Sentry Plugin
Use the Sentry plugin to investigate issues with a user’s Sentry account, make requested project, team, and alert changes, and respond to new issues and metric alerts through watches and event automations.
Junior stores each user’s OAuth grant and uses it only for that user’s requests. Optional org read access lets Junior read Sentry data without a user’s OAuth token, such as in scheduled tasks and event automations. Webhooks use a separate internal integration.
Install
Section titled “Install”pnpm add @sentry/junior @sentry/junior-sentryimport { defineJuniorPlugins } from "@sentry/junior";import { sentryPlugin } from "@sentry/junior-sentry";
export const plugins = defineJuniorPlugins([sentryPlugin()]);Register sentryPlugin() so Junior loads the webhook route.
Config
Section titled “Config”Ask Junior to set conversation config in a Slack channel or Space, or define the same keys for every conversation with createApp({ configDefaults }). Set deployment variables in the Junior environment, then redeploy. Explicit values in a request always win over conversation defaults.
Conversation defaults
Section titled “Conversation defaults”sentry.org
Default Sentry organization slug when a request does not name one.
- Define: ask Junior to set
sentry.org - Install-wide default:
configDefaults["sentry.org"] - Required: No
- Environment override: None
sentry.project
Default Sentry project slug when a request does not name one. With sentry.org, Junior also links the issue short ids of this project in its replies, such as JUNIOR-3ZK for the junior project.
- Define: ask Junior to set
sentry.project - Install-wide default:
configDefaults["sentry.project"] - Required: No
- Environment override: None
Environment variables
Section titled “Environment variables”SENTRY_CLIENT_ID
OAuth client ID used when a user connects their Sentry account.
- Define: Set
SENTRY_CLIENT_IDin the deployment environment - Required: Yes for user OAuth
- Environment override:
SENTRY_CLIENT_ID
SENTRY_CLIENT_SECRET
OAuth client secret used when a user connects their Sentry account.
- Define: Set
SENTRY_CLIENT_SECRETin the deployment environment - Required: Yes for user OAuth
- Environment override:
SENTRY_CLIENT_SECRET
SENTRY_READ_TOKEN
Internal integration token with read-only scopes. Junior uses it for Sentry API reads.
- Define: Set
SENTRY_READ_TOKENin the deployment environment - Required: Yes for org read access; otherwise no
- Environment override:
SENTRY_READ_TOKEN
SENTRY_WEBHOOK_SECRET
Internal integration client secret used to verify webhooks.
- Define: Set
SENTRY_WEBHOOK_SECRETin the deployment environment - Required: Yes for events; otherwise no
- Environment override:
SENTRY_WEBHOOK_SECRET
Set up user OAuth
Section titled “Set up user OAuth”Create a Sentry OAuth app with this redirect URL:
<base-url>/api/oauth/callback/sentrySet SENTRY_CLIENT_ID and SENTRY_CLIENT_SECRET to the app’s credentials. Junior requests these scopes:
alerts:write event:write member:read org:read project:releases project:write team:write
Reconnect after scope changes. Existing grants do not pick up new scopes automatically.
With these scopes, Junior can make Sentry writes that a user asks for, such as creating projects, changing project settings, managing teams, and managing alerts. The user’s own Sentry role still applies. The skill does not limit which requests Junior makes. To limit access, narrow the OAuth scopes or add host egress rules.
Set up org read access
Section titled “Set up org read access”Without org read access, every Sentry request needs the requesting user’s OAuth token. Scheduled tasks, event automations, and messages from other bots cannot send an authorization link, so their Sentry requests fail.
Use a separate Sentry internal integration from the webhook integration, so you can revoke it on its own.
- Create an internal integration in the organization.
- Grant read-only permissions for Project, Issue & Event, Organization, and Release.
- Create a token for the integration.
- Set
SENTRY_READ_TOKENto the token. - Redeploy Junior.
Junior uses the token for GET, HEAD, and OPTIONS requests to the Sentry API. This includes Explore queries for spans, logs, and traces. Sentry limits the token to the organization that installed the integration. Writes and /api/0/users/ requests use the requesting user’s OAuth token.
Anyone who can talk to Junior can read every project the token can read. Sentry audit logs show the integration, not the Slack user.
Issue link cards
Section titled “Issue link cards”The dashboard shows a card for a link to a Sentry issue or to one of its events, on sentry.io/organizations/<org>/ or on <org>.sentry.io. The card shows the title, the culprit, the state, the assignee, the priority, the project, and a line of events per hour for the last day.
A link to a user feedback, such as <org>.sentry.io/feedback/?feedbackSlug=<project>:<id>, gets a feedback card. It shows the title, the message, the state, the assignee, and the project. It never shows the name or email of the person who sent the feedback.
- Each viewer must connect Sentry on the dashboard Connections page. Junior asks Sentry, with that viewer’s own token, whether the viewer can open the issue. Without a connection, or without access, the viewer gets no card. Junior never asks the viewer to connect for a card.
- Junior reads the card with the org read token, so set
SENTRY_READ_TOKEN. It sends the issue calls to the org’s region host, such asus.sentry.ioorde.sentry.io, from thelinks.regionUrlof the org.
Set up issue webhooks
Section titled “Set up issue webhooks”Create a Sentry internal integration in the organization that should send issue webhooks. A public Sentry app is not required.
- Create an internal integration.
- Enable the issue webhook resource.
- Set the webhook URL to:
https://<junior-host>/api/webhooks/sentry- Set
SENTRY_WEBHOOK_SECRETto the integration’s client secret. - Redeploy Junior.
Junior verifies each webhook signature. An internal integration belongs to one organization, so a valid signature also identifies the organization. Junior reads the organization slug from the signed payload.
Metric alert webhooks
Section titled “Metric alert webhooks”Sentry sends metric alerts only to an integration that is an action on the alert.
- In the same internal integration, enable Alert Rule Action.
- On each metric alert that Junior should receive, add this trigger action:
{ "type": "sentry_app", "sentryAppId": <integration-id>, "targetType": "sentry_app", "targetIdentifier": <integration-id>}For a metric monitor, add an alert that notifies the integration as a service. Sentry then sends each firing as an event_alert webhook for the monitor’s metric issue. Junior publishes a firing at high priority as metric_alert.critical and one at medium priority as metric_alert.warning. The alert rule id is the monitor’s legacy alert rule id, or the monitor id plus 10,000,000,000 when it has none. Junior does not publish resolved monitors or other issue alerts from this webhook.
Watches
Section titled “Watches”Set SENTRY_WEBHOOK_SECRET to enable watches. See Watches for the difference between temporary watches and durable event automations.
Subscribe to one issue with org/project#issueId.
issue.created
The issue was created.
project
Section titled “project”Subscribe to all new issues and metric alerts in a project with org/project.
issue.created
An issue was created in the project.
metric_alert.critical, metric_alert.warning, metric_alert.resolved
A metric alert on the project changed state. Junior uses the projects on the alert rule. The alert must still have Junior as a trigger action.
metric_alert
Section titled “metric_alert”Subscribe to one metric alert with metric-alert:org/alertRuleId.
metric_alert.critical
The alert reached its critical threshold.
metric_alert.warning
The alert reached its warning threshold.
metric_alert.resolved
The alert resolved.
Junior publishes each state once for each alert incident.
An event automation selects Sentry events with filters instead of an
identifier, and can run for every project in the Sentry org. issue.created, metric_alert.critical, metric_alert.warning,
and metric_alert.resolved can run that way with no filter. Use the
projects filter to limit one to some projects. Junior saves project slugs in
lowercase. Junior does not check that the creator can see the projects, so a
broad automation can post private project names in its channel. See
Automations.
Create the watch or event automation before the webhook arrives. Junior does not replay earlier webhooks.
Verify
Section titled “Verify”OAuth: Connect Sentry from Slack, then query an issue or organization.
Org read access: Ask Junior to read an issue from a scheduled task, then make sure it does not ask you to connect Sentry.
Webhooks: Subscribe to a project, then create a test issue in that project. For metric alerts, subscribe to the alert, then lower its threshold until it triggers.
Security
Section titled “Security”- Junior stores user tokens and does not include them in model input.
- The org read token is used only for read requests. Writes always need the requesting user’s OAuth token.
- Webhooks use the internal integration client secret, not user OAuth.
- Missing or stale user authorization starts a private reconnect flow.
Failure modes
Section titled “Failure modes”- OAuth callback fails: Set the app’s redirect URL to exactly
<base-url>/api/oauth/callback/sentry. - Sentry returns
401: Reconnect Sentry to replace the stale or revoked token. - Sentry reports a missing scope: Reconnect Sentry to grant the current scopes.
- Sentry returns
403: Connect an account with access to the requested organization and project. With org read access, also check the integration’s read permissions. - A scheduled task cannot read Sentry: Set
SENTRY_READ_TOKEN. Confirm the request targets the organization that installed the integration. - Webhooks are ignored: Check
SENTRY_WEBHOOK_SECRET, then confirm a matching watch or event automation exists. For metric alerts, also confirm the integration is a trigger action on the alert. - Authorization links use the wrong host: Set
JUNIOR_BASE_URLto Junior’s public URL.
Next step
Section titled “Next step”Review Watches and Security Hardening.