Repository navigation
feat: send install funnel events to PostHog - #26
Merged
Merged
Conversation
The connect flow and login send mcp_install_started, mcp_install_logged_in and mcp_install_completed (plus mcp_install_login_failed with the error code) so we can see where installs stop. Events go straight to PostHog EU with the public project key, a 2s timeout and an anonymous per-machine ID; they never carry keys, tokens, paths or error messages. DO_NOT_TRACK=1 or SG_NO_TELEMETRY=1 turns them off; tests and binary smoke tests set it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Send only standard OAuth error codes as the login-failure reason; any other value becomes oauth_error, since it can echo broker or user text. - Send through node:https and destroy the socket on timeout, so a stalled connection or TLS handshake cannot keep the CLI alive. All events share one two-second budget per run instead of two seconds each. - Await every event, so logged_in is no longer lost when a later step calls process.exit (no supported agent, cancelled picker). - skills_installed now reflects the skills that actually installed, and failed_skill_count reports the failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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
Adds product analytics to the connect flow and
loginso we can see where installs stop. A saved PostHog funnel tracks the steps: MCP wizard install funnel.mcp_install_startedloginstarts (command, auth mode, scope, interactive)mcp_install_logged_inreused_saved_credential), plussg_org,sg_regionmcp_install_completedmcp_install_login_failedcancelled,timeout, or a standard OAuth code; anything else is sent asoauth_error)Implementation
src/sg/telemetry.ts: no new dependency. Anode:httpsPOST toeu.i.posthog.comwith the public, write-onlyphc_key. It never throws. On timeout the socket is destroyed, so a stalled connection or TLS handshake can't keep the CLI running. Events are personless ($process_person_profile: false).~/.config/add-sg-mcp/telemetry-id, not tied to the credential.fail(), Ctrl-C and some later steps (no supported agent, cancelled picker) callprocess.exit, which would drop a request still in flight. All events share one 2-second budget per run, so analytics adds at most 2 seconds in total.DO_NOT_TRACK=1orSG_NO_TELEMETRY=1.tests/run.mjsand the binary smoke-test job set it.Notes
--auth oauth(preview) has no sign-in step, so it never sends step 2. Those runs show as drop-offs at step 2.command = connect: a non-interactiveloginstops after step 2 by design and would otherwise count as a drop-off.mcp_install_startedevent from local verification is already in prod.Test plan
bun run build,bun run typecheck,bun run test(23/23 files)tests/sg-telemetry.test.ts: opt-out parsing, persisted ID, payload shape, opted-outtracksends nothing, OAuth reason allowlist, and a stalled endpoint is cut off with its socket closed (passes on Node and Bun; fails if the socket isn't destroyed)mcp_install_startedarrived in PostHog with the expected properties🤖 Generated with Claude Code