Skip to content

feat(analytics): add OTEL analytics source with session-detail report#384

Merged
codemie-ai merged 3 commits into
mainfrom
feature/analytics-otel-source
Jun 30, 2026
Merged

feat(analytics): add OTEL analytics source with session-detail report#384
codemie-ai merged 3 commits into
mainfrom
feature/analytics-otel-source

Conversation

@vadimvlasenko

Copy link
Copy Markdown
Collaborator

Summary

Adds an analytics otel --file <path> source that maps a flattened native
Claude Code OTEL events file (otel-events.jsonl) into the existing analytics
pipeline, rendering the same HTML report (cost, tokens, tools, timeline, skills,
turns, project/branch) from OTEL data. The default local-session source is
unchanged.

Changes

  • AnalyticsSource seam (sources/{types,sessions-source,otel-source}.ts):
    the CLI is now agnostic to where data comes from; index.ts is split into a
    shared runAnalytics runner plus the otel subcommand.
  • otel-loader.ts: parse/filter OTEL events, authoritative cost index
    (native cost_usd), per-model rollup, timeline dispatches, synthesized
    MetricDeltas, and a transcript cwd/branch join. Each agent api_request is
    attributed to a single dispatch, so parallel subagents with overlapping
    windows do not double-count cost/tokens.
  • otel-source.ts: honors --session/--project/--agent/--branch so
    filtered runs return the right sessions and reports are never mislabeled.
  • usage-readers.ts: keeps the most complete row when Claude writes
    progressive JSONL records for a single streaming response.
  • hook.ts: on SessionStart re-entry, preserves accumulated
    startTime/activeDurationMs for a live session (compact); clear/exit
    start fresh instead of resurrecting a completed session.
  • report (app.js, template.html): prompt/title column, per-session JSON
    export, full-window timeline.
  • Test fixtures use anonymized user identifiers (no real emails/usernames).

Testing

  • Tests added/updated (otel-loader unit + otel-report integration;
    usage-readers progressive-row case)
  • Manual testing done (analytics otel --file <fixture> --report renders
    HTML + JSON; filter and dispatch attribution verified end to end)

Checklist

  • Code follows project standards
  • CI is green (CI=true npm run ci — 2106 unit + 211 integration passing)
  • No merge conflicts with main

Note: cost-enricher.test.ts "TTL-aware pricing against real transcripts"
reads machine-specific local transcripts and is it.skipped when CI is set
(pre-existing behavior, unrelated to this change).

vadimvlasenko and others added 3 commits June 23, 2026 14:37
Add `analytics otel --file <path>`: maps a flattened otel-events.jsonl
(native Claude Code telemetry) into the existing analytics pipeline so it
renders the same HTML report (cost, tokens, tools, timeline, skills,
turns, project/branch) from OTEL data.

- AnalyticsSource seam (sources/{types,sessions-source,otel-source}) so
  the CLI is agnostic to where the data comes from; the command is split
  into a shared runner plus the `otel` subcommand.
- otel-loader: parse/filter events, authoritative cost index, per-model
  rollup, timeline dispatches, synthesized deltas, transcript cwd/branch
  join. Each agent api_request is attributed to a single dispatch so
  parallel subagents with overlapping windows do not double-count.
- otel-source honors --session/--project/--agent/--branch so filtered
  runs return the right sessions and reports are never mislabeled.
- usage-readers: keep the most complete row when Claude writes
  progressive JSONL records for one streaming response.
- hook: on SessionStart re-entry, preserve accumulated
  startTime/activeDurationMs for a live session (compact); clear/exit
  start fresh instead of resurrecting a completed session.
- report: prompt/title column, per-session JSON export, full-window
  timeline.
- Test fixtures use anonymized user identifiers (no real emails).

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
…l-source

# Conflicts:
#	src/cli/commands/analytics/index.ts
#	src/cli/commands/analytics/report/client/app.js
…description

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
@BolotnyaBoss

Copy link
Copy Markdown
Contributor

The architecture seam is clean, the dispatch attribution logic works correctly for the core case, and the plan-vs-implementation is fully aligned.

@codemie-ai codemie-ai merged commit 95fb54a into main Jun 30, 2026
5 checks passed
@codemie-ai codemie-ai deleted the feature/analytics-otel-source branch June 30, 2026 14:11
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.

3 participants