Repository navigation
Conversation
4aa281c to
9049932
Compare
|
Two time-window issues to fix before merging this:
I ran the existing 22 tests and typecheck at Please add the boundary coverage and clarify the metric windows. Chart and navigation QA is still pending; this is not a merge approval. |
df47b27 to
414d50a
Compare
Spend is estimated over any window, across billing cycles, by sharing each cycle's billed total over the usage events of the window. The 24h range is a true rolling 24 hours: the window starts exactly 24 hours ago, so events of the oldest partial hour count. It is returned hour by hour, from the hour of the cutoff to the current hour, with per-hour request counts. The stats, analytics and user APIs accept days=cycle. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The Overview, Insights and user pages share one selector: 24h, 3d, 7d, 14d, 30d or Cycle (default). The range lives in the URL (?range=) and the main menu forwards it to Overview and Insights. The members table headers no longer repeat the range, the selector already shows it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A vertical line marks each billing cycle change on the daily spend trend and on the daily spend by user bars, labelled previous cycle / new cycle. A label is left out when it would not fit inside the plot area, so it never runs over the axis near the edge of the chart. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The charts show exactly the selected range. The 24h range is drawn hour by hour (UTC), one bar or point per hour like the other ranges, with an axis tick every 3 hours on fixed clock hours (0h, 3h, 6h...), an average over 24 hours and $/req computed from the events of each hour. The charts are titled Hourly Spend there, and cycle markers are skipped. The trend no longer states how many days or hours it shows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…range On the 24h range the spend covers the last 24 hours, but requests, active members and the $/request ratios came from daily data starting at yesterday's midnight, so the figures did not describe the same window. They now come from the usage events of the last 24 hours, on the Overview and on the user page. Lines are only kept per day, so the Lines card is left out of the 24h range. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Daily Spend by Top Users now sits under Team Spend Trend and Top Spenders under Model Cost Comparison, so the two charts over time share a column instead of being read diagonally. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The row now opens the user page, keeping the selected range. The arrow lightens on row hover instead of on its own hover. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
414d50a to
c50b93e
Compare
|
Thanks, both points are addressed. I reorganised the branch into one change per commit (force-pushed, so older commit links are stale).
Unrelated to the review, one extra commit: the whole members row is now clickable (c50b93e). I haven't rerun the production build. |
Changes
1. Compute spend over any window and add a cycle range
Spend is billed per cycle but was shown next to windows of 1 to 30 days, so a 30-day view at the start of a cycle only covered the current cycle. Each cycle's billed total is now shared over the usage events that fall inside the window, per user and per day, across as many cycles as the window touches. The ranking, the team total, the daily charts and the model costs come from the same estimate, and the user stats gain the user's spend over the window.
getFullDashboard,getUserStatsand the analytics queries also accept acyclerange that starts at the billing cycle start, where the estimate equals the billed total./api/stats,/api/analyticsand/api/users/:emailtakedays=cycle.2. Shared time range selector with a cycle range
One selector (24h, 3d, 7d, 14d, 30d, Cycle) in the overview blue style, at the right of the toolbar or header, drives the overview, the insights page and the user page, which gets a picker for the first time. Cycle is the default.
?range=7) and is read by the server pages: the first render already uses it, nothing is stored in the browser, and links are shareable. The main menu forwards it, so Overview and Insights keep the range you picked.3. Mark billing cycle changes on the spend charts
A thin vertical line, behind the data, marks where a billing cycle starts inside the displayed range, with "previous cycle" on its left and "new cycle" on its right. It shows on the daily spend trend (overview and user page) and on the stacked daily spend by user chart. The last two provisional days of the trend now fade out instead of sitting in an orange block.
4. Zoom the spend charts on the selected range
On 24h and 3d the charts still showed a week, with the older days dimmed on the side. They now cover exactly the selected range. The 24h range charts the last 24 hours: one point per hour on the trend and one bar every 2 hours on the stacked chart (hours are UTC). Its spend figures cover those same 24 hours. The user page does the same, with
$/reqcomputed from the events of each hour, while its daily table stays per day.Screenshots
Overview, 30 days: selector on the right, members count next to the search, cycle change marker on the daily spend.

Top spenders and daily spend by user, 30 days: same marker between two bars.

Overview, 24 hours: one point per hour (UTC), KPIs over the last 24 hours.

User page, 30 days: selector in the header, spend over the range, $/req line, marker on the daily spend.

Insights, 14 days: shared selector, Model Rankings on the same window.

Checks
npm run typecheck,npm test(22 tests) andnpm run lintpass.🤖 Generated with Claude Code