Commit aadc41e 1 parent 5172dd7 commit aadc41e Copy full SHA for aadc41e
File tree 1 file changed +3
-10
lines changed
1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change 1
1
import posthog from "posthog-js" ;
2
2
import { PostHogProvider } from "posthog-js/react" ;
3
- import React , { PropsWithChildren , useEffect } from "react" ;
3
+ import { PropsWithChildren , useEffect } from "react" ;
4
4
import { useAppSelector } from "../redux/hooks" ;
5
5
6
6
const CustomPostHogProvider = ( { children } : PropsWithChildren ) => {
7
7
const allowAnonymousTelemetry = useAppSelector (
8
8
( store ) => store ?. config ?. config ?. allowAnonymousTelemetry ,
9
9
) ;
10
10
11
- const [ client , setClient ] = React . useState < any > ( undefined ) ;
12
-
13
11
useEffect ( ( ) => {
14
12
if ( allowAnonymousTelemetry ) {
15
13
posthog . init ( "phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs" , {
@@ -22,17 +20,12 @@ const CustomPostHogProvider = ({ children }: PropsWithChildren) => {
22
20
} ) ;
23
21
posthog . identify ( window . vscMachineId ) ;
24
22
posthog . opt_in_capturing ( ) ;
25
- setClient ( client ) ;
26
23
} else {
27
- setClient ( undefined ) ;
24
+ posthog . opt_out_capturing ( ) ;
28
25
}
29
26
} , [ allowAnonymousTelemetry ] ) ;
30
27
31
- return allowAnonymousTelemetry ? (
32
- < PostHogProvider client = { client } > { children } </ PostHogProvider >
33
- ) : (
34
- < > { children } </ >
35
- ) ;
28
+ return < PostHogProvider client = { posthog } > { children } </ PostHogProvider > ;
36
29
} ;
37
30
38
31
export default CustomPostHogProvider ;
You can’t perform that action at this time.
0 commit comments