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.
This commit is contained in:
parent
f3db11ef3a
commit
86f8eb3e6d
|
|
@ -22,11 +22,17 @@
|
|||
loaded = false
|
||||
}
|
||||
s.onload = function () {
|
||||
// Consent withdrawn while array.js was downloading: skip init, allow a retry on re-grant.
|
||||
if (!granted()) {
|
||||
loaded = false
|
||||
return
|
||||
}
|
||||
window.posthog.init(KEY, {
|
||||
api_host: 'https://us.i.posthog.com',
|
||||
ui_host: 'https://us.posthog.com',
|
||||
cross_subdomain_cookie: true,
|
||||
person_profiles: 'identified_only',
|
||||
capture_pageview: 'history_change',
|
||||
})
|
||||
}
|
||||
document.head.appendChild(s)
|
||||
|
|
|
|||
Loading…
Reference in New Issue