Skip to content

Analytics: say whether tokens per day count every model call or only runs - #316

Merged
nambok merged 1 commit into
mainfrom
cut-model-spend
Nov 5, 2026
Merged

nambok merged 1 commit into
mainfrom
cut-model-spend

Conversation

@nambok

@nambok nambok commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

The analytics page's tokens-per-day chart says what it counts. With the platform change that comes with it (CoderHelm/coderhelm-platform, "Cut model spend"), the analytics API reports the per-call usage meter's daily totals: every model call, including PR reviews and work on runs started on earlier days, instead of the sum of the run records (one day read as $78 from run records against $168 metered).

Changes

  • src/app/analytics/page.tsx: the chart is titled "Tokens per day, every model call" when the API's cost_basis is metered, and "Tokens per day, runs only" otherwise (one repository picked, or an older server).
  • src/lib/api.ts: AnalyticsSummary carries run_cost_usd, cost_basis and cost_by_feature; each day carries run_cost_usd and run_tokens next to the metered cost_usd and tokens. The cost per run and per merged PR are documented as coming from the run records.
  • e2e/analytics.spec.ts: the fixture is metered and the test checks the chart's title.

The page still measures in tokens, not dollars (#91).

Verification

  • npm run lint, npm run typecheck, npm run check:openapi, npm run build: pass.
  • e2e/analytics.spec.ts against the static build: 14 passed.

…runs

The analytics API now puts the per-call meter's daily totals on the page
(every model call: runs, including work on runs started earlier, reviews,
follow-ups, chat) instead of what the run records add up to. The chart's
title says which one it shows, and the API types carry the metered cost,
the run records' cost and what the metered cost was for.
@nambok
nambok merged commit 7d2e215 into main Nov 5, 2026
10 checks passed
@nambok
nambok deleted the cut-model-spend branch November 5, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant