Skip to content

feat: auto-select US or EU based on cloud region#16132

Open
vmaineng wants to merge 1 commit intoPostHog:masterfrom
vmaineng:feat/docs-auto-select-cloud-tab-15894
Open

feat: auto-select US or EU based on cloud region#16132
vmaineng wants to merge 1 commit intoPostHog:masterfrom
vmaineng:feat/docs-auto-select-cloud-tab-15894

Conversation

@vmaineng
Copy link
Copy Markdown

@vmaineng vmaineng commented Apr 2, 2026

Closes #15894

Changes

Auto-selects the US/EU code snippet tabs based on the user's cloud region, so users no longer have to manually switch tabs when following docs.

After digging into the codebase, PostHog already has feature flags (direct-to-eu-cloud / direct-to-us-cloud) that determine a user's cloud region. This PR wires those existing flags into the tab selection logic in two places:

  • src/components/CodeBlock/index.tsx — when direct-to-eu-cloud is enabled, the EU tab is now auto-selected in addition to the existing region string replacement that was already happening

  • src/components/Tab/index.tsx — added useCloud() hook so generic US/EU tabs also auto-select based on cloud region, with the correct priority chain:

    1. URL ?tab= param (highest priority, preserves shareable links)
    2. Cloud region from feature flag
    3. Default to first tab (US)
    Screenshot 2026-04-01 at 5 05 31 PM

Testing

Tested locally by temporarily setting the direct-to-eu-cloud condition to true in CodeBlock and confirming the EU tab auto-selects on pages with file=US / file=EU code blocks (e.g. /docs/advanced/proxy/nextjs).

  • [X ] I've read the docs and/or content style guides.
  • [ X] Words are spelled using American English
  • Use relative URLs for internal links
  • I've checked the pages added or changed in the Vercel preview build
  • If I moved a page, I added a redirect in vercel.json

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.

Docs tab auto select (US/EU)

1 participant