fix(analytics): exclude non-CodeMie-owned native sessions from output#410
Open
BolotnyaBoss wants to merge 3 commits into
Open
fix(analytics): exclude non-CodeMie-owned native sessions from output#410BolotnyaBoss wants to merge 3 commits into
BolotnyaBoss wants to merge 3 commits into
Conversation
added 2 commits
July 7, 2026 16:56
Native sessions tagged native-external by hasOwnershipMarker were only labeled, not filtered, so untracked claude/codex usage still counted toward totals. SessionsSource now drops them by default; --include-external restores the prior unfiltered behavior for comparison. EPMCDME-13367
Spec, plan, technical analysis, and task run artifacts from the brainstorming/planning workflow behind the analytics exclusion fix. EPMCDME-13367
codemie-ai
approved these changes
Jul 7, 2026
…rnal (EPMCDME-13367) Two bugs caused CodeMie-managed sessions to lose their ownership marker and appear as native-external in analytics: 1. Sidecar overwrite on resume: appendTranscriptMarker keyed the sidecar by the CodeMie session ID, so resuming with a new Claude session overwrote the prior transcript's entry in the ownership index. Fixed by keying the sidecar by the Claude session ID (transcript basename without .jsonl) — each Claude session now gets its own non-overwriting marker. Write is idempotent; skips if already exists. 2. Empty transcript_path at SessionStart: the transcript file does not exist when the SessionStart hook fires, so the marker was never written for the initial session. Fixed by calling appendTranscriptMarker on the first UserPromptSubmit/Stop event that carries transcript_path (deferred write, idempotent). Also adds a fallback for sessions started via the native claude CLI (no CODEMIE_SESSION_ID env var): writes a minimal ownership sidecar from the SessionStart event and exits cleanly instead of throwing. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
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
Native sessions from bare
claude/codexlogs that lack CodeMie ownership evidence were only labelednative-external, not excluded — so untracked usage still counted toward analytics totals.SessionsSourcenow filters them out by default; a new--include-externalflag restores the prior unfiltered view for comparison.Changes
sessions-source.ts: drop native sessions taggednative-externalunlessincludeExternalis set.index.ts/types.ts/sources/types.ts: add--include-externalCLI flag threaded throughAnalyticsOptions→SourceLoadOptions.Testing
sessions-source.test.ts, 5 new cases)codemie analytics --last 7dwith/without--include-external; confirmed exclusion behavior against real native session logs)Checklist
npm run ci)mainEPMCDME-13367