File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
libraries/helpers/src/utils Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { usePlausible } from 'next-plausible' ;
2
2
import { useCallback } from 'react' ;
3
- import { useVariables } from '@gitroom/react/helpers/variable.context' ;
4
3
import { usePostHog } from 'posthog-js/react' ;
4
+ import { useVariables } from '@gitroom/react/helpers/variable.context' ;
5
+ import { useUser } from '@gitroom/frontend/components/layout/user.context' ;
5
6
6
7
export const useFireEvents = ( ) => {
7
8
const { billingEnabled } = useVariables ( ) ;
8
9
const plausible = usePlausible ( ) ;
9
10
const posthog = usePostHog ( ) ;
11
+ const user = useUser ( ) ;
12
+
13
+ return useCallback (
14
+ ( name : string , props ?: any ) => {
15
+ if ( ! billingEnabled ) {
16
+ return ;
17
+ }
10
18
11
- return useCallback ( ( name : string , props ?: any ) => {
12
- if ( ! billingEnabled ) {
13
- return ;
14
- }
19
+ if ( user ) {
20
+ posthog . identify ( user . id , { email : user . email , name : user . name } ) ;
21
+ }
15
22
16
- posthog . capture ( name , props ) ;
17
- plausible ( name , { props } ) ;
18
- } , [ ] ) ;
23
+ posthog . capture ( name , props ) ;
24
+ plausible ( name , { props } ) ;
25
+ } ,
26
+ [ user ]
27
+ ) ;
19
28
} ;
You can’t perform that action at this time.
0 commit comments