litellm/ui/litellm-dashboard/src/components/EntityUsageExport
Yassin Kortam bc5638b38e
Some checks are pending
GitHub Actions Security Analysis / zizmor (push) Waiting to run
fix(ui): stop per-model usage export from duplicating user spend across models (#30980)
The "day-by-day by user and model" usage export overcounted spend by
repeating each user-day total once per model. generateDailyWithModelsData
iterated day.breakdown.models crossed with the entity's own
api_key_breakdown and added the api key's full daily spend to every model,
leaving the per-model object (modelData) unused and never matching the api
key to the model. A user who called N models got N identical rows, so the
column summed to N times the real spend; one reported export totaled
$167,953 against a true $21,353 (7.87x).

Attribute each model only the spend of the keys that actually used it by
intersecting the entity's api keys with modelData.api_key_breakdown. This
mirrors the already-correct pattern in activity_metrics.tsx, so per-model
rows now sum back to the user-day total and models a user never called no
longer appear.

The existing tests passed only because their mocks omitted
models[*].api_key_breakdown and never asserted numeric values. The mocks
now match the real /user/daily/activity payload, and new tests assert that
per-model spend sums to the user-day total and that uncalled models are
omitted; both fail on the old code.

Resolves LIT-3866
2026-06-22 11:26:54 -07:00
..
EntityUsageExportModal.test.tsx Resolve Team ID and Team name in export 2026-01-13 14:42:28 -08:00
EntityUsageExportModal.tsx Resolve Team ID and Team name in export 2026-01-13 14:42:28 -08:00
ExportFormatSelector.test.tsx address greptile review feedback (greploop iteration 3) 2026-03-18 12:48:01 -07:00
ExportFormatSelector.tsx style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
ExportSummary.test.tsx style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
ExportSummary.tsx style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
ExportTypeSelector.test.tsx style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
ExportTypeSelector.tsx breakdown by team and keys 2026-01-28 13:30:27 -08:00
index.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
types.ts feat(ui): add user filtering to usage page (#22059) 2026-02-25 10:37:45 -08:00
UsageExportHeader.test.tsx [Test] UI: Add unit tests for 10 previously untested components 2026-03-18 12:18:42 -07:00
UsageExportHeader.tsx style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
utils.test.ts fix(ui): stop per-model usage export from duplicating user spend across models (#30980) 2026-06-22 11:26:54 -07:00
utils.ts fix(ui): stop per-model usage export from duplicating user spend across models (#30980) 2026-06-22 11:26:54 -07:00