Add PostHog analytics integration - #2
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
Add posthog-node as a production dependency and a new src/posthog.ts singleton client (flushAt 1, flushInterval 0, exception autocapture) for CLI-safe event flushing. Instrument src/cli.ts to capture lint run completions, snapshot dumps, rule explanations, threshold failures, and unhandled errors. Ignore .env to keep the API key out of the repo. Generated-By: PostHog Code Task-Id: 61523356-59ce-46bc-bf5c-23388a84ecb6
Author
CI statusThis repository has no
Note: |
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
This PR adds PostHog analytics to mcplint using the
posthog-nodeSDK (installed via npm). The setup wizard instrumented the CLI to capture events at every meaningful exit point.src/posthog.ts— new PostHog singleton client (Node SDK,flushAt: 1,flushInterval: 0, exception autocapture) for CLI-safe flushingsrc/cli.ts— imports the client and captures events for successful lint runs, snapshot dumps, rule explanations, threshold failures, and unhandled errorspackage.json/package-lock.json— addsposthog-node@^5.45.2.gitignore— ignores.envso the API key is never committedCaptured events:
lint_run_completed,snapshot_dumped,rule_explained,lint_threshold_failed,lint_run_errored.Insights and dashboards created
How to verify
lint_run_completedevent arrive within a minute.Environment variables (action needed before PostHog works)
mcplint is a Node CLI distributed via npm (run with
npx mcplint). There is no server deployment and no committed runtime config file read in production — the code readsprocess.env.POSTHOG_API_KEY/POSTHOG_HOSTdirectly, and.envis both gitignored and excluded from the npmfilesbundle, so it would never reach end users anyway. "Production" for a CLI is each user's own shell, so these variables must be set in the environment where the CLI runs.POSTHOG_API_KEYphc_nWALq8MXGHFzBUQ9JxTVQoY4VEYjZd3SXC5ZduKQMPtXPOSTHOG_HOSThttps://us.i.posthog.comSet them wherever you run mcplint — e.g. in your shell profile (
~/.bashrc/~/.zshrc) or your CI runner's secret store — and ensure they are exported into the process environment before invokingnpx mcplint.When unset, PostHog initializes with an empty key and silently no-ops — the linter still runs normally, it just does not emit analytics.
Created with PostHog Code