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) => {
|
2022-03-28 14:46:40 +02:00
|
|
|
try {
|
|
|
|
window.gtag("event", action, {
|
|
|
|
event_category: category,
|
|
|
|
event_label: label,
|
|
|
|
value,
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.error("error logging to ga", error);
|
|
|
|
}
|
2020-12-20 04:08:22 -08:00
|
|
|
}
|
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-03-28 14:46:40 +02:00
|
|
|
// console.log("Track Event", { category, action, label, value });
|
2020-12-20 04:08:22 -08:00
|
|
|
};
|