fix(stats): align timezone handling with user preferences and UTC params#119331
Merged
Conversation
Member
Author
|
Tested this on preview: load stats page, observe timestamps in date picker, chart tooltips, and the date range label below chart. change account tz in different tab. refresh dev preview and observe new timestamps. |
ryan953
approved these changes
Jul 10, 2026
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.
Fixes two bugs on the Stats page (
/settings/stats/) where the chart date range didn't match the time selector and the timezone label ignored user account preferences.What changed
index.tsx—dataDatetimegetter: Changedmoment(start).utc()tomoment.utc(start). The prior form treated the raw URLstart/endparams (which have no timezone suffix) as local time before converting to UTC, adding an extra offset.DatePageFiltertreats the same strings as already-UTC, so the chart was systematically shifted by the user's UTC offset relative to the time selector.usageStatsOrg.tsx—chartDateRangememo: Replaced.local()with.tz(getUserTimezone())fordisplayStart/displayEnd.moment().local()resolves to the browser system timezone, not the user's Sentry account timezone preference. This caused the chart date display and theDate Range:footer label to show the wrong timezone when user preferences differed from the browser.usageChart/utils.tsx—getDateFromMoment: Same.local()→.tz(getUserTimezone())fix for the x-axis date label generation.Follows the same pattern already used by
timeSeriesWidgetVisualization.tsxandheatMapWidgetVisualization.tsx.What's verified
getUserTimezone()is a stable export fromsentry/utils/datesalready imported throughout the codebaseusageChart/utils.spec.tsxandindex.spec.tsxcover the datetime logicFixes #119327
--
View Junior Session in Sentry