Mirrors the proven pattern from gendersloty: rewrites /ingest/* to the PostHog host so requests go through the same origin (no CORS, no ad-blocker issues). Uses PostHogProvider and usePostHog from posthog-js/react official React integration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
19 lines
547 B
TypeScript
19 lines
547 B
TypeScript
'use client'
|
|
|
|
import posthog from 'posthog-js'
|
|
import { PostHogProvider as PHProvider } from 'posthog-js/react'
|
|
import { useEffect } from 'react'
|
|
|
|
export default function PostHogProvider({ children }: { children: React.ReactNode }) {
|
|
useEffect(() => {
|
|
posthog.init('phc_BHgg9S7CQqVShe7EMCdi86PxA49qcNaTsR9Nn5EGxRCT', {
|
|
api_host: '/ingest',
|
|
ui_host: 'https://analytics.hyggecraftery.com',
|
|
capture_pageview: false,
|
|
persistence: 'memory',
|
|
})
|
|
}, [])
|
|
|
|
return <PHProvider client={posthog}>{children}</PHProvider>
|
|
}
|