Repository navigation
feat(proxy): expanded fields and new usage events (OTLP analytics pipeline) - #609
Merged
Merged
Conversation
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 5, 2026
vld-m
reviewed
Oct 6, 2026
Replace the mixed if/switch dispatch with one if-chain and one handler per hook event, each returning its own ForwardDecision directly. Drop the shared fallback sink, collapse the raw/parsed object duplication by extending BaseClaudeCodeHookEvent, rename the orchestrator collectors, and split client-version caching from resolution. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
Add docs/ARCHITECTURE-OTLP-PLUGIN.md: the agent-agnostic OtlpAgentAdapter contract, the evaluate()/ForwardDecision dispatch pattern, how to add a new hook event or a new adapter, and the current otlp-spool completeness-gating/draining behavior (with planned extensions clearly flagged as not-yet-implemented). Index it from AGENTS.md's Agent Plugins table and add a top-level OTel (OTLP) Ingestion section pointing new contributors at it. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
dzhalai
force-pushed
the
EPMCDME-15301_stage-1-1
branch
from
October 7, 2026 07:31
e9d0083 to
93512cf
Compare
Analytics forwarding hooks no longer block Claude Code. UserPromptSubmit stays synchronous so its SSO-gate block decision reaches Claude Code before the prompt proceeds.
…rwarding mapHookRecords overwrote the record's own timestamp and git_branch with the spool-write time and the daemon's cwd branch, so every request in a hook pass collapsed to one moment and carried the wrong branch. Prefer the event's own values and fall back only when they are missing, empty or unparseable. Generated with AI
Move git_branch, repo_remote, story_id and story_source resolution from the proxy-daemon forwarder into an abstract OtlpAgentAdapter that runs at hook time. The daemon env is frozen at spawn, so env-dependent fields such as SDLC_ANALYTICS_STORY_ID were read from the wrong process. - add OtlpAgentAdapter<TInput, TBlockOutput> with a fixed processOtlpEvent flow and a generic ForwardDecision - inject forwardOtlpEventToSpool via OtlpAdapterDeps - move story-resolver to agents/core and add resolveStoryFor - make the forwarder pass the four fields through from the record - migrate ClaudeCodeOtlpPlugin to the base class - update tests and OTLP architecture docs Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
the adapter The abstract OtlpAgentAdapter now produces the complete event at hook time: type, truncation, prompt_body, session_id, cwd, schema_version, event_id, timestamp, plus identity, project name and CLI version resolved for the hook cwd from the stored SSO credentials. Events are sent awaited and in order. The forwarder only unwraps the spool envelope, POSTs it as is, advances the cursor and retries on auth failure; session end is detected from the event type. - rename OtlpHookSpoolData.raw to hookEvent and drop its timestamp - move identity.ts to agents/core/identity-resolver.ts, add hook-credentials.ts - remove forward-context.ts and the daemon-side CLI version lookup - add abstract resolveEventType, rename resolveAgentCommonFields to resolveAgentFields - update OTLP and proxy architecture docs
…tics contract request_id is now the API request id (top-level requestId, empty when the transcript has none) and message_id carries message.id. Requests are grouped by requestId, else message.id, plus model, through a single usageRequestKey helper. This lets the backend pair direct Claude Code requests with their OTel api_request records instead of counting them twice. Generated with AI
Derive the summary fields the backend reads only from the summary once one exists, instead of sending null, omitting them or sending the wrong shape: - lines_added/lines_removed from applied edit diffs (null until measured) - commands in call order with repeats; primary_command is the first - turns from real user prompts - compactions, compaction_count and compaction_pre_tokens from compact_boundary lines (replaces the PreCompact hook counter) - client_versions, git_branch and title (latest ai-title) - branch_counts count user lines only; branch_dominant ties go to the later branch Generated with AI
…-code-otlp Fills agent.subagent.usage's worktree from the triggering hook's cwd, threads agent_type through agent.usage.request end to end, tracks a Skill tool_use as a scope_kind='skill' context (cleared on the next genuine user turn), counts MultiEdit/NotebookEdit toward files_edited/files_changed, and rejects an empty or path-traversing session_id before it ever reaches a filesystem path. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
…g thinking_tokens
codemie-ai
approved these changes
Oct 13, 2026
3 of 4 tasks
3 of 4 tasks
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
Extends the
claude-code-otlpanalytics pipeline with common fields on everyagent.*event, incremental persisted transcript parsing, and three new usage events, plus story/identity resolution. Additive only — no changes to existing event content, no server-side changes.Changes
schema_version,event_id,codemie_cli_version,platform,client_version,entrypoint) stamped on every event viaforwarder.ts+ newOtlpAgentAdapter.prepareAnalyticsFields().agent.usage.request,agent.subagent.usage,agent.session.summaryevents, derived by incremental transcript re-parsing onStop/SubagentStop/PreCompact/SessionEnd, backed by persisted per-session parse state (src/agents/plugins/claude-code-otlp/transcript/*).jwt→git→codemie_cli→os) and story/ticket resolution (explicit→marker→branch→mention), new modules underotlp-spool/.docs/ARCHITECTURE-OTLP-PLUGIN.md; full unit test coverage for all new modules (this pipeline previously had none).Impact
agent.*events keep their content, only gain the common fields.developer_name/identity_source, never SSO/billing/attribution headers.Checklist