Repository navigation
feat(cli): migrate dashboard chart widgets to events-timeseries - #1901
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
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/apialready provides. The CLI rule is to import API response types from@sentry/apiand not re-declare them as Valibot schemas insrc/types/.@sentry/[email protected](the catalog version) shipsListOrganizationEventsTimeseriesResponse,vListOrganizationEventsTimeseriesResponse, andListOrganizationEventsTimeseriesData["query"]. BuildEventsTimeseries*SchemafromvListOrganizationEventsTimeseriesResponseentries, and override only the two fields where the generated spec is narrower than what the server returns:groupByis nullable on the Other series, andvaluecan be a string on errors. Put a short "why" comment on each override, or fix the serializer upstream. Then typereqParams/buildTopEventsParamswithListOrganizationEventsTimeseriesData["query"]and drop the looseRecord<string, string | string[] | number | undefined>. That way a typo ingroupBy/excludeOtherfails to compile. throw new Error("Unexpected events-timeseries response shape")skips the shared validation path. CLI errors should extendCliError. The neighboringqueryWidgetTablealready passesschema:toapiRequestToRegion, which throws anApiErrorwith the Valibot issue messages and attaches the strippedschema_validationcontext to the Sentry event. Here the issues are thrown away, so a future shape drift (like the nullgroupBy/stringvaluefixed in the second commit) shows up as one opaque message. Passschema: EventsTimeseriesResponseSchematoapiRequestToRegionand delete the manualsafeParse+throw. The existing "malformed response" test should still pass, becausequeryWidgetDatacatches it.- Tests sit at the wrong layer. The new
dashboard.test.tscases 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. Onefast-checkproperty over generatedtimeSeriesarrays covers those invariants better than the fixed examples. Keep thedashboards.test.tsrequest-param tests; they're the right kind of unit test.
…piRequestToRegion Label a real "Other" group as "Other ()" and trim schema tests to the spec overrides.
5c5a608 to
3612fd2
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
Superseded by re-review on 3612fd2: the requested changes are addressed.
There was a problem hiding this comment.
Re-reviewed at 3612fd2. LGTM. I dismissed my earlier change request.
- Schema:
EventsTimeseries*Schemanow comes fromvListOrganizationEventsTimeseriesResponse. Only the two documented overrides are changed (nullablegroupByfor Other, stringvalue). Both match whatorganization_events_timeseries.pyandcreate_groupby_dictcan emit (groupby: Noneon Other,row.get(value_column, 0)passed through unchanged). - Validation:
schema:goes throughapiRequestToRegion, so shape drift now shows up as anApiErrorwith the issue messages instead of an opaque throw. - Tests: the new
queryAllWidgetscases 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
reqParamstyping ask:ListOrganizationEventsTimeseriesData["query"]in@sentry/[email protected]typesintervalasnumberandyAxisas a singlestring. 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
groupBythread, your reply is correct:getTimeseriesRequestQueryin getsentry/sentry sendsgroupBy: field, wherefieldis columns + aggregates + the orderby column. The server only readsgroupBy(notfield) on this endpoint, so it's fine that the CLI only sendsgroupBy.

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.