Skip to content

fix(docs): name the SDK on the aged-out reference notice - #20163

Draft
posthog[bot] wants to merge 1 commit into
masterfrom
posthog-self-driving/fixdocs-name-the-sdk-on-the-aged-out-82bbea
Draft

posthog[bot] wants to merge 1 commit into
masterfrom
posthog-self-driving/fixdocs-name-the-sdk-on-the-aged-out-82bbea

Conversation

@posthog

@posthog posthog Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Changes

Readers who ask for an SDK reference version that aged out of the build get a notice page. That page was written to name the SDK and version they asked for, and to link to the current reference for that SDK. It never did either: everybody got the generic copy, whose only link is "Browse all SDK docs".

Problem

  • A reader who asks for an old version is told nothing about their SDK, and is sent to the full library index to search for the page by hand. This happens every day, to a steady stream of readers, and to AI assistants that fetch these URLs.
  • version-unavailable.tsx read the SDK and version from window.location.pathname after mount.
  • The vercel.json rewrite is transparent, but Gatsby is not: when the served page's window.pagePath differs from the browser path, Gatsby's runtime replaces the address bar with the page path and keeps only the query string (production-app.js). Behind this rewrite that is always true, so the parse always failed.

Fix

  • Read the requested URL from the navigation timing entry (performance.getEntriesByType('navigation')[0].name). It records the URL the document was fetched with, and the history replacement does not change it.
  • The ?ref= override and the parser are unchanged.

Two approaches that do not work

Approach Why not
Pass the slug through the rewrite, ?ref=:slug A rewrite destination's query string is server-side only. It never reaches the browser, so the page cannot read it.
Redirect instead of rewrite Redirects run before the filesystem check, so the rule would also capture the versions that do have pages. Rewrites run after it, which is why only aged-out URLs reach this page.

Version picker (SdkReference.tsx): no change. It lists every sourced version on purpose, and Gatsby falls back to a full page load when a page fails to load, so a picker entry with no page reaches the rewrite and now gets the named notice.

Screenshots

The "after" column is production, opened with the ?ref= override that already renders this branch. The environment cannot build the site, so the branch itself is not pictured; the override feeds the same JSX the fix feeds.

Before After
Light, narrow before-light-640 after-light-640
Light, wide before-light-1440 after-light-1440
Dark, narrow before-dark-640 after-dark-640
Dark, wide before-dark-1440 after-dark-1440
How the root cause and the fix were verified

Headless Chromium, against production, on /docs/references/posthog-react-native-4.61.0:

  • location.pathname reads /docs/references/version-unavailable, which confirms the parse can never succeed. The page renders the generic copy.
  • performance.getEntriesByType('navigation')[0].name still reads https://posthog.com/docs/references/posthog-react-native-4.61.0.
  • The new resolver, run in that page, returns { sdk: 'posthog-react-native', version: '4.61.0' }. It also resolves a types subpath (/docs/references/posthog-js-1.203.1/types/Survey) and the ?ref= override.

pnpm format (Prettier 2, repo config) and node --test src/components/SdkReferences/utils.test.ts both pass.

Not tested: the dev server and the production build. This environment has no node_modules and cannot install them, so there is no local console check. The Vercel preview build covers both.

Checklist

  • I've read the docs and/or content style guides.
  • 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 — this environment cannot build or open the site; please check the preview
  • If I moved a page, I added a redirect in vercel.json — no page moved

Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code

The notice page read the requested SDK and version from window.location.pathname. Gatsby replaces that path with the page's own path on hydration, so the parse always failed and every reader got the generic copy.

Read the requested URL from the navigation timing entry instead, which keeps the URL the document was requested with.

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

Generated-By: PostHog Desktop
Task-Id: 9e9acf6c-191b-48ac-a5c8-4a5ece1807fc
@posthog

posthog Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

🦔 PostHog Review reviewed this pull request

Nothing worth raising this time, so here's a calming picture instead:

A panda relaxing and waving

@github-actions github-actions Bot added the website About the website (beyond just landing pages) label Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Deploy preview

Status Details Updated (UTC)
🟢 Ready View preview Sep 15, 2026 05:39AM

@github-actions

Copy link
Copy Markdown
Contributor

Bundle report

Total JS (gzip)

8.78 MiB (+0.1 KiB / +0.0%)

Eager graph (modules shipped in each entrypoint's initial chunks)

Entrypoint Eager size Budget Modules
app 18.51 MiB (no change) report-only 2062
Largest modules in the app closure
Module Size
./src/data/mcp-tools.json 1137.8 KiB
css ./node_modules/.pnpm/css-loader@5.2.7_webpack@5.101.3/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[8].oneOf[1].use[1]!./node_modules/.pnpm/postcss-loader@4.3.0_postcss@8.5.6_webpack@5.101.3/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[8].oneOf[1].use[2]!./src/styles/global.css 773.5 KiB
./src/components/Stickers/Stickers.tsx 696.4 KiB
./node_modules/.pnpm/@radix-ui+react-icons@1.3.2_react@18.3.1/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js 481.4 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/x-ray.mjs 480.8 KiB
./node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.js + 29 modules 395.1 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/im-the-driver.mjs 385.7 KiB
./src/hooks/useCustomers.tsx + 55 modules 370.0 KiB
./node_modules/.pnpm/@posthog+icons@0.36.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js 354.8 KiB
./node_modules/.pnpm/react-markdown@8.0.7_@types+react@16.14.66_react@18.3.1/node_modules/react-markdown/lib/react-markdown.js + 88 modules 351.4 KiB
./src/components/ProductComparisonTable/index.tsx + 126 modules 305.7 KiB
./node_modules/.pnpm/cloudinary-core@2.14.0_lodash@4.17.21/node_modules/cloudinary-core/cloudinary-core.js 281.9 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/doll-house.mjs 281.7 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/director.mjs 275.6 KiB
./src/components/SearchUI/index.tsx + 87 modules 273.7 KiB

Eager-graph budgets are report-only until a baseline is established. Sizes are gzip of public/**/*.js; eager size is webpack module source bytes for the modules actually shipped in the entrypoint's initial chunks (post-tree-shake).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

website About the website (beyond just landing pages)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants