File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ import { useEffect } from "react" ;
4+ import posthog from "posthog-js" ;
5+ import { PostHogProvider as PHProvider } from "posthog-js/react" ;
6+
7+ import { env } from "~/env" ;
8+
9+ export function PostHogProvider ( { children } : { children : React . ReactNode } ) {
10+ useEffect ( ( ) => {
11+ posthog . init ( env . NEXT_PUBLIC_POSTHOG_KEY , {
12+ api_host : env . NEXT_PUBLIC_POSTHOG_HOST ,
13+ person_profiles : "identified_only" , // or 'always' to create profiles for anonymous users as well
14+ defaults : "2025-05-24" ,
15+ } ) ;
16+ } , [ ] ) ;
17+
18+ return < PHProvider client = { posthog } > { children } </ PHProvider > ;
19+ }
Original file line number Diff line number Diff line change 1- import "~/styles/globals.css" ;
2-
31import { ClerkProvider } from "@clerk/nextjs" ;
42import { type Metadata } from "next" ;
53import { Geist } from "next/font/google" ;
64
5+ import { PostHogProvider } from "./_providers/posthog-provider" ;
6+
7+ import "~/styles/globals.css" ;
8+
79export const metadata : Metadata = {
810 title : "Drive Tutorial" ,
911 description : "It's like Google Drive, but worse!" ,
@@ -20,9 +22,11 @@ export default function RootLayout({
2022} : Readonly < { children : React . ReactNode } > ) {
2123 return (
2224 < ClerkProvider >
23- < html lang = "en" className = { `${ geist . variable } ` } >
24- < body > { children } </ body >
25- </ html >
25+ < PostHogProvider >
26+ < html lang = "en" className = { `${ geist . variable } ` } >
27+ < body > { children } </ body >
28+ </ html >
29+ </ PostHogProvider >
2630 </ ClerkProvider >
2731 ) ;
2832}
You can’t perform that action at this time.
0 commit comments