Fix PostHog init race condition — remove __loaded guard

posthog.capture() queues events automatically before init completes,
so checking __loaded blocked the first pageview from being sent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tim Leikauf
2026-07-01 21:04:57 +02:00
parent 0101447d84
commit f487189a19
2 changed files with 8 additions and 16 deletions

View File

@@ -1,13 +1,2 @@
import posthog from 'posthog-js'
export function initPostHog() {
if (typeof window !== 'undefined' && !posthog.__loaded) {
posthog.init('phc_BHgg9S7CQqVShe7EMCdi86PxA49qcNaTsR9Nn5EGxRCT', {
api_host: 'https://analytics.hyggecraftery.com',
capture_pageview: false,
persistence: 'localStorage',
})
}
}
export { posthog }