ref(tsc): useReleasesWidgetQuery to apiOptions#114427
Merged
Conversation
Collaborator
Author
|
bugbot run |
Contributor
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 309ea1e. Configure here.
JonasBa
reviewed
Apr 30, 2026
| if (queue) { | ||
| return new Promise((resolve, reject) => { | ||
| const fetchFnRef = { | ||
| current: () => |
JonasBa
approved these changes
Apr 30, 2026
Contributor
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.40% |
cleptric
pushed a commit
that referenced
this pull request
May 5, 2026
Migrate the `useReleasesSeriesQuery` and `useReleasesTableQuery` hooks
(the `/sessions/` and `/metrics/data/` callers behind release-health
widget cards) onto `apiOptions` so their results live in the v2 query
cache.
The widgets previously built v1 query keys by hand and dispatched via
`doSessionsRequest` / `doReleaseHealthRequest`, which used
`api.requestPromise` directly and never participated in the structured
cache. To keep the existing imperative call site
(`projectAnrScoreCard.tsx`) working without a behavior change, both
action creators now share their URL-query construction with two new
factories:
- `sessionsApiOptions(options)` →
`apiOptions.as<SessionApiResponse>()('/organizations/$organizationIdOrSlug/sessions/',
...)`
- `releaseHealthApiOptions(options)` →
`apiOptions.as<SessionApiResponse>()('/organizations/$organizationIdOrSlug/metrics/data/',
...)`
`useReleasesWidgetQuery.tsx` picks the factory based on
`requestData.useSessionAPI`, then overrides `queryFn` with the existing
queue-wrapping pattern (calling `apiFetch` instead of the imperative
wrappers). `select: selectJsonWithHeaders` exposes both the JSON body
and the `Link` header used for pagination. Result-access in the
transform block updates from the v1 tuple to v2 shape (`q.data?.[0]` →
`q.data?.json`, `responseMeta?.getResponseHeader('Link')` →
`q.data.headers.Link`).
`projectAnrScoreCard.tsx` is also rewritten to consume
`sessionsApiOptions` directly via `useQuery`, replacing the two ad-hoc
`useEffect` + manual `setState` blocks with cached queries that get
cancellation and dedup for free.
The remaining `~17` other callers of `/sessions/` (insights hooks,
project score cards, releases pages, charts) are intentionally left on
v1 for now: there are no `invalidateQueries` / `setQueryData` predicates
that match this URL anywhere in the codebase, and each caller's `query`
params produce a distinct cache slot, so a v1/v2 mix is independent — no
leak, no clobber. Migrating them is mechanical follow-up work, not a
correctness gate for this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrate the
useReleasesSeriesQueryanduseReleasesTableQueryhooks (the/sessions/and/metrics/data/callers behind release-health widget cards) ontoapiOptionsso their results live in the v2 query cache.The widgets previously built v1 query keys by hand and dispatched via
doSessionsRequest/doReleaseHealthRequest, which usedapi.requestPromisedirectly and never participated in the structured cache. To keep the existing imperative call site (projectAnrScoreCard.tsx) working without a behavior change, both action creators now share their URL-query construction with two new factories:sessionsApiOptions(options)→apiOptions.as<SessionApiResponse>()('/organizations/$organizationIdOrSlug/sessions/', ...)releaseHealthApiOptions(options)→apiOptions.as<SessionApiResponse>()('/organizations/$organizationIdOrSlug/metrics/data/', ...)useReleasesWidgetQuery.tsxpicks the factory based onrequestData.useSessionAPI, then overridesqueryFnwith the existing queue-wrapping pattern (callingapiFetchinstead of the imperative wrappers).select: selectJsonWithHeadersexposes both the JSON body and theLinkheader used for pagination. Result-access in the transform block updates from the v1 tuple to v2 shape (q.data?.[0]→q.data?.json,responseMeta?.getResponseHeader('Link')→q.data.headers.Link).projectAnrScoreCard.tsxis also rewritten to consumesessionsApiOptionsdirectly viauseQuery, replacing the two ad-hocuseEffect+ manualsetStateblocks with cached queries that get cancellation and dedup for free.The remaining
~17other callers of/sessions/(insights hooks, project score cards, releases pages, charts) are intentionally left on v1 for now: there are noinvalidateQueries/setQueryDatapredicates that match this URL anywhere in the codebase, and each caller'squeryparams produce a distinct cache slot, so a v1/v2 mix is independent — no leak, no clobber. Migrating them is mechanical follow-up work, not a correctness gate for this change.