Skip to content

fix(stats): align timezone handling with user preferences and UTC params#119331

Merged
billyvg merged 7 commits into
masterfrom
fix/stats-page-timezone-mismatch
Jul 10, 2026
Merged

fix(stats): align timezone handling with user preferences and UTC params#119331
billyvg merged 7 commits into
masterfrom
fix/stats-page-timezone-mismatch

Conversation

@billyvg

@billyvg billyvg commented Jul 9, 2026

Copy link
Copy Markdown
Member

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.tsxdataDatetime getter: Changed moment(start).utc() to moment.utc(start). The prior form treated the raw URL start/end params (which have no timezone suffix) as local time before converting to UTC, adding an extra offset. DatePageFilter treats the same strings as already-UTC, so the chart was systematically shifted by the user's UTC offset relative to the time selector.

usageStatsOrg.tsxchartDateRange memo: Replaced .local() with .tz(getUserTimezone()) for displayStart/displayEnd. moment().local() resolves to the browser system timezone, not the user's Sentry account timezone preference. This caused the chart date display and the Date Range: footer label to show the wrong timezone when user preferences differed from the browser.

usageChart/utils.tsxgetDateFromMoment: Same .local().tz(getUserTimezone()) fix for the x-axis date label generation.

Follows the same pattern already used by timeSeriesWidgetVisualization.tsx and heatMapWidgetVisualization.tsx.

What's verified

  • 3-file diff is minimal and surgical; no logic changes beyond the timezone resolution
  • getUserTimezone() is a stable export from sentry/utils/dates already imported throughout the codebase
  • Existing tests for usageChart/utils.spec.tsx and index.spec.tsx cover the datetime logic
image

Fixes #119327

--

View Junior Session in Sentry

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 9, 2026
@billyvg

billyvg commented Jul 9, 2026

Copy link
Copy Markdown
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.

@billyvg billyvg marked this pull request as ready for review July 9, 2026 19:33
@billyvg billyvg requested a review from a team as a code owner July 9, 2026 19:33
Comment thread static/app/views/organizationStats/usageChart/utils.tsx Outdated
@billyvg billyvg merged commit 5c4e7b6 into master Jul 10, 2026
71 checks passed
@billyvg billyvg deleted the fix/stats-page-timezone-mismatch branch July 10, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stats page: chart range doesn't match time selector; timezone ignores user preference

2 participants