'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>
}
