Skip to content

fix(web): honor Do Not Track and Global Privacy Control in site analytics - #1605

Merged
scttbnsn merged 2 commits into
dev/v1.8from
fix/v1.8-web-dnt-gpc
Nov 17, 2026
Merged

scttbnsn merged 2 commits into
dev/v1.8from
fix/v1.8-web-dnt-gpc

Conversation

@scttbnsn

Copy link
Copy Markdown
Contributor

getdrydock.com was capturing analytics for visitors with Do Not Track or Global Privacy Control turned on. In posthog-js 1.449.2, is_capturing() returns true whenever cookieless_mode is "always", before any consent check, so respect_dnt never took effect. Our client had no check of its own. Flagged by ops (X96).

The site now checks for itself. navigator.doNotTrack === "1", the legacy msDoNotTrack / window.doNotTrack, or navigator.globalPrivacyControl === true means:

  • PostHog doesn't load at all.
  • Every capture is re-checked when it's sent and when the queue flushes after load, so a signal that shows up late clears the queue.
  • before_send returns null for every event as a second line of defense.

It's safe on the server, where there's no navigator or window. Pageviews, CTA events and $pageleave all go through the same client, and there's no beacon or proxy path around it. Tests cover each signal, neither, the late signal, the before_send drop and the no-window case.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 87ad0c5 and a14c43e.

Files ignored due to path filters: 1

  • CHANGELOG.md is excluded by !CHANGELOG.md
Files selected for processing: 3

  • apps/web/scripts/analytics-client.test.mjs
  • apps/web/src/lib/analytics-client.ts
  • apps/web/src/lib/analytics.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttbnsn
scttbnsn merged commit ab92939 into dev/v1.8 Nov 17, 2026
32 checks passed
@scttbnsn
scttbnsn deleted the fix/v1.8-web-dnt-gpc branch November 17, 2026 22:33
scttbnsn added a commit that referenced this pull request Nov 18, 2026
…tics (#1607)

fix(web): honor Do Not Track and Global Privacy Control in site analytics (#1605)
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.

1 participant