Skip to content

Add Claude edge telemetry extraction and dashboard surfacing.#1

Open
shuningc wants to merge 1 commit into
mainfrom
claude
Open

Add Claude edge telemetry extraction and dashboard surfacing.#1
shuningc wants to merge 1 commit into
mainfrom
claude

Conversation

@shuningc

@shuningc shuningc commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the documented Claude JSONL edge telemetry gaps by extracting session metadata, extended usage fields, and derived productivity signals from local logs — without API keys or network calls.

Token Meter already surfaces token counts, cost, tool calls, and context pressure from ~/.claude/projects/*/*.jsonl. Several high-value fields were present in the raw logs but not aggregated. This PR adds a structured edge_telemetry block to Claude session state and surfaces the most actionable metrics in the dashboard.

Scope: Claude Code CLI / Claude Desktop JSONL only. No Anthropic API integration. Codex and Cursor are out of scope for this PR.


Motivation

docs/edge-telemetry.md catalogs what Token Meter already collects and what was still missing. The gaps fell into three buckets:

  1. Session context on user records — gitBranch, entrypoint (cli vs vscode), CLI version
  2. Extended usage  service_tier, speed, ephemeral cache tiers (5m / 1h), server-side tool use (web_search, web_fetch)
  3. Derived signals — completion rate from stop_reason, tokens per turn/tool, files edited, repeat queries

These are all available locally at the edge. This PR implements extraction and display so developers can reason about session quality and efficiency without cloud analytics.


What changed

Backend — state.edge_telemetry (Claude sessions only)

New claude_edge_telemetry() aggregates:

Section | Fields -- | -- session | git_branch, entrypoint, version, branches_seen usage | service_tiers, speeds, cache_ephemeral_5m, cache_ephemeral_1h, web_search_requests, web_fetch_requests stop_reasons | counts, total, end_turn, tool_use, max_tokens, completion_rate derived | completion_rate, tokens_per_turn, tokens_per_tool_call, human_turns, files_edited, repeat_queries, repeat_rate edited_files | Unique paths from Edit / Write tool calls

Backward compatibility

  • edge_telemetry is additive — existing state fields unchanged
  • Non-Claude providers unaffected (edge_telemetry absent)
  • No new dependencies or config required
  • history.jsonl is optional; repeat-query metrics degrade gracefully if missing

Test plan

  •  python3 -m unittest tests.test_meter -v — 101 passed
  •  Live session: curl http://127.0.0.1:8722/state returns edge_telemetry for active Claude session
  •  Open dashboard → select Claude session → verify session meta line (branch / entrypoint / version)
  •  Verify Executions subline shows human turns, tok/turn, tok/tool
  •  Verify Cost/task shows completion rate when end_turn present
  •  Confirm Codex session has no edge_telemetry (no regression)

Related

  • Spec: docs/edge-telemetry.md
  • Follow-up: Cursor equivalent (cursor-telemetry branch) — agent transcript JSONL + ai-code-tracking.db

Parse additional JSONL fields (session context, usage extras, stop reasons) and derived session metrics into edge_telemetry, with UI and tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
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