Repository navigation
feat(upload): push session usage metrics at launch; logs upload only via codev upload --logs - #373
Merged
Merged
Conversation
…via codev upload --logs Every launch of codev, codev run and CoDev Desktop (plus a fresh sign-in and each desktop sandbox as it comes up) now pushes per-session usage statistics to the analysis backend's upload-session-stats function instead of uploading session logs: provider-reported tokens and cost, prompts, tool calls, lines of code, and hourly buckets per model. Only sessions whose stats changed are sent. CODEV_DISABLE_METRICS=1 turns the automatic push off. `codev upload` sends the same metrics on demand; `codev upload --logs` is the original log upload and the only path that uploads logs. The diagnostic trail moves from --logs to --diagnostics. The desktop "Upload Session Logs" menu item, the launch/sign-in log uploads, `codev debug upload` and CODEV_DISABLE_AUTO_UPLOAD are removed; the sign-in toast now tracks the metrics push. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The analysis web app currently derives every metric by parsing uploaded markdown transcripts: tokens are
chars ÷ 4, cost is absent, durations are mostly null, and re-uploads double-count. The client already records the real numbers, so this PR sends them directly. The markdown upload itself is unchanged.Usage metrics push (new)
@codev/uploadbuilds one record per top-level session, with subagent sessions added into their parent. Sources are the local store and, on desktop, each ready sandbox over the v1 API. Each record holds provider-reported tokens (input, output, reasoning, cache read/write) and cost, user prompts, tool calls (ok/error), accepted/rejected lines of code, files changed, active time, and hourly UTC buckets per model/provider. No message text is sent.POST {supabase}/functions/v1/upload-session-statsas{v: 1, client, sessions}, in batches of 200. A local sent-hash cache (~/.local/share/codev/stats-sent.json) keeps unchanged sessions from being resent.codev/codev runlaunch, via a detachedcodev debug stats/configuresign-instats-*.ndjsonlogs under the agent's data dir. It shares nothing with the hub's~/.codev-hubfiles.CODEV_DISABLE_METRICS=1turns off the automatic push.codev uploadcodev uploadruns the metrics push interactively. It signs in first if needed, ignoresCODEV_DISABLE_METRICS, and shares the lock with the launch push.codev upload --logsis the original log upload.--forcere-sends unchanged sessions in either mode.--diagnostics(previously--logs) prints the last run's trail. With--logs, it shows the last log upload instead.Log upload is now manual only. Removed:
codev debug uploadCODEV_DISABLE_AUTO_UPLOADA codebase scan confirms
codev upload --logsis the only remaining path that uploads logs. codev-hub still uploads codev-code logs on its own schedule; that's out of scope here.Behavior changes
codev upload --logsnow starts a log upload instead of printing diagnostics.codev uploadwithout flags no longer uploads logs.Follow-ups
upload-session-statsedge function, the tables and views, and moving the reports to the new data. The payload contract isSessionStatsinpackages/codev-upload/src/stats.ts.codev-landing-pagestill describe automatic upload,CODEV_DISABLE_AUTO_UPLOADand--logsas the diagnostics flag.DIVERGENCES rows are updated for the CLI wiring, desktop wiring, TUI dependency, desktop menu, gateway sign-in toast, TUI toast and the
uploadregistration. The CHANGELOG has a new "Usage reporting" section.Test plan
bun typecheckincodev-upload,opencode,tui,desktopandappbun testincodev-upload(57, including new stats-builder, push and daemon tests) anddesktop(194)bun run test:unitinapp(823)debug upload→debug stats; newuploadflags)CODEV_DISABLE_METRICS=1 codev debug statsexits 0 and logs the skip;codev upload --diagnosticsandcodev upload --logs --diagnosticsprint the right trails🤖 Generated with Claude Code