Stop posthog-js downloading surveys.js on every page - #1136
Merged
Merged
Conversation
The site runs no surveys and the project's remote config already says `surveys: false`, yet every page fetched the 33.5KB surveys bundle. posthog-js loads the extension once the remote value has arrived, whatever it is (`if (!isUndefined(remoteSurveys) || advanced_enable_surveys)`), then does nothing with it. Only the client `disable_surveys` flag is checked before that load, so the project setting alone can never prevent it. Verified in a real browser with PostHog's actual remote config served locally and every /ingest request intercepted: prod as it is fetches surveys.js once per page; with this flag, zero. web-vitals.js still loads. POSTHOG_INIT_OPTIONS is pinned by `toEqual`, so the spec states the new key, plus a named case explaining why dropping it silently restores the fetch.
blove
enabled auto-merge (squash)
September 23, 2026 03:51
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
This branch was successfully deployed
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.
Turns off PostHog surveys on the website. The site runs none, but every page was still downloading the 33.5KB
surveys.jsbundle.Why the project setting wasn't enough
The project's remote config already says
surveys: false.posthog-js(1.372.6) loads the surveys extension as soon as that remote value has arrived, whatever it is:It then does nothing with it. The client-side
disable_surveysflag is checked before that line (in bothloadIfEnabled()and the remote-config handler), so it's the only switch that prevents the download. Only the website initializes PostHog; cockpit doesn't.Change
disable_surveys: trueinPOSTHOG_INIT_OPTIONS, with a comment explaining the quirk. That object is pinned withtoEqual, so the spec states the new key, plus a named case — same pattern as the existingcapture_pageviewone — saying why removing it would silently bring the fetch back.Verified
In a real browser, with PostHog's actual remote config served locally and every
/ingestrequest intercepted (nothing sent to PostHog):surveys.jsrequestsweb-vitals.jsdisable_surveysnx test website,nx lint website,nx build website🤖 Generated with Claude Code