Commit Graph

3 Commits

Author SHA1 Message Date
Erosika 86f8eb3e6d fix(docs): loader re-checks consent before init and captures SPA pageviews
If consent is withdrawn while array.js downloads, sync() runs before window.posthog exists and the opt-out is skipped. onload now re-checks granted() and resets loaded so a later re-grant retries.

Mintlify swaps pages without a reload, so capture_pageview: 'history_change' records navigation past the landing page.
2026-08-27 10:53:10 -04:00
Erosika b5d1a1ae54 fix(docs): loader survives a failed fetch and honors withdrawal
Review findings on #1071. The cookie match now requires the exact
CookieConsent name boundary. A failed array.js request resets the
loaded flag so later consent events retry. And consent events now run
a full sync: withdrawal opts an already running instance out, and a
re-grant opts it back in — same behavior as the landing site's gate.
2026-08-26 10:25:26 -04:00
Erosika 0b9ae00170 feat(docs): PostHog loads only with a granting consent answer
DEV-2465 open question 5, option d. Mintlify's built-in integration
loaded PostHog unconditionally on all 249 docs pages — a visitor who
declined on the homepage was tracked one click later in the docs. The
integration key comes out of docs.json; docs/posthog-consent.js loads
PostHog directly instead, only when the CookieConsent cookie grants
Statistics (or holds Cookiebot's -1 marker), and listens for the
consent events so a grant on the docs banner itself loads it too.

Trade recorded on the ticket: this bypasses the ph.mintlify.com proxy,
so ad blockers reduce docs PostHog volume. Verify after deploy that
Mintlify's page CSP allows us-assets.i.posthog.com; if it blocks,
fall back to option c.
2026-08-25 17:01:47 -04:00