Repository navigation
Analytics: let Google Analytics hits through the CSP (#166) - #171
Merged
Merged
Conversation
A `*.` wildcard needs a subdomain, so `https://*.analytics.google.com` never matched the bare `analytics.google.com` that gtag posts page_view hits to; with Google signals on, hits also go to www.google.com and stats.g.doubleclick.net. All were blocked by connect-src. One GA_HOSTS list now feeds connect-src and img-src (Google's CSP guide for GA4 with signals). The country-specific ga-audiences pixel stays blocked. An e2e test checks the header carries the new hosts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #166. Part of #74.
What
vite.config.ts: oneGA_HOSTSlist feeds bothconnect-srcandimg-src. It adds:https://analytics.google.com: a*.wildcard needs a subdomain, so*.analytics.google.comnever matched the bare host gtag postspage_viewto.https://www.google.comandhttps://*.g.doubleclick.net: where hits go with Google signals on (Google's CSP guide for GA4 with signals).img-srcnow uses the same wildcards asconnect-src(it listed onlywww.google-analytics.com/www.googletagmanager.com).ga-audiencespixel (www.google.com.au…) stays blocked, as the issue suggests.e2e/pages.spec.ts: a new test checks that the CSP header'sconnect-srcandimg-srccarry the new hosts.AGENTS.md: the allowed third parties line lists the GA hosts and points toGA_HOSTS.Checks
pnpm lint,pnpm check,pnpm build,pnpm test:e2e(38 passed).After deploy (acceptance, not checkable here)
🤖 Generated with Claude Code