File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
app/dashboard/app/providers Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,12 @@ import posthog from 'posthog-js';
99import { PostHogProvider as PHProvider } from 'posthog-js/react' ;
1010
1111export function PostHogProvider ( { children } : { children : React . ReactNode } ) {
12+ const isProd = process . env . NODE_ENV === 'production' ;
13+
14+ // Initialise PostHog only in production builds to avoid noisy 401/404 errors
1215 useEffect ( ( ) => {
16+ if ( ! isProd ) return ;
17+
1318 const posthogKey = process . env . NEXT_PUBLIC_POSTHOG_KEY ;
1419
1520 // Only initialize PostHog if we have a valid key
@@ -20,7 +25,12 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
2025 capture_pageview : false , // Disable automatic pageview capture, as we capture manually
2126 } ) ;
2227 }
23- } , [ ] ) ;
28+ } , [ isProd ] ) ;
29+
30+ // When not in production, skip rendering the PostHogProvider entirely
31+ if ( ! isProd ) {
32+ return < > { children } </ > ;
33+ }
2434
2535 return (
2636 < PHProvider client = { posthog } >
You can’t perform that action at this time.
0 commit comments