feat(code): anonymous PostHog usage analytics for CLI runs - #56
Merged
Conversation
Send one fire-and-forget cli_run event per invocation: CLI version, OS/arch, tracker type, run mode, task count, and feature flags only — never task content, code, repo names, or credentials. - New src/lib/analytics.ts: bare-fetch PostHog capture, per-project anonymous ID in .devintern-code/telemetry.json, allowlisted prop scrubbing, bounded flush on exit - Opt out via DEVINTERN_TELEMETRY_DISABLED=1 (shell or .env) or analytics.enabled: false in .devintern-code/settings.json - POSTHOG_API_KEY/POSTHOG_HOST baked at build time; missing key permanently disables analytics (source/dev builds are no-op) - One-time disclosure notice on the first instrumented run - Docs: new Anonymous Usage Analytics section in configuration.md
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
Tracks anonymous usage of the
devinternCLI via PostHog (same vendor as pm-desktop) to understand popularity and feature adoption. Branch is based cleanly onmain.cli_run): CLI version, OS/arch, CI flag, tracker type, run mode (tasks/query/estimate), task count, and boolean feature flags (--create-pr,--auto-review,--estimate, sandbox provider). Sent fire-and-forget at run start; never blocks or fails the CLI.analytics.ts): task content, code, repo names, paths, and credentials are never sent..devintern-code/telemetry.json; no accounts, emails, or IPs tied to profiles.DEVINTERN_TELEMETRY_DISABLED=1(shell or.devintern-code/.env) oranalytics.enabled: falsein.devintern-code/settings.json. A one-time console notice discloses collection on the first instrumented interactive run.POSTHOG_API_KEY/POSTHOG_HOSTbaked into the bundle viabuild.tsdefines; missing key permanently disables analytics, so source/dev builds and CI test runs are no-ops.docs/code/configuration.md.Follow-ups
POSTHOG_API_KEYsecret to the npm publish pipeline so released builds instrumentTest plan
tests/analytics.test.ts(16 cases): env opt-out parsing, settings opt-out + malformed settings resilience, prop scrubbing, stable anonymous ID persistence, first-run detection, sender-failure safetybun run lint,bun run typecheckgreenbun run build.tssucceeds; host string verified baked intodist/index.js