File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
src/components/PostHogProvider Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 2626 - name : Install dependencies
2727 run : npm ci
2828
29+ - name : TypeScript type check
30+ run : npm run typecheck
31+
2932 - name : Build site
3033 run : npm run build
3134 env :
Original file line number Diff line number Diff line change 1- import React , { useEffect , useState } from 'react' ;
1+ import React , { useEffect } from 'react' ;
22import { hasConsent , onConsentChange } from '../../lib/analytics/consent-manager' ;
33
4+ // PostHog interface - define the methods we use
5+ interface PostHogInstance {
6+ opt_in_capturing ( ) : void ;
7+ opt_out_capturing ( ) : void ;
8+ startSessionRecording ( ) : void ;
9+ stopSessionRecording ( ) : void ;
10+ }
11+
412declare global {
513 interface Window {
6- posthog ?: any ;
14+ posthog ?: PostHogInstance ;
715 }
816}
917
1018export function PostHogProvider ( { children } : { children : React . ReactNode } ) {
11- const [ isPostHogEnabled , setIsPostHogEnabled ] = useState ( false ) ;
12-
1319 useEffect ( ( ) => {
1420 // Check initial consent status
1521 const consentGiven = hasConsent ( ) ;
16- setIsPostHogEnabled ( consentGiven ) ;
1722
1823 if ( consentGiven ) {
1924 enablePostHog ( ) ;
@@ -23,7 +28,6 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
2328
2429 // Listen for consent changes
2530 const cleanup = onConsentChange ( ( granted ) => {
26- setIsPostHogEnabled ( granted ) ;
2731 if ( granted ) {
2832 enablePostHog ( ) ;
2933 } else {
You can’t perform that action at this time.
0 commit comments