Skip to content

feat(integrations): Set ViewerContext on webhook handlers - #112284

Merged
gricha merged 2 commits into
masterfrom
gricha/feat/webhook-viewer-context
Apr 7, 2026
Merged

gricha merged 2 commits into
masterfrom
gricha/feat/webhook-viewer-context

Conversation

@gricha

@gricha gricha commented Apr 6, 2026

Copy link
Copy Markdown
Member

Add webhook_viewer_context(org_id) helper that wraps webhook per-org processing in viewer_context_scope with actor_type=INTEGRATION. Gated behind the viewer-context.enabled option so it rolls out with the rest of the ViewerContext infrastructure.

Wired into 5 webhook handlers at the point where organization_id is known:

  • GitHub — inside per-repo loop in GitHubWebhook.__call__
  • GitLab — inside per-install loop in GitlabWebhookEndpoint.post
  • Bitbucket — wrapping handler call (org from URL param)
  • Bitbucket Server — wrapping handler call (org from URL param)
  • Cursor — wrapping _process_webhook (org from URL param)

Remaining integrations (Slack, Jira Server, MS Teams, Vercel) resolve the organization deeper in the stack and need separate work — they're tracked but not in scope here.

Part of the ViewerContext RFC.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 6, 2026
@gricha
gricha marked this pull request as ready for review April 6, 2026 22:24
@gricha
gricha requested a review from a team as a code owner April 6, 2026 22:24
@gricha
gricha requested a review from a team April 6, 2026 22:24
@gricha
gricha requested a review from a team as a code owner April 6, 2026 22:24
@gricha
gricha force-pushed the gricha/feat/webhook-viewer-context branch from 355b655 to 715d0ce Compare April 6, 2026 22:35
@gricha
gricha force-pushed the gricha/feat/webhook-viewer-context branch from 715d0ce to 4227003 Compare April 7, 2026 01:32
gricha and others added 2 commits April 7, 2026 09:51
Add webhook_viewer_context() helper that wraps webhook per-org
processing in a viewer_context_scope with actor_type=INTEGRATION.
Gated behind the viewer-context.enabled option.

Wired into GitHub, GitLab, Bitbucket, Bitbucket Server, and Cursor
webhook handlers at the point where organization_id is known.

Remaining integrations (Slack, Jira Server, MS Teams, Vercel) resolve
the org deeper in the stack and need separate work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gricha
gricha merged commit f9145c6 into master Apr 7, 2026
59 checks passed
@gricha
gricha deleted the gricha/feat/webhook-viewer-context branch April 7, 2026 17:02
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
Add `webhook_viewer_context(org_id)` helper that wraps webhook per-org
processing in `viewer_context_scope` with `actor_type=INTEGRATION`.
Gated behind the `viewer-context.enabled` option so it rolls out with
the rest of the ViewerContext infrastructure.

Wired into 5 webhook handlers at the point where `organization_id` is
known:
- **GitHub** — inside per-repo loop in `GitHubWebhook.__call__`
- **GitLab** — inside per-install loop in `GitlabWebhookEndpoint.post`
- **Bitbucket** — wrapping handler call (org from URL param)
- **Bitbucket Server** — wrapping handler call (org from URL param)
- **Cursor** — wrapping `_process_webhook` (org from URL param)

Remaining integrations (Slack, Jira Server, MS Teams, Vercel) resolve
the organization deeper in the stack and need separate work — they're
tracked but not in scope here.

Part of the [ViewerContext
RFC](https://www.notion.so/sentry/RFC-Unified-ViewerContext-via-ContextVar-32f8b10e4b5d81988625cb5787035e02).

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2026

This branch was successfully deployed

1 active deployment
Preview — fdef6fd4 Deployed Apr 7, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants