20 lines
446 B
TypeScript
20 lines
446 B
TypeScript
'use client';
|
|
|
|
import { useEffect } from 'react';
|
|
import { usePathname } from 'next/navigation';
|
|
import { initAnalytics, trackPageView } from '@/lib/analytics';
|
|
|
|
export default function PostHogProvider({ children }: { children: React.ReactNode }) {
|
|
const pathname = usePathname();
|
|
|
|
useEffect(() => {
|
|
initAnalytics();
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (pathname) trackPageView(pathname);
|
|
}, [pathname]);
|
|
|
|
return <>{children}</>;
|
|
}
|