49bd683401
* fix(analytics.ts): add safe check for process so Excalidraw can be loaded via script * fix
19 lines
727 B
TypeScript
19 lines
727 B
TypeScript
export const trackEvent =
|
|
typeof process !== "undefined" &&
|
|
process.env?.REACT_APP_GOOGLE_ANALYTICS_ID &&
|
|
typeof window !== "undefined" &&
|
|
window.gtag
|
|
? (category: string, name: string, label?: string, value?: number) => {
|
|
window.gtag("event", name, {
|
|
event_category: category,
|
|
event_label: label,
|
|
value,
|
|
});
|
|
}
|
|
: typeof process !== "undefined" && process.env?.JEST_WORKER_ID
|
|
? (category: string, name: string, label?: string, value?: number) => {}
|
|
: (category: string, name: string, label?: string, value?: number) => {
|
|
// Uncomment the next line to track locally
|
|
// console.info("Track Event", category, name, label, value);
|
|
};
|