Skip to content

feat(usage): add month-to-date range - #9108

Closed
andersryanc wants to merge 1 commit into
pingdotgg:mainfrom
andersryanc:feat/usage-month-to-date
Closed

feat(usage): add month-to-date range#9108
andersryanc wants to merge 1 commit into
pingdotgg:mainfrom
andersryanc:feat/usage-month-to-date

Conversation

@andersryanc

@andersryanc andersryanc commented Sep 1, 2026

Copy link
Copy Markdown

What Changed

Added an MTD (month to date) option to the Usage page on web, desktop, and mobile.

The new range covers the first day of the current month through today using the user’s local time zone. Refreshing the page also recalculates the range when the day or month changes.

Why

The existing 30-day range is a rolling window, so it can include usage from the previous month. This makes it harder for API-billed users to estimate their current monthly spend.

MTD provides a calendar-aligned view of usage and estimated API costs for the current month.

UI Changes

Before

browser-screenshot-localhost-mtj73986

After

Usage page with MTD selected

Verification

  • Added coverage for month-to-date boundaries in the user’s local time zone
  • Existing Usage page tests pass
  • Shared, web, and mobile typechecks pass
  • Targeted lint and formatting checks pass

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Low Risk
Scoped UI and date-window helpers for usage display; no auth, billing, or data-pipeline changes beyond existing usage queries.

Overview
Adds an MTD period to Usage on web and mobile so totals and charts use the first day of the current calendar month through today in the viewer’s local time zone, instead of only rolling day windows.

Shared makeMonthToDateWindow builds that daily-resolution window (reusing makeWindow for “today” and timezone, then setting sinceDay to YYYY-MM-01). Period selectors now use a value of number | "mtd" with makeWindowForPeriod, including on refresh when the calendar day rolls over. Web period toggles/selects resolve options by string value so MTD is not coerced with Number(). User docs and a timezone-focused unit test cover the new range.

Reviewed by Cursor Bugbot for commit 2f15c83. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add month-to-date range option to usage screens

  • Adds makeMonthToDateWindow(now?) in usageFormat.ts which builds a daily-resolution window from the first day of the current month to today in the viewer's time zone
  • Updates the mobile and web usage screens to include an MTD option in the period selector, refactoring state from { days, window } to { period, window } where period is a union of numbers and 'mtd'
  • Introduces makeWindowForPeriod helper on both platforms that delegates to makeMonthToDateWindow() for MTD and preserves hourly resolution for 24h and daily resolution for other numeric ranges
  • Updates tests and usage.md to cover the new option
  • Behavioral Change: WINDOW_OPTIONS entries now use value instead of days; any code referencing the old days field on these options will need updating

Macroscope summarized 2f15c83.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 1, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR adds a new month-to-date usage and estimated-cost view across web and mobile, backed by shared runtime date-window logic. Existing defaults remain unchanged, but the cross-surface production behavior and limited UI-level coverage merit human review.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge

Copy link
Copy Markdown
Member

Closing as part of the open-PR backlog sweep (wave 2).

Reason: Month-to-date range is subsumed by saphid usage custom-range stack #9014
Related: #9014

Reopen if this is still wanted and you’re willing to rebase onto current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants