Skip to content

ref(seer): Add viewer_context passthrough to all Seer API wrappers#109697

Merged
azulus merged 1 commit intomasterfrom
jstanley/ref-propagating-seer-context
Mar 2, 2026
Merged

ref(seer): Add viewer_context passthrough to all Seer API wrappers#109697
azulus merged 1 commit intomasterfrom
jstanley/ref-propagating-seer-context

Conversation

@azulus
Copy link
Member

@azulus azulus commented Mar 2, 2026

Summary

  • Propagates the optional viewer_context: SeerViewerContext | None kwarg through all 51 wrapper functions across 15 files that call make_signed_seer_api_request()
  • Enables callers to pass organization and user context which gets HMAC-signed into X-Viewer-Context / X-Viewer-Context-Signature headers for Seer access control
  • All new params default to None — no call sites are changed yet

Builds on #109626 which added viewer_context support to make_signed_seer_api_request().

Test plan

  • All changes are additive (new optional param defaulting to None), so existing behavior is unchanged
  • Pre-commit passes on all 15 modified files
  • CI should validate no regressions

Propagate the optional `viewer_context: SeerViewerContext | None` kwarg
through all 51 wrapper functions that call `make_signed_seer_api_request`.
This enables callers to pass organization and user context which gets
HMAC-signed into `X-Viewer-Context` headers for Seer access control.

No call sites are changed yet — all new params default to `None`.
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 2, 2026
@azulus azulus marked this pull request as ready for review March 2, 2026 19:37
@azulus azulus requested review from a team as code owners March 2, 2026 19:37
@azulus azulus merged commit 76c6f53 into master Mar 2, 2026
77 checks passed
@azulus azulus deleted the jstanley/ref-propagating-seer-context branch March 2, 2026 20:03
azulus added a commit that referenced this pull request Mar 3, 2026
Pass `SeerViewerContext` to all Seer API wrapper call sites in the
replays module.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR updates the replays module call sites:

- **Endpoint** (`project_replay_summary`): Pass both `organization_id`
and `user_id` to start/state requests
- **Delete usecase** (`delete.py`): Pass `organization_id` only
(background task, no user context)

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 3, 2026
…09719)

Pass `SeerViewerContext` through similarity/grouping code to all Seer
call sites.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR threads it through
`get_similarity_data_from_seer()` and updates all callers:

- **Endpoint** (`group_similar_issues_embeddings`): Pass both
`organization_id` and `user_id`
- **Grouping ingest** (`seer.py`): Pass `organization_id` only from
`event.project` (no user in ingest context)

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
…109718)

Pass `SeerViewerContext` through breakpoint detection to all call sites.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR threads it through `detect_breakpoints()` and
updates all callers:

- **Endpoints** (`organization_events_trends_v2`,
`organization_profiling_functions`): Pass both `organization_id` and
`user_id`
- **Statistical detector tasks**: Pass `organization_id` only
(background task, no user)
- Uses `functools.partial` for `ThreadPoolExecutor.map` compatibility in
trends endpoint

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
…tes (#109720)

Pass `SeerViewerContext` to all Seer API wrapper call sites in anomaly
detection.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR constructs context at each call site from
available org data:

- `get_anomaly_data.py`: From `subscription.project.organization_id`
- `store_data.py`: From `alert_rule.organization.id`
- `store_data_workflow_engine.py`: From `project.organization.id`
- `delete_rule.py`: From `organization.id`
- `get_historical_anomalies.py`: From `organization_id` parameter

All are background/task contexts with org only (no user).

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
)

Pass `SeerViewerContext` to all Seer API wrapper call sites in the
feedback module.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR updates the call sites in the feedback module
to construct and pass `SeerViewerContext` from available org/user data:

- **Endpoints** (`organization_feedback_categories`,
`organization_feedback_summary`): Pass both `organization_id` and
`user_id`
- **Ingest** (`create_feedback`): Pass `organization_id` only (no user
in ingest context)
- **Intermediate functions** (`spam_detection`, `label_generation`,
`title_generation`): Thread `viewer_context` parameter through to
underlying API calls

No behavior change — `viewer_context` defaults to `None` which preserves
the existing behavior of not sending the header.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
)

Pass `SeerViewerContext` to all Seer API wrapper call sites in the
explorer module.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR updates the explorer module call sites:

- **SeerExplorerClient**: Builds context from `self.organization` and
`self.user` in `__init__`, passes to `start_run`, `continue_run`,
`get_runs`, `push_changes`
- **Service map utils** (`_send_to_seer`): Pass `organization_id` only
(no user available)

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
…109717)

Pass `SeerViewerContext` to the Seer API call site in the code review
webhook task.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR updates `process_github_webhook_event()` to
extract `sentry_organization_id` from the tags dict and construct a
`SeerViewerContext` when available.

No behavior change — if tags are missing or don't contain the org ID,
`viewer_context` remains `None`.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
#109721)

Pass `SeerViewerContext` to Seer API call sites in LLM issue detection
and event manager.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR updates two call sites:

- **LLM issue detection task**: Constructs context from
`organization_id` already in scope
- **Event manager severity scoring**: Constructs context from
`event.project.organization_id` (already loaded, no extra DB query)

Both are background contexts with org only (no user).

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
Pass `SeerViewerContext` to all Seer API wrapper call sites in the
autofix module.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR updates autofix call sites:

- **`_call_autofix()`**: Pass `organization_id` + `user_id` (when not
anonymous)
- **`update_autofix()`**: Pass `organization_id` only
- **`utils.py`** (`get_autofix_state`,
`bulk_get/set_project_preferences`): Pass `organization_id` only
- **`issue_summary.py`** (`_call_seer`, `_generate_fixability_score`):
Pass `organization_id` from group
- **`project_seer_preferences` endpoint**: Pass both `organization_id`
and `user_id`
- **`tasks/seer.py`** (`cleanup_seer_repository_preferences`): Pass
`organization_id` only
- **Skipped**: `_fetch_user_preference` (only has `project_id`, no org
context)

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
)

Pass `SeerViewerContext` to Seer API wrapper call sites in various Seer
endpoint modules.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR updates 8 files:

- `compare.py` + `organization_trace_item_attributes_ranked.py`: Compare
distributions
- `issue_view_title_generate.py`: Title generation from query
- `search_agent_state.py`, `search_agent_start.py`: Search agent
endpoints
- `trace_explorer_ai_query.py`,
`trace_explorer_ai_translate_agentic.py`, `trace_explorer_ai_setup.py`:
Trace explorer AI endpoints

All are API endpoints with both `organization_id` and `user_id`
available. Intermediate functions thread `viewer_context` through to the
underlying wrapper calls.

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
azulus added a commit that referenced this pull request Mar 4, 2026
…#109724)

Pass `SeerViewerContext` to Seer API wrapper call sites in background
tasks and utility modules.

PR #109697 added an optional `viewer_context` parameter to all Seer API
wrapper functions. This PR updates:

- **`context_engine_index.py`**: Pass `organization_id` from `org_id`
param
- **`seer_explorer_index.py`**: Pass `organization_id` from project
tuples
- **`trace_summary.py`**: Pass `organization_id` + optional `user_id`
(when user is not None/anonymous)
- **`supergroups.py`**: Pass `organization_id` from param
- **Skipped**: `seer_models.py` (no auth), `uptime/seer_assertions.py`
(no context)

No behavior change — `viewer_context` defaults to `None` which preserves
existing behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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