ref(dashboards): Remove Widget Viewer manual caching layer#109689
Merged
ref(dashboards): Remove Widget Viewer manual caching layer#109689
Conversation
edwardgou-sentry
approved these changes
Mar 3, 2026
DominikB2014
approved these changes
Mar 3, 2026
Contributor
DominikB2014
left a comment
There was a problem hiding this comment.
Lgtm! Just to confirm, did you test out the react query caching as well, just to ensure it's working as expected and we didn't mess up any query keys.
Member
Author
|
@DominikB2014 I did, yeah! I actually used the TanStack Devtools UI for the first time, pretty handy 👍🏻 |
Remove the convoluted caching system where WidgetCard pushed fetched data into a WidgetViewerContext, which DashboardDetail then read and passed as props to the Widget Viewer modal. Since widget data fetching now uses hooks backed by TanStack Query, the query cache serves as the data store, making this manual caching layer redundant. - Delete widgetViewerContext.tsx - Remove WidgetViewerContext provider from DashboardDetail - Remove cached data props from WidgetViewerModalOptions interface - Remove chartUnmodified state and conditional cached-data rendering - Remove setChartUnmodified from ViewerTableV2 - Update tests to not rely on cached data behavior Refs DAIN-1253 Co-Authored-By: Claude <noreply@anthropic.com>
This will increase the amount of request re-use. Using my judgement for this one, we can tweak later.
Tests now provide proper mock API responses instead of relying on cached data props. Add events-stats meta for duration formatting, adjust session request counts for mount fetches, and provide span event data for table rendering. Co-Authored-By: Claude <noreply@anthropic.com>
Function is only used within the same file now that the dashboard stale time logic uses its own GranularityLadder.
Replace GranularityLadder with RangeMap since it maps duration ranges directly to millisecond values without the intermediate string conversion step. Co-Authored-By: Claude <noreply@anthropic.com>
75a27bd to
670cb46
Compare
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.
Remove the manual caching system where WidgetCard pushed fetched data into a WidgetViewerContext, which DashboardDetail then read and passed as props to the Widget Viewer modal. Since widget data fetching now uses hooks backed by TanStack Query, the query cache serves as the data store. When the modal opens and renders the same query hooks, TanStack Query returns cached data instantly, making the manual caching layer redundant.
This deletes the WidgetViewerContext entirely, removes the cached data props and conditional rendering branches from the modal, and simplifies the DashboardDetail component state.
Also increases stale time for dashboard widget queries using a custom GranularityLadder that scales with the selected time range. This ensures the TanStack Query cache serves data when the Widget Viewer opens, reducing redundant API requests. The stale times are more generous than Insights/Explore since dashboards are more static.
Refs DAIN-1253