Skip to content

feat: add Export Usage Data command (CSV / JSON) - #40

Open
long-910 wants to merge 2 commits into
mainfrom
claude/feat-export-usage-y9ahrw
Open

long-910 wants to merge 2 commits into
mainfrom
claude/feat-export-usage-y9ahrw

Conversation

@long-910

@long-910 long-910 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

New command Claude Status: Export Usage Data... exports the daily usage history — the same aggregation that powers the heatmap, covering claudeStatus.heatmap.days days — so users can feed it into expense reports or external analysis. Independent of #37/#38/#39; based directly on main.

UX

  1. Command palette → Claude Status: Export Usage Data...
  2. QuickPick: CSV (spreadsheet-friendly) or JSON (machine-readable with metadata)
  3. Save dialog (default ~/claude-usage-YYYY-MM-DD.csv|json) → confirmation toast with the written path

If there is no recorded activity yet, a warning toast is shown instead of writing an empty file.

Formats

  • CSV: date,cost_usd,messages,tokens, one row per day including zero-activity days, cost at 4 decimal places.
  • JSON: { exportedAt, days, totalCostUsd, daily: [{ date, costUsd, messages, tokens }] }.

Implementation

  • Serializers isolated in src/data/exportUsage.ts as pure functions (no vscode import) so they run under plain mocha.
  • Command registered in extension.ts; writes via vscode.workspace.fs.writeFile so remote workspaces work.
  • Reuses dataManager.getHeatmapData() (5-minute in-memory cache) — no extra JSONL scan.
  • l10n: command title in package.nls* (EN/JA/ZH) and runtime strings in l10n/bundle.l10n.*.
  • Docs: docs/SETTINGS.md commands section + format spec, README usage tables (EN/JA/ZH), CHANGELOG.

Tests

New exportUsage suite: CSV header/rows/decimal formatting/empty input, JSON round-trip shape, totalCostUsd sum. npm run lint ✅, npm run compile ✅, unit suites ✅ via mocha — the one failure locally is the pre-existing time-of-day flake in the heatmap suite that #37 fixes (unrelated to this change). @vscode/test-electron cannot download VS Code in this sandbox; please rely on CI for the extension-host suites.

🤖 Generated with Claude Code

https://claude.ai/code/session_012ZLCLQeudf1LQBnBSyyr4f


Generated by Claude Code

claude added 2 commits July 7, 2026 02:29
New command "Claude Status: Export Usage Data..." exports the daily
usage history — the same aggregation that powers the heatmap, covering
claudeStatus.heatmap.days days — for expense reports and external
analysis.

- QuickPick format selection (CSV or JSON) + save dialog
- CSV: date,cost_usd,messages,tokens with one row per day
- JSON: exportedAt, days, totalCostUsd, and per-day records
- Serializers in src/data/exportUsage.ts (pure, unit-tested)
- l10n: EN/JA/ZH command title and runtime strings
- Docs: SETTINGS.md commands section, README usage tables (EN/JA/ZH),
  CHANGELOG

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ZLCLQeudf1LQBnBSyyr4f
The ubuntu job failed on the pre-existing heatmap test flake that only
reproduces between 02:00 and 03:00 local time; the fix ships in #37.
Empty commit to re-run CI outside that window.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ZLCLQeudf1LQBnBSyyr4f
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.

2 participants