Repository navigation
feat: migrate analytics from Mixpanel to PostHog - #9
Merged
Merged
Conversation
- Replace mixpanel-browser with posthog-js behind the existing consent flow (opted out by default; no PostHog requests before consent). - Rely on native $pageview/$pageleave (history_change for ClientRouter) and autocapture; drop redundant page_viewed/page_exited/page_hidden/page_visible. - Add traffic_source super property and pointer_type on click events. - Pass PUBLIC_POSTHOG_KEY/HOST repo variables to the Pages build step. 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
Replaces Mixpanel with PostHog, keeping the existing consent banner.
$geoip_country_code) at ingestion — no code.$referrer/utm_*/$initial_*, plus atraffic_sourcesuper property (utm_source → referrer host →direct).cta_clicked,contact_intent,outbound_link_clicked,language_switched, now withpointer_type(touch/mouse/pen).Changes
src/lib/analytics.ts:posthog-jswithopt_out_capturing_by_default, localStorage persistence, session recording/surveys/flags disabled (zero PostHog requests before consent). Public API unchanged.BaseLayout.astro: removedpage_viewed,page_exited,page_hidden,page_visiblein favor of native$pageview(history_change, works with ClientRouter) and$pageleave.deploy.yml: passesPUBLIC_POSTHOG_KEY/PUBLIC_POSTHOG_HOSTrepo variables to the build step.mixpanel-browser+ types; typed env vars insrc/env.d.ts.Notes
PUBLIC_MIXPANEL_TOKENis agithub-pagesenvironment variable, which thebuildjob can't read. That variable can be deleted after merge.PUBLIC_POSTHOG_KEYandPUBLIC_POSTHOG_HOSTare already set.Test plan
yarn lint,yarn typecheck$pageview+consent_granted; CTA tap sendscta_clicked+$autocapture; ES→EN navigation sends a single new$pageview$geoip_country_code,traffic_source,pointer_type🤖 Generated with Claude Code