Skip to content

feat: support switch to UTC for usage page#504

Open
drankou wants to merge 3 commits into
mainfrom
add-timezone-switcher-to-usage-dashboard-dash-162
Open

feat: support switch to UTC for usage page#504
drankou wants to merge 3 commits into
mainfrom
add-timezone-switcher-to-usage-dashboard-dash-162

Conversation

@drankou

@drankou drankou commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Adds a page-scoped UTC switch to the usage page so displayed totals can match billing, which aggregates over UTC calendar boundaries.

  • shows an info banner when the user's timezone differs from UTC, with a one-click "View in UTC" toggle held in the utc query param — the persisted timezone preference is untouched
  • pins all charts, presets, and time pickers on the page to UTC via a TimezoneOverride provider that shadows useTimezone() for the subtree, so existing consumers need no changes
  • toggling re-anchors preset-aligned ranges ("This month", "Last 30 days", …) to the target timezone's calendar boundaries; custom ranges are kept as picked
  • preset matching now prefers the closest match instead of the first within tolerance, so toggling near month ends doesn't drop a day from the range
  • unit tests cover timezone resolution, re-anchoring (incl. month-boundary regressions and round-trips), and preset matching

closes DASH-162

@linear-code

linear-code Bot commented Jul 10, 2026

Copy link
Copy Markdown

DASH-162

@cla-bot cla-bot Bot added the cla-signed label Jul 10, 2026
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment Jul 10, 2026 1:26pm

Request Review

Near month ends "this-month" also fell within the loose 24h tolerance of
"last-30-days", and findMatchingPreset returned the first match, so
pinning to UTC could drop a day from the range. The closest preset now
wins, the tolerance is shared between highlight and re-anchoring, and
setPinnedToUtc uses a functional URL update so it stays stable across
timeframe changes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35133c3b3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/features/dashboard/usage/usage-timezone-utils.ts
…nchoring

On the 30th of a 30-day month "this-month" and "last-30-days" produce
identical ranges, so the re-anchor match is a pure tie. When the user's
timezone is a calendar day ahead of UTC, guessing the rolling preset
rewrote the pinned view to a window missing the billing month. The
re-anchor path now matches calendar-anchored presets first; the popover
order and highlight behavior are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant