Skip to content

privacy(feat): gate all third-party analytics behind explicit consent - #372

Merged
Ducksss merged 3 commits into
devfrom
claude/analytics-consent-gate
Jul 27, 2026
Merged

Ducksss merged 3 commits into
devfrom
claude/analytics-consent-gate

Conversation

@Ducksss

@Ducksss Ducksss commented Jul 27, 2026 •

Copy link
Copy Markdown
Owner

Closes the one item the PR audit deliberately left open. #352 made the site honour GPC/DNT, but that could not close the gap on its own: GA4 was mounted regardless, so an EU visitor had _ga cookies set before any interaction.

AnalyticsShell now renders nothing until consent is granted. On a first visit there is no GA4 script, no Vercel bundle, no PostHog beacon, and no stored identifier. State lives in src/lib/consent.ts under pc_consent; ConsentBanner collects the choice; /privacy documents the stack and can withdraw it.

Three things worth a reviewer's attention

A privacy signal is a decision, not a prompt. GPC (binding under CCPA) or DNT resolves to denied, and the banner never renders.

Withdrawal reloads — and this was a real bug. Unmounting AnalyticsShell does not unload a third party that is already running: gtag stays initialised on window and keeps collecting, and the injected <script> tags stay in the document. So setConsent forces a reload on granted → denied, and clears pc_distinct_id so opting out erases the identifier rather than freezing it. My first implementation had this wrong; the e2e spec caught it, not review.

No layout shift. The banner is fixed-positioned, so it never moves the landing page's LCP content.

How the visual baselines stayed intact

Specs that assert on analytics or capture snapshots grant consent up-front via tests/e2e/consent.ts, keeping the banner out of every capture. Only the two landing baselines changed, and only because /privacy was added to the footer — verified by cropping the pixel diff to the footer region rather than assuming. Linux baselines are being minted via the visual-baselines dispatch.

The axe suites deliberately run without consent, so the banner is held to the same a11y bar as the rest of the site.

Verification

lint clean · tsc clean · 341 int tests · e2e: consent 6/6, a11y 10/10, frontend 39/39, templates 60/60, templates-visual 62/62, components-visual 69/69, blog 5/5, geo 13/13.

Two things I checked rather than assumed:

  • The blog-index visual baselines fail identically on clean origin/dev with none of this code — stale darwin snapshots, pre-existing and out of scope here.
  • blog-visual-system.int.spec.ts flaked once under load; it drives synthetic page.setContent HTML and never loads the app, so it is unrelated. Passes on re-run.

Summary by CodeRabbit

  • New Features

    • Added an analytics consent banner with Accept, Decline, and Privacy options.
    • Analytics now load only after explicit consent.
    • Added a Privacy page with analytics disclosures and consent settings.
    • Added Privacy links to the footer and site sitemap.
  • Bug Fixes

    • Respect Global Privacy Control and Do Not Track signals.
    • Withdrawing consent stops analytics and clears related identifiers.
  • Documentation

    • Updated consent and privacy guidance for contributors.

Copilot AI review requested due to automatic review settings July 27, 2026 08:36
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/ducksss-projects?upgradeToPro=build-rate-limit

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Ducksss, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f651496d-3592-4166-8b52-7debc444b0e4

📥 Commits

Reviewing files that changed from the base of the PR and between 9c51c65 and 9e1570a.

⛔ Files ignored due to path filters (3)
  • tests/e2e/frontend.e2e.spec.ts-snapshots/landing-home-desktop-chromium-darwin.png is excluded by !**/*.png
  • tests/e2e/frontend.e2e.spec.ts-snapshots/landing-home-mobile-chromium-darwin.png is excluded by !**/*.png
  • tests/e2e/frontend.e2e.spec.ts-snapshots/landing-home-mobile-chromium-linux.png is excluded by !**/*.png
📒 Files selected for processing (20)
  • .env.example
  • content/docs/contributing.mdx
  • src/app/layout.tsx
  • src/app/privacy/page.tsx
  • src/app/sitemap.ts
  • src/components/site/AnalyticsShell.tsx
  • src/components/site/ConsentBanner.tsx
  • src/components/site/ConsentSettings.tsx
  • src/components/site/useConsent.ts
  • src/lib/analytics.ts
  • src/lib/consent.ts
  • src/lib/site.ts
  • tests/e2e/blog-visual.e2e.spec.ts
  • tests/e2e/blog.e2e.spec.ts
  • tests/e2e/consent.e2e.spec.ts
  • tests/e2e/consent.ts
  • tests/e2e/frontend.e2e.spec.ts
  • tests/e2e/templates-visual.e2e.spec.ts
  • tests/e2e/templates.e2e.spec.ts
  • tests/int/e2e-runner.int.spec.ts
📝 Walkthrough

Walkthrough

Adds an opt-in consent system for analytics, a consent banner and privacy page, consent-aware analytics mounting and dispatch, privacy navigation, documentation, and Playwright coverage for consent, withdrawal, privacy signals, and accessibility.

Changes

Analytics consent gate

Layer / File(s) Summary
Consent resolution and analytics gating
src/lib/consent.ts, src/lib/analytics.ts
Consent is persisted and synchronized across tabs, privacy signals force denial, withdrawal clears the distinct ID and reloads, and analytics dispatch requires granted consent.
Consent UI and layout integration
src/components/site/useConsent.ts, src/components/site/ConsentBanner.tsx, src/components/site/ConsentSettings.tsx, src/components/site/AnalyticsShell.tsx, src/app/layout.tsx
The application renders consent controls, hides analytics until consent is granted, and preserves stable pre-hydration output.
Privacy disclosure and navigation
src/app/privacy/page.tsx, src/app/sitemap.ts, src/lib/site.ts
Adds the privacy page, analytics processor and event disclosures, structured data, sitemap entry, footer link, and consent settings.
Consent documentation and end-to-end validation
.env.example, content/docs/contributing.mdx, tests/e2e/*, tests/int/e2e-runner.int.spec.ts
Documents the opt-in behavior and validates initial blocking, acceptance, denial, privacy signals, withdrawal, accessibility, and consent setup for existing suites.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Visitor
  participant ConsentBanner
  participant ConsentStorage
  participant AnalyticsShell
  Visitor->>ConsentBanner: Choose Accept or Decline
  ConsentBanner->>ConsentStorage: Persist consent state
  ConsentStorage-->>AnalyticsShell: Resolve consent
  AnalyticsShell->>AnalyticsShell: Mount analytics only when granted
Loading

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR has strong substance, but it does not follow the repository template and omits the required Summary, Registry Checklist, and Notes sections. Reformat the description to use the template headings and add a concise Summary, the checklist items, and a Notes section.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: consent-gating third-party analytics.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/analytics-consent-gate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/app/privacy/page.tsx`:
- Around line 11-36: Move all privacy-page copy and disclosure catalog
data—including the metadata description, headings, prose, processor entries, and
event entries—from the privacy page into a typed exported privacy-content object
in src/lib/site.ts. Update the privacy page to import and render that object,
preserving every contract string verbatim without introducing page-local site
content; keep privacyStructuredData and page composition in the page.

In `@src/lib/consent.ts`:
- Around line 50-54: Update resolveConsent so that when privacySignalOptOut() is
true, it clears the persisted pc_distinct_id before returning 'denied'. Preserve
the existing null behavior for non-browser environments and stored-consent
resolution for users without a privacy signal.
- Around line 85-87: Update the onStorage handler in consent.ts to detect a
cross-tab transition from granted to denied using the stored consent value, then
reload the current tab so initialized analytics scripts are removed. Preserve
the existing listener notification for consentStorageKey events and avoid
reloading for grants or unrelated storage changes.

In `@tests/e2e/consent.e2e.spec.ts`:
- Around line 96-108: Update the consent withdrawal test around the existing
localStorage seeding to also set a representative pc_distinct_id while consent
is granted, then after clicking “Turn analytics off” assert that
localStorage.getItem('pc_distinct_id') returns null alongside the existing
denied-consent assertion.

In `@tests/e2e/templates.e2e.spec.ts`:
- Around line 53-58: Restrict the grantConsent beforeEach hook to the
functional/gallery and visual template suites instead of applying it file-wide.
Update the test structure around the Templates accessibility (axe-core, WCAG 2.1
A/AA) suite so it runs without pc_consent granted and continues exercising the
undecided-state banner.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 75685ecd-981b-4f36-9ff0-58500ecfd356

📥 Commits

Reviewing files that changed from the base of the PR and between cb4acc6 and 9c51c65.

⛔ Files ignored due to path filters (2)
  • tests/e2e/frontend.e2e.spec.ts-snapshots/landing-home-desktop-chromium-darwin.png is excluded by !**/*.png
  • tests/e2e/frontend.e2e.spec.ts-snapshots/landing-home-mobile-chromium-darwin.png is excluded by !**/*.png
📒 Files selected for processing (20)
  • .env.example
  • content/docs/contributing.mdx
  • src/app/layout.tsx
  • src/app/privacy/page.tsx
  • src/app/sitemap.ts
  • src/components/site/AnalyticsShell.tsx
  • src/components/site/ConsentBanner.tsx
  • src/components/site/ConsentSettings.tsx
  • src/components/site/useConsent.ts
  • src/lib/analytics.ts
  • src/lib/consent.ts
  • src/lib/site.ts
  • tests/e2e/blog-visual.e2e.spec.ts
  • tests/e2e/blog.e2e.spec.ts
  • tests/e2e/consent.e2e.spec.ts
  • tests/e2e/consent.ts
  • tests/e2e/frontend.e2e.spec.ts
  • tests/e2e/templates-visual.e2e.spec.ts
  • tests/e2e/templates.e2e.spec.ts
  • tests/int/e2e-runner.int.spec.ts

Comment thread src/app/privacy/page.tsx
Comment on lines +11 to +36
const description =
'What Payload Components measures, which third parties receive it, and how to change or withdraw your choice at any time.'

export const metadata: Metadata = {
alternates: { canonical: '/privacy', ...feedMetadataAlternates },
title: 'Privacy',
description,
openGraph: {
description,
title: 'Privacy — Payload Components',
type: 'website',
url: '/privacy',
},
twitter: {
card: 'summary_large_image',
description,
title: 'Privacy — Payload Components',
},
}

const privacyStructuredData = graph(
breadcrumbNode([
{ name: 'Home', path: '/' },
{ name: 'Privacy', path: '/privacy' },
]),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Move privacy-page copy and disclosure catalog data into src/lib/site.ts.

This adds metadata, headings, prose, processor data, and event data directly in the page, contrary to the site-content contract. Export a typed privacy-content object from src/lib/site.ts and render it here without rewording the contract strings.

As per coding guidelines: “Keep all site copy and catalog data … in src/lib/site.ts.”

Also applies to: 41-75, 84-150

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/app/privacy/page.tsx` around lines 11 - 36, Move all privacy-page copy
and disclosure catalog data—including the metadata description, headings, prose,
processor entries, and event entries—from the privacy page into a typed exported
privacy-content object in src/lib/site.ts. Update the privacy page to import and
render that object, preserving every contract string verbatim without
introducing page-local site content; keep privacyStructuredData and page
composition in the page.

Source: Coding guidelines

Comment thread src/lib/consent.ts Resolved
Comment thread src/lib/consent.ts Resolved
Comment on lines +96 to +108
test('/privacy can withdraw consent after it was granted', async ({ page }) => {
// Seeded through the page rather than an init script: withdrawing forces a
// reload (see setConsent), and an init script would re-grant on the way back.
await page.goto(`${baseURL}/privacy`)
await page.evaluate(() => window.localStorage.setItem('pc_consent', 'granted'))
await page.reload()
await expect(page.getByText('Analytics is currently on.')).toBeVisible()

await page.getByRole('button', { name: 'Turn analytics off' }).click()

await expect(page.getByText('Analytics is currently off.')).toBeVisible()
expect(await page.evaluate(() => window.localStorage.getItem('pc_consent'))).toBe('denied')
await expect(page.locator(thirdPartyScripts)).toHaveCount(0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Assert identifier deletion during withdrawal.

The test can pass if withdrawal leaves a pre-existing pc_distinct_id behind. Seed one with the granted consent, then assert it is null after clicking “Turn analytics off.”

Proposed coverage
 await page.goto(`${baseURL}/privacy`)
-await page.evaluate(() => window.localStorage.setItem('pc_consent', 'granted'))
+await page.evaluate(() => {
+  window.localStorage.setItem('pc_consent', 'granted')
+  window.localStorage.setItem('pc_distinct_id', 'test-visitor')
+})
 await page.reload()
 ...
 expect(await page.evaluate(() => window.localStorage.getItem('pc_consent'))).toBe('denied')
+expect(await page.evaluate(() => window.localStorage.getItem('pc_distinct_id'))).toBeNull()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('/privacy can withdraw consent after it was granted', async ({ page }) => {
// Seeded through the page rather than an init script: withdrawing forces a
// reload (see setConsent), and an init script would re-grant on the way back.
await page.goto(`${baseURL}/privacy`)
await page.evaluate(() => window.localStorage.setItem('pc_consent', 'granted'))
await page.reload()
await expect(page.getByText('Analytics is currently on.')).toBeVisible()
await page.getByRole('button', { name: 'Turn analytics off' }).click()
await expect(page.getByText('Analytics is currently off.')).toBeVisible()
expect(await page.evaluate(() => window.localStorage.getItem('pc_consent'))).toBe('denied')
await expect(page.locator(thirdPartyScripts)).toHaveCount(0)
test('/privacy can withdraw consent after it was granted', async ({ page }) => {
// Seeded through the page rather than an init script: withdrawing forces a
// reload (see setConsent), and an init script would re-grant on the way back.
await page.goto(`${baseURL}/privacy`)
await page.evaluate(() => {
window.localStorage.setItem('pc_consent', 'granted')
window.localStorage.setItem('pc_distinct_id', 'test-visitor')
})
await page.reload()
await expect(page.getByText('Analytics is currently on.')).toBeVisible()
await page.getByRole('button', { name: 'Turn analytics off' }).click()
await expect(page.getByText('Analytics is currently off.')).toBeVisible()
expect(await page.evaluate(() => window.localStorage.getItem('pc_consent'))).toBe('denied')
expect(await page.evaluate(() => window.localStorage.getItem('pc_distinct_id'))).toBeNull()
await expect(page.locator(thirdPartyScripts)).toHaveCount(0)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/consent.e2e.spec.ts` around lines 96 - 108, Update the consent
withdrawal test around the existing localStorage seeding to also set a
representative pc_distinct_id while consent is granted, then after clicking
“Turn analytics off” assert that localStorage.getItem('pc_distinct_id') returns
null alongside the existing denied-consent assertion.

Comment on lines +53 to +58
/* Analytics consent granted for the whole file: these specs interact with the
page, and the undecided-state banner is fixed to the bottom of the viewport
where it could intercept clicks. The banner has its own spec, and the axe
suites deliberately run without consent so it is still held to the a11y bar. */
test.beforeEach(async ({ context }) => grantConsent(context))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate file =="
fd -a 'templates\.e2e\.spec\.ts$' . || true

echo "== file outline =="
AST_FILE="$(fd 'templates\.e2e\.spec\.ts$' . | head -n1 || true)"
if [ -n "${AST_FILE:-}" ]; then
  ast-grep outline "$AST_FILE" || true
  echo "== relevant file lines =="
  nl -ba "$AST_FILE" | sed -n '1,140p'
fi

echo "== search consent hook definitions/usages =="
rg -n "function grantConsent|const grantConsent|grantConsent\\(|axe-core|axe" .

Repository: Ducksss/payload-components

Length of output: 648


🏁 Script executed:

#!/bin/bash
set -euo pipefail

AST_FILE="$(fd 'templates\.e2e\.spec\.ts$' . | head -n1)"
echo "== file lines =="
awk '{printf "%5d  %s\n", NR, $0}' "$AST_FILE" | sed -n '1,140p'

echo "== search consent hook and axe annotations/usages =="
rg -n "function grantConsent|const grantConsent|grantConsent\\(|`@axe-core`|axe-core|axe|consent|banner" tests package.json -S || true

Repository: Ducksss/payload-components

Length of output: 12184


🏁 Script executed:

#!/bin/bash
set -euo pipefail

awk '{printf "%5d  %s\n", NR, $0}' tests/e2e/templates.e2e.spec.ts | sed -n '480,580p'

