jan/web/app/posthog.js
2024-11-26 20:17:50 +07:00

15 lines
475 B
JavaScript

'use client'
import posthog from 'posthog-js'
import { PostHogProvider } from 'posthog-js/react'
if (typeof window !== 'undefined') {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
person_profiles: 'identified_only', // or 'always' to create profiles for anonymous users as well
})
}
export function CSPostHogProvider({ children }) {
return <PostHogProvider client={posthog}>{children}</PostHogProvider>
}