We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 95a3e47 commit 2f63001Copy full SHA for 2f63001
ui/src/hooks/useAnalytics.tsx
@@ -1,9 +1,22 @@
1
-import { useAppSdk } from './useAppSdk';
+import { useCallback } from "react";
2
+import { useAppSdk } from "./useAppSdk";
3
4
+const ENV: string = process.env.NODE_ENV || "";
5
+
6
+/**
7
+ * useAnalytics hook to track user actions and events in application
8
+ */
9
const useAnalytics = () => {
- 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
+ );
19
- const trackEvent = (event: string, eventData: any = {}) => appSdk?.pulse(event, eventData);
20
return { trackEvent };
21
};
22
0 commit comments