Skip to content

feat(importer): add Claude Code activity metrics#8

Open
jmelloy wants to merge 2 commits into
tobilg:mainfrom
jmelloy:claude-import-metrics
Open

feat(importer): add Claude Code activity metrics#8
jmelloy wants to merge 2 commits into
tobilg:mainfrom
jmelloy:claude-import-metrics

Conversation

@jmelloy

@jmelloy jmelloy commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Adds Claude Code activity metrics to the local JSONL importer.

  • Emit claude_code.lines_of_code.count from Edit, Write, and MultiEdit tool calls.
  • Emit claude_code.pull_request.count, claude_code.commit.count, claude_code.session.count, and claude_code.active_time.total.
  • Add focused tests for LOC parsing, session counting, PR deduplication, commit detection, active time, and helper behavior.

Impact

Claude Code imports expose repository-aware activity metrics that can be used for reporting and dashboards.

Stack

This branch is stacked after pr-repository-attribution; this PR targets main per request, so its diff includes the repository attribution commit until the first PR merges.

Validation

  • GOROOT=/opt/homebrew/Cellar/go/1.26.1/libexec go test ./internal/importer

Note: plain go test currently fails locally because go reports 1.26.1 while GOROOT is set to a mise 1.24.0 install.

@jmelloy jmelloy marked this pull request as ready for review June 12, 2026 20:17
@tobilg

tobilg commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Hey, thanks for the PR! I pushed some changes on main today, could you eventually rebase?

@jmelloy jmelloy force-pushed the claude-import-metrics branch from a89847e to cd3ec91 Compare June 16, 2026 03:06
@tobilg

tobilg commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Thanks for the work on this. The feature direction looks useful: bringing Claude Code historical imports closer to the activity metrics shown from live telemetry would make reporting and dashboards more valuable.

Before merging, I think a few correctness details should be tightened so the imported metrics do not mislead users:

  1. claude_code.pull_request.count currently emits at most one PR metric per session. collectSessionMeta keeps only the first structured pr-link, so a session that links or creates multiple PRs would be undercounted. It would be better to emit one metric per distinct PR link.

  2. claude_code.lines_of_code.count is currently based on counting all lines in each old_string and new_string. For Edit/MultiEdit, those strings can include unchanged context, so a one-line edit inside a larger replacement block can be recorded as many removed and many added lines. Either this should compute an actual diff, or the metric should be clearly labeled/documented as an approximate gross replacement size rather than lines changed.

  3. claude_code.commit.count currently checks whether a Bash command contains git commit. That can count failed commits and false positives, because it does not inspect the matching tool result/success. If this metric is shown as commits created, it should ideally be tied to a successful tool result or use stricter command detection.

  4. The new activity metrics are added to full import, but not to the Claude incremental watcher path. That may be acceptable if intentional, but the docs and metric availability table should make the import/watch difference explicit. Otherwise users may expect the same metrics from watch and import.

  5. The branch is currently behind current main, and the CI run is still in action_required state with no completed job signal. I would prefer a rebase on current main and a green CI run before merging.

Overall, I would support landing this after those points are addressed. The product value is solid, but these metrics will likely be used for reporting, so it is important that their semantics are either accurate or explicitly documented as reconstructed estimates.

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