echo "== Playwright nested describe hook behavior =="
node - <<'JS'
const test = { _describeStack: [], describe: function(label, fn) {
  this._describeStack.push(label);
  fn();
  this._describeStack.pop();
}, beforeEach: function(fn) {
  console.log(`nested beforeEach registered in stack: ${this._describeStack.join(' > ') || '<root>'}`);
} };
(() => {
  test.describe('Gallery', () => { test.beforeEach(() => {}); test.describe('Accessibility', () => { test.beforeEach(() => {}); }); });
})();
console.log('All beforeEach are top-level callbacks registered by Playwright and run for every test in their enclosing describe.')
JS

Repository: Ducksss/payload-components

Length of output: 2112


Scope consent setup away from the axe tests.

test.beforeEach(... grantConsent(context)) is file-scoped, so the nested Templates accessibility (axe-core, WCAG 2.1 A/AA) suite still runs with pc_consent set to granted and the undecided-state banner is bypassed. Move the hook below the gallery/visual template suites and define an empty consent setup or only grant consent for the functional/templates groups, so axe coverage exercises the banner state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/templates.e2e.spec.ts` around lines 53 - 58, Restrict the
grantConsent beforeEach hook to the functional/gallery and visual template
suites instead of applying it file-wide. Update the test structure around the
Templates accessibility (axe-core, WCAG 2.1 A/AA) suite so it runs without
pc_consent granted and continues exercising the undecided-state banner.

@Ducksss
Ducksss force-pushed the claude/analytics-consent-gate branch from 1ef3b51 to ee53460 Compare July 27, 2026 08:48
Ducksss and others added 3 commits July 27, 2026 22:49
Closes the gap the PR audit left open: GA4, Vercel Analytics/Speed Insights and
PostHog all loaded on first paint, so an EU visitor had GA4 cookies set before
any interaction. Honouring GPC/DNT (shipped in #352) narrowed that but could not
close it, because GA4 was mounted regardless.

AnalyticsShell now renders nothing until consent is 'granted'. On a first visit
there is no GA4 script, no Vercel bundle, no PostHog beacon and no stored
identifier. State lives in src/lib/consent.ts under `pc_consent`; ConsentBanner
collects the choice and /privacy documents the stack and can withdraw it.

Three things worth calling out:

- A browser privacy signal is a decision, not a prompt. GPC (binding under the
  CCPA) or DNT resolves to 'denied' and the banner never renders.
- Withdrawal reloads. Unmounting AnalyticsShell does not unload a third party
  that is already running — gtag stays initialised on window and keeps
  collecting — so setConsent reloads on granted -> denied. It also clears
  pc_distinct_id, so opting out erases the identifier instead of freezing it.
  This was caught by the e2e spec, not by review.
- The banner is fixed-positioned, so it costs no layout shift on the landing
  page's LCP content.

Testing: specs that assert on analytics or capture visual baselines grant consent
up-front via tests/e2e/consent.ts, which keeps the banner out of every snapshot —
only the two landing baselines changed, and only because /privacy was added to
the footer. The axe suites deliberately run without consent, so the banner is
held to the same a11y bar as the rest of the site.

Verified: lint clean, tsc clean, 341 int tests, and e2e — consent 6/6, a11y
10/10, frontend 39/39, templates 60/60, templates-visual 62/62, components-visual
69/69, blog 5/5, geo 13/13. blog-index visual baselines fail identically on clean
origin/dev (stale darwin snapshots, unrelated to this change).

Co-Authored-By: Claude Opus 5 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…er tabs

Both found by CodeRabbit on #372 — the first substantive AI review this repo has
had on a dev-targeted PR since .coderabbit.yaml listed `dev` as a base branch.

resolveConsent() returned 'denied' for a GPC/DNT visitor without clearing a
pc_distinct_id that an earlier opt-in may have stored. It was never sent while
denied, but it survived to re-link the visitor to their previous identity if they
later opted back in. A signal is now treated exactly like an explicit
withdrawal.

subscribeToConsent() notified React on a cross-tab change but never reloaded.
That is the same defect the reload in setConsent exists to prevent, one tab over:
a tab that already mounted GA4 keeps gtag initialised on window and keeps
collecting, because unmounting AnalyticsShell cannot unload it. A withdrawal
elsewhere now tears this tab down too.

Both are covered by new specs that fail without the fix: a privacy signal
arriving after an opt-in must leave no identifier, and withdrawing in one tab
must strip the Google tag from a second tab that already had it.

Verified: lint clean, tsc clean, 341 int tests, consent e2e 8/8.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Ducksss
Ducksss force-pushed the claude/analytics-consent-gate branch from ee53460 to 9e1570a Compare July 27, 2026 15:49
@vercel

vercel Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
payload-components Ready Ready Preview, Comment Jul 27, 2026 3:57pm
payload-components-97bf Ready Ready Preview, Comment Jul 27, 2026 3:57pm

@Ducksss
Ducksss merged commit 4ab2971 into dev Jul 27, 2026
12 checks passed
Ducksss added a commit that referenced this pull request Jul 29, 2026
…e days

Triaged every bot review on the 60 PRs merged since 2026-07-24. Copilot was
quota-limited on all of them and Codex's one finding (#340 Linux baselines) was
handled by #342, so everything actionable is CodeRabbit's. Most of its findings
were already closed by #378/#380 or superseded by later work; two were false
positives. These five were still open and worth taking.

- frontend.e2e: pin the tablet wall fade (#399). The 2.75rem override IS that
  PR, and nothing asserted it — the existing fade check runs at 390px, outside
  the 640-1023px query, so deleting the rule stayed green, and the overrun
  ceiling is deliberately loose enough (60px) to swallow the 44px residue too.
  Asserted exactly, because matching the residue is the point.

- templates-a11y: accept the 3D identity as settled (#394). A reveal written
  with translate3d, or carrying a translateZ(0) compositor hint, serialises as
  matrix3d — the check saw only the 2D identity and would have failed the gate
  for a reveal sitting exactly where it belongs.

- painted-contrast: name the no-glyph-pixel skips (#394). unresolvedSelectors
  already exists so a skip cannot hide which node it dropped; this is the other
  way an unmeasurable node leaves the run, and it was a bare count.

- ComponentWall: fix the zoom comment (#396). It claimed every card shows true
  desktop proportions at every size. zoom pins the 1280px layout width, not the
  breakpoint — frontend.e2e's own comment says as much — and that claim is
  exactly what would mislead the next person curating frame heights.

- CONTRIBUTING: document the changed-vs-all snapshot trap (#375). A bare
  --update-snapshots skips baselines whose diff lands under tolerance, which is
  the same stale-baseline half-mint the section warns about, minus the missing
  file that would have revealed it. visual-baselines.yml explains this at
  length; the local instructions did not.

Skipped, with reasons: tokenising the wall fade heights and the mask-image
black stops (#399/#396/#370) — the token rule scans component utilities, not
globals.css, which defines tokens and carries raw lengths throughout, and a
mask's black is an alpha keyword rather than a colour; fading only
confirmed-overflow cards (#396) — the valve exists for content that has not
changed yet; moving privacy copy into site.ts (#372) — real per AGENTS.md, but
about/blog/brand-guide hold local copy too, so this belongs in one deliberate
pass; subset-aware blog visual validation (#375) — outputRoot defaults to the
repo, so a --slug render is incremental against committed assets and the
full-catalog gate is the correct final check.

Verified: lint, tsc, the three affected int specs, and both e2e specs green
(frontend 44 passed, templates-a11y 43 passed) in production mode.

Co-Authored-By: Claude Opus 5 <[email protected]>
Ducksss added a commit that referenced this pull request Jul 29, 2026
…e days (#411)

Triaged every bot review on the 60 PRs merged since 2026-07-24. Copilot was
quota-limited on all of them and Codex's one finding (#340 Linux baselines) was
handled by #342, so everything actionable is CodeRabbit's. Most of its findings
were already closed by #378/#380 or superseded by later work; two were false
positives. These five were still open and worth taking.

- frontend.e2e: pin the tablet wall fade (#399). The 2.75rem override IS that
  PR, and nothing asserted it — the existing fade check runs at 390px, outside
  the 640-1023px query, so deleting the rule stayed green, and the overrun
  ceiling is deliberately loose enough (60px) to swallow the 44px residue too.
  Asserted exactly, because matching the residue is the point.

- templates-a11y: accept the 3D identity as settled (#394). A reveal written
  with translate3d, or carrying a translateZ(0) compositor hint, serialises as
  matrix3d — the check saw only the 2D identity and would have failed the gate
  for a reveal sitting exactly where it belongs.

- painted-contrast: name the no-glyph-pixel skips (#394). unresolvedSelectors
  already exists so a skip cannot hide which node it dropped; this is the other
  way an unmeasurable node leaves the run, and it was a bare count.

- ComponentWall: fix the zoom comment (#396). It claimed every card shows true
  desktop proportions at every size. zoom pins the 1280px layout width, not the
  breakpoint — frontend.e2e's own comment says as much — and that claim is
  exactly what would mislead the next person curating frame heights.

- CONTRIBUTING: document the changed-vs-all snapshot trap (#375). A bare
  --update-snapshots skips baselines whose diff lands under tolerance, which is
  the same stale-baseline half-mint the section warns about, minus the missing
  file that would have revealed it. visual-baselines.yml explains this at
  length; the local instructions did not.

Skipped, with reasons: tokenising the wall fade heights and the mask-image
black stops (#399/#396/#370) — the token rule scans component utilities, not
globals.css, which defines tokens and carries raw lengths throughout, and a
mask's black is an alpha keyword rather than a colour; fading only
confirmed-overflow cards (#396) — the valve exists for content that has not
changed yet; moving privacy copy into site.ts (#372) — real per AGENTS.md, but
about/blog/brand-guide hold local copy too, so this belongs in one deliberate
pass; subset-aware blog visual validation (#375) — outputRoot defaults to the
repo, so a --slug render is incremental against committed assets and the
full-catalog gate is the correct final check.

Verified: lint, tsc, the three affected int specs, and both e2e specs green
(frontend 44 passed, templates-a11y 43 passed) in production mode.

Co-authored-by: Claude Opus 5 <[email protected]>
@Ducksss
Ducksss deleted the claude/analytics-consent-gate branch August 3, 2026 08:49

This branch was successfully deployed

2 active deployments
Preview – payload-components — 9e1570ae Deployed Jul 27, 2026 by vercel[bot]
Preview – payload-components-97bf — 9e1570ae Deployed Jul 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants