Skip to content

Commit 2f63001

Browse files
committed
fix:PR feedback
1 parent 95a3e47 commit 2f63001

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ui/src/hooks/useAnalytics.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
import { useAppSdk } from './useAppSdk';
1+
import { useCallback } from "react";
2+
import { useAppSdk } from "./useAppSdk";
23

4+
const ENV: string = process.env.NODE_ENV || "";
5+
6+
/**
7+
* useAnalytics hook to track user actions and events in application
8+
*/
39
const useAnalytics = () => {
4-
const [appSdk] = useAppSdk();
10+
const [appSDK] = useAppSdk();
11+
const trackEvent = useCallback(
12+
(event: string, eventData: any = {}) => {
13+
if (ENV === "production") {
14+
appSDK?.pulse(event, eventData);
15+
}
16+
},
17+
[appSDK]
18+
);
519

6-
const trackEvent = (event: string, eventData: any = {}) => appSdk?.pulse(event, eventData);
720
return { trackEvent };
821
};
922

0 commit comments

Comments
 (0)