feat: capture anonymous homepage page_view analytics#522
Merged
Conversation
The marketing homepage now fires an anonymous PostHog page_view event mirroring the served docs pages: a cookieless daily-rotating visitor hash as the distinctId, no person profile, and the EU host.
|
|
|
🚅 Deployed to the docs.page-pr-522 environment in docs.page
|
|
Bugbot is not enabled for this team, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
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.
Requested by Elliot Hesp · Slack thread
Summary
Before: The marketing homepage (
/) recorded no analytics. Only served docs pages fired PostHogdocs:page_viewevents, so we had no visibility into homepage traffic.After: Loading the homepage fires an anonymous
homepage:page_viewPostHog event, using the identical anonymity model as the docs pages.How: The homepage is served by the same Pages Router
getServerSidePropscatch-all inapp/src/pages/[[...path]].tsx; the empty-path (kind: "home") branch previously returned early without any capture. It now calls the sharedgetPostHogClient()?.capture(...)with the same cookieless daily-rotatingvisitorId(ip, userAgent, ...)distinctId,$process_person_profile: false,$raw_user_agent, and the EU host /disableGeoipconfig used bydocs:page_view. No new dependencies, no client-side JS, no cookies, no unhashed IP or PII. Event disabled automatically whenPOSTHOG_KEYis unset (helper returns null).Scope
app/(hosted site, MCP, Ask AI)packages/cli/packages/mdx-bundler/docs/(product documentation)Type of change
Test plan
bunx @biomejs/biome checkpasses on the changed filebunx tsc --noEmitintroduces no new type errors (pre-existing image-asset import errors are unrelated and present onmain)bun dev, CLI command, or other relevant command)docs/(if user-facing)Notes for reviewers
Reuses the existing
getPostHogClient,readVisitorHeaders,visitorId, andincomingHttpHeadersToWebHeadershelpers already imported in the file — no new imports or dependencies. The capture mirrors thedocs:page_viewsite exactly for anonymity (cookieless daily-rotating visitor hash, no person profile, EU host).Generated by Claude Code