Skip to content

feat(cli): migrate dashboard chart widgets to events-timeseries - #1901

Merged
edwardgou-sentry merged 3 commits into
mainfrom
feat/dashboard-events-timeseries
Nov 5, 2026
Merged

edwardgou-sentry merged 3 commits into
mainfrom
feat/dashboard-events-timeseries

Conversation

@edwardgou-sentry

Copy link
Copy Markdown
Contributor

Switch chart widget queries from events-stats to events-timeseries.
Parse the new timeSeries response shape and match the Sentry UI for grouped (topEvents) params and series labels.
Renderers are unchanged; incomplete-bucket display will follow in a stacked PR.

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 5, 2026 7:49pm UTC

Request Review

@BYK
BYK marked this pull request as ready for review November 5, 2026 13:33
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 5, 2026
sentry-junior[bot]
sentry-junior Bot previously requested changes Nov 5, 2026

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the switch against organization_events_timeseries.py in getsentry/sentry. groupBy/sort/topEvents/excludeOther, string intervals (same get_rollup_from_request path), and top-events support for all four mapped datasets all line up. A few things don't follow packages/cli/AGENTS.md, though:

  • Hand-written response schemas that @sentry/api already provides. The CLI rule is to import API response types from @sentry/api and not re-declare them as Valibot schemas in src/types/. @sentry/[email protected] (the catalog version) ships ListOrganizationEventsTimeseriesResponse, vListOrganizationEventsTimeseriesResponse, and ListOrganizationEventsTimeseriesData["query"]. Build EventsTimeseries*Schema from vListOrganizationEventsTimeseriesResponse entries, and override only the two fields where the generated spec is narrower than what the server returns: groupBy is nullable on the Other series, and value can be a string on errors. Put a short "why" comment on each override, or fix the serializer upstream. Then type reqParams/buildTopEventsParams with ListOrganizationEventsTimeseriesData["query"] and drop the loose Record<string, string | string[] | number | undefined>. That way a typo in groupBy/excludeOther fails to compile.
  • throw new Error("Unexpected events-timeseries response shape") skips the shared validation path. CLI errors should extend CliError. The neighboring queryWidgetTable already passes schema: to apiRequestToRegion, which throws an ApiError with the Valibot issue messages and attaches the stripped schema_validation context to the Sentry event. Here the issues are thrown away, so a future shape drift (like the null groupBy/string value fixed in the second commit) shows up as one opaque message. Pass schema: EventsTimeseriesResponseSchema to apiRequestToRegion and delete the manual safeParse + throw. The existing "malformed response" test should still pass, because queryWidgetData catches it.
  • Tests sit at the wrong layer. The new dashboard.test.ts cases mostly check that the schema accepts or rejects hand-picked objects. Once the schema comes from @sentry/api, they are testing generated code. The real logic here is a pure transform: ms→s timestamps, coercing null/""/string buckets, Other always last, and unique labels when there are several axes. The CLI testing hierarchy puts that in property tests. One fast-check property over generated timeSeries arrays covers those invariants better than the fixed examples. Keep the dashboards.test.ts request-param tests; they're the right kind of unit test.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/cli/src/lib/api/dashboards.ts Resolved
@edwardgou-sentry
edwardgou-sentry force-pushed the feat/dashboard-events-timeseries branch from 5c5a608 to 3612fd2 Compare November 5, 2026 19:49

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3612fd2. Configure here.

Comment thread packages/cli/src/lib/api/dashboards.ts Resolved
@sentry-junior
sentry-junior Bot dismissed their stale review November 5, 2026 20:18

Superseded by re-review on 3612fd2: the requested changes are addressed.

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 3612fd2. LGTM. I dismissed my earlier change request.

  • Schema: EventsTimeseries*Schema now comes from vListOrganizationEventsTimeseriesResponse. Only the two documented overrides are changed (nullable groupBy for Other, string value). Both match what organization_events_timeseries.py and create_groupby_dict can emit (groupby: None on Other, row.get(value_column, 0) passed through unchanged).
  • Validation: schema: goes through apiRequestToRegion, so shape drift now shows up as an ApiError with the issue messages instead of an opaque throw.
  • Tests: the new queryAllWidgets cases test the transform at the right layer, and the mock validates against the real schema. A fast-check property would still be nice for the label/ordering invariants, but I don't need it to merge.
  • Dropping my earlier reqParams typing ask: ListOrganizationEventsTimeseriesData["query"] in @sentry/[email protected] types interval as number and yAxis as a single string. The CLI correctly sends "1h" and an array, so that type would need its own overrides. The loose record is fine here.
  • On the Bugbot groupBy thread, your reply is correct: getTimeseriesRequestQuery in getsentry/sentry sends groupBy: field, where field is columns + aggregates + the orderby column. The server only reads groupBy (not field) on this endpoint, so it's fine that the CLI only sends groupBy.

@edwardgou-sentry
edwardgou-sentry merged commit 4f1162a into main Nov 5, 2026
27 checks passed
@edwardgou-sentry
edwardgou-sentry deleted the feat/dashboard-events-timeseries branch November 5, 2026 20:25

This branch was previously deployed

1 inactive deployment
Preview — 3612fd2a Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants