File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/components/PostHogProvider Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -41,15 +41,23 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
4141 const enablePostHog = ( ) => {
4242 if ( typeof window !== 'undefined' && window . posthog ) {
4343 // Re-initialize PostHog if it was previously disabled
44- window . posthog . opt_in_capturing ( ) ;
45- window . posthog . startSessionRecording ( ) ;
44+ if ( typeof window . posthog . opt_in_capturing === 'function' ) {
45+ window . posthog . opt_in_capturing ( ) ;
46+ }
47+ if ( typeof window . posthog . startSessionRecording === 'function' ) {
48+ window . posthog . startSessionRecording ( ) ;
49+ }
4650 }
4751 } ;
4852
4953 const disablePostHog = ( ) => {
5054 if ( typeof window !== 'undefined' && window . posthog ) {
51- window . posthog . opt_out_capturing ( ) ;
52- window . posthog . stopSessionRecording ( ) ;
55+ if ( typeof window . posthog . opt_out_capturing === 'function' ) {
56+ window . posthog . opt_out_capturing ( ) ;
57+ }
58+ if ( typeof window . posthog . stopSessionRecording === 'function' ) {
59+ window . posthog . stopSessionRecording ( ) ;
60+ }
5361 }
5462 } ;
5563
You can’t perform that action at this time.
0 commit comments