Repository navigation
fix: use posthog-js directly in the Gatsby example - #520
Merged
Merged
Conversation
gatsby-plugin-posthog is deprecated. Initialize posthog-js in gatsby-browser.ts onClientEntry with capture_pageview: "history_change", and import posthog in the page instead of using window.posthog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 5115f2a3-23ac-46d3-9f8e-d9dbae3ab94d
Explain that defaults dated 2025-05-24 or later already enable history_change pageviews, and add migration steps from gatsby-plugin-posthog, including removing manual onRouteUpdate pageviews to prevent duplicates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 5115f2a3-23ac-46d3-9f8e-d9dbae3ab94d
sarahxsanders
marked this pull request as ready for review
November 13, 2026 14:09
edwinyjlim
approved these changes
Nov 13, 2026
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.
Why
gatsby-plugin-posthogis deprecated and gets no more releases, so the Gatsby example (and the skills that use it) must not recommend it.Changes
gatsby-plugin-posthogand addposthog-js.gatsby-browser.ts(onClientEntry) withcapture_pageview: "history_change", so the SDK captures pageviews on Gatsby route changes. No manual$pageviewis necessary.posthogfromposthog-jsin the page instead ofwindow.posthog, and remove thewindow.posthogtype file.Checked with
pnpm typecheckandpnpm build(the token is inlined into the client bundle).Created with PostHog from a Slack thread
🤖 Generated with Claude Code