Remove the cookie consent banner (feature-flagged off) - #84
Merged
Conversation
Gate the cookie-consent banner, its footer 'Cookie settings' link, and the geo region-detection middleware behind a new NEXT_PUBLIC_COOKIE_CONSENT flag. The flag is OFF by default, so: - no consent banner is shown to visitors, - the footer 'Cookie settings' link is hidden, - the region middleware no-ops (no pl-consent-region cookie is set), - Google Analytics loads directly whenever NEXT_PUBLIC_GA_ID is set. All the existing consent components are kept intact, so re-enabling is a one-line change (see companion PR) or simply setting NEXT_PUBLIC_COOKIE_CONSENT=on.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What this does
Removes the analytics cookie consent banner from the site by gating the whole consent flow behind a new
NEXT_PUBLIC_COOKIE_CONSENTfeature flag that is off by default.With the flag off (the new default):
pl-consent-regioncookie is set.NEXT_PUBLIC_GA_IDis set.Why a flag instead of a delete
All the existing consent components (
CookieConsent,CookieSettingsLink, the region middleware logic) are kept intact. That makes bringing the banner back trivial — see the companion PR — or just setNEXT_PUBLIC_COOKIE_CONSENT=onin the environment.With the banner off, analytics loads for everyone, including EU/EEA/UK visitors, without prior consent. That's the intended "no banner" behaviour, but if the site serves those regions you'll likely want to flip the flag back on (companion PR) before shipping to production.
Files changed
src/lib/cookie-consent.ts— new flag helper (default off)src/app/layout.tsx— banner vs. direct GA based on the flagsrc/components/SiteFooter.tsx— hide "Cookie settings" link when offsrc/middleware.ts— skip region detection when off.env.example/README.md— documentNEXT_PUBLIC_COOKIE_CONSENT