Add PostHog analytics to the Vocs docs site#11
Open
probablyangg wants to merge 3 commits into
Open
Conversation
The Mintlify-era PostHog integration (dev-docs/docs.json) was dropped in the migration to Vocs, so the new site sent no analytics. Restore reporting into the same PostHog project so historical data stays continuous. - docs/lib/analytics.ts: standard PostHog browser snippet, injected via Vocs' documented `head` option (loads async, independent of the app bundle). capture_pageview: 'history_change' tracks SPA navigations; person_profiles: 'identified_only' keeps anonymous docs traffic profile-free. - vocs.config.ts: compose analyticsHead() with the existing SEO head(). - ADRs/DR006: document the decision (head snippet vs posthog-js, SPA pageviews, Mintlify continuity). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | 1b6c52f | Commit Preview URL Branch Preview URL |
Jun 18 2026, 02:48 PM |
PostHog was capturing pageviews + autocapture and setting cookies on load. That is product analytics, not strictly-necessary telemetry, so it needs prior opt-in consent under GDPR/ePrivacy. Gate it: - Init with opt_out_capturing_by_default + persistence:'memory' — no capture, no cookies until the visitor opts in. An inline bootstrap re-applies a stored "granted" choice at load for returning visitors. - ConsentBanner (mounted site-wide via the default Layout export) prompts for a choice when none is stored; Accept/Decline are equal-weight. - A "Cookie preferences" footer link re-opens the banner so consent can be withdrawn as easily as it was given. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Record the opt-in consent decision layered onto DR006's PostHog integration, and note in DR006 that its init config and "Layout slot unused" framing are superseded by the consent gate. Co-Authored-By: Claude Opus 4.8 (1M context) <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
The Mintlify-era PostHog integration (
dev-docs/docs.json→posthog.apiKey) was dropped in the migration to Vocs, so the new docs site sent no analytics. This restores reporting into the same PostHog project (samephc_…key + US host) so historical data stays continuous.What changed
docs/lib/analytics.ts(new) — the standard PostHog browser snippet, injected via Vocs' documentedheadconfig option ("Additional tags to include in the<head>"). Loads async and independent of the app bundle, so it keeps reporting even if React fails to hydrate — mirroring what Mintlify did implicitly.capture_pageview: 'history_change'— Vocs is a client-side-routed SPA; this fires$pageviewonpushState/popstateso in-app navigations are tracked (the default captures the initial load only).person_profiles: 'identified_only'— anonymous docs traffic shouldn't create a person profile per visitor.vocs.config.ts— composesanalyticsHead()with the existing SEOhead()into oneFragment(Vocs'headtakes a single value); removes the stale "wire PostHog later" TODO.ADRs/DR006_PostHog_Analytics.md(new) — documents the decision: theheadsnippet vsposthog-jsin aLayout(reliability vs hydration), SPA pageview handling, and the Mintlify-continuity constraint.Kept analytics in its own module rather than
structured-data.tsso that file stays single-purpose SEO (per DR001), and the analytics wiring is easy to find/remove.Verification
npm run docs:buildpasses (Node ≥ 22).us.i.posthog.comon the deployed site.🤖 Generated with Claude Code