You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cc-economics: monthly totals and the summary keep only the last per-project ccusage row #4761
rtk cc-economics --monthly and the default rtk cc-economics summary report only the last ccusage row for a month when ccusage emits more than one row per month. ccusage 18 does this when per-project grouping is on ("groupByProject": true in its config file). The rows carry no project field in JSON, and merge_monthly in src/analytics/cc_economics.rs calls set_ccusage once per row on the same map entry, so each row overwrites the previous one.
Measured with ccusage 18.0.11 on real Claude Code logs, config {"commands":{"monthly":{"groupByProject":true}}}: ccusage returns 27 rows for 3 months.
month
sum of ccusage rows
rtk cc-economics --monthly
2026-08
$713.21
$27.58
2026-09
$7,237.07
$104.18
2026-10
$5,310.88
$26.33
The summary view builds its totals from the same merge_monthly, so its spend figure and the derived cost-per-token are understated by the same amount. Daily is not affected: ccusage 18 emits one row per day there.
#4409 fixes the same overwrite for weekly rows with aggregate_weekly_periods in src/analytics/ccusage.rs. Summing duplicate monthly rows the same way would close this. The test would feed two rows for the same month and assert the summed cost and token counts.
merge_monthly in src/analytics/cc_economics.rs overwrites instead of sums duplicate per-project ccusage rows for a month, understating monthly and summary totals by up to ~75%.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
Activity
rtk-wshm-sync-bot commentedon Oct 23, 2026
🔍 Automated Triage
bughighSummary
merge_monthly in src/analytics/cc_economics.rs overwrites instead of sums duplicate per-project ccusage rows for a month, understating monthly and summary totals by up to ~75%.
📁 Relevant files
src/analytics/cc_economics.rssrc/analytics/ccusage.rsSuggested Actions
Triaged automatically by wshm · This is an automated analysis, not a human review.
refactor(analytics): let the ccusage row aggregation name its granula…
chore(upstream): merge 341 commits from rtk-ai/rtk develop (2 Novembe…
chore(upstream): record rtk-ai/rtk develop 22812af as merged so the n…