mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
21 lines
531 B
TypeScript
21 lines
531 B
TypeScript
import { useEffect } from 'react'
|
|
import { usePostHog } from 'posthog-js/react'
|
|
import { useRouter } from 'tuono'
|
|
|
|
export default function PostHogPageView(): null {
|
|
const { pathname } = useRouter()
|
|
const posthog = usePostHog()
|
|
|
|
// Track pageviews
|
|
useEffect(() => {
|
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
if (pathname && posthog) {
|
|
const url = window.origin + pathname
|
|
|
|
posthog.capture('$pageview', { $current_url: url })
|
|
}
|
|
}, [pathname, posthog])
|
|
|
|
return null
|
|
}
|