2020-12-20 04:08:22 -08:00
|
|
|
export const trackEvent =
|
2021-01-20 21:27:33 +05:30
|
|
|
typeof process !== "undefined" &&
|
|
|
|
process.env?.REACT_APP_GOOGLE_ANALYTICS_ID &&
|
2021-01-05 20:06:14 +02:00
|
|
|
typeof window !== "undefined" &&
|
|
|
|
window.gtag
|
2022-02-21 17:44:28 +05:30
|
|
|
? (category: string, action: string, label?: string, value?: number) => {
|
|
|
|
window.gtag("event", action, {
|
2020-12-20 04:08:22 -08:00
|
|
|
event_category: category,
|
|
|
|
event_label: label,
|
|
|
|
value,
|
|
|
|
});
|
|
|
|
}
|
2021-01-20 21:27:33 +05:30
|
|
|
: typeof process !== "undefined" && process.env?.JEST_WORKER_ID
|
2022-02-21 17:44:28 +05:30
|
|
|
? (category: string, action: string, label?: string, value?: number) => {}
|
|
|
|
: (category: string, action: string, label?: string, value?: number) => {
|
2021-01-05 20:06:14 +02:00
|
|
|
// Uncomment the next line to track locally
|
2022-02-21 17:44:28 +05:30
|
|
|
// console.info("Track Event", category, action, label, value);
|
2020-12-20 04:08:22 -08:00
|
|
|
};
|