Skip to content

Add PostHog for logged-out visitors outside the EEA/UK - #2602

Merged
alexleventer merged 2 commits into
mainfrom
docs-posthog
Oct 27, 2026
Merged

alexleventer merged 2 commits into
mainfrom
docs-posthog

Conversation

@alexleventer

Copy link
Copy Markdown
Contributor

Part of superfly/docs-tracking#304. Replaces #2540, which was closed to wait for the ui-ex CORS change. That change has now shipped in superfly/ui-ex#6104 and superfly/ui-ex#6126.

This adds PostHog to docs.fly.io. GA4 from #2540 is left out. There is no consent banner on docs:

Visitor docs.fly.io
Outside EEA/UK, logged out PostHog + Plausible
EEA/UK, logged out Plausible only
Logged in Plausible only

What fly-analytics.js does:

  • Fetches https://fly.io/api/consent-scope with credentials. ui-ex allows exactly https://docs.fly.io. PostHog loads only when the answer is "not EEA/UK, logged out". Fetch failures, Mintlify previews and mint dev load nothing.
  • Loads the vendored PostHog bundle from fly.io/static/javascripts/posthog.js. It uses the same project key and posthog.fly.io host as fly.io.
  • Uses capture_pageview: "history_change" because Mintlify navigates client-side. Internal fly.io referrers are rewritten to $direct, as on landing and ui-ex.
  • docs.json gets a Legal footer linking the Privacy Policy.

#security approved #2540, which also included GA4, so this is a subset of what was approved.

Known gap: a visitor outside the EEA/UK who rejects through fly.io's Cookie preferences link is still tracked on docs. That choice is stored per origin on fly.io. Fixing it needs a shared .fly.io consent cookie.

Test after merge

Previews run on *.mintlify.site, which gets no CORS grant, so the script loads nothing there by design. On production:

  • Logged out, from outside the EEA/UK: requests to posthog.fly.io, and a $pageview on each client-side navigation
  • Logged in: no PostHog requests
  • Through an EEA/UK edge: no PostHog requests

🤖 Generated with Claude Code

Restores the PostHog half of #2540, now that ui-ex #6104 and #6126 let
docs.fly.io read /api/consent-scope with credentials. GA4 is left out.

fly-analytics.js asks fly.io whether the visitor is logged in and whether
they came through an EEA/UK edge, and loads PostHog only for logged-out
visitors outside the EEA/UK. Anything else, including errors and preview
hosts, loads nothing. docs.json gets a Legal footer linking the Privacy
Policy.

Refs superfly/docs-tracking#304

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mintlify

mintlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
fly-io 🟢 Ready View Preview Oct 27, 2026, 2:24 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@mintlify

mintlify Bot commented Oct 27, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
fly-io 🟡 Building – Oct 27, 2026, 2:19 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

…_decide

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexleventer
alexleventer merged commit 9de475b into main Oct 27, 2026
1 check passed
@alexleventer
alexleventer deleted the docs-posthog branch October 27, 2026 02:26

This branch was successfully deployed

1 active deployment
staging — f49bd13f Deployed Oct 27, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant