* chore: Add tracking for hyperlinks * update * fix * remove * tweak * disable ga logging in dev again * add logging for hyperlink `edit` & support for tracking in manager * event label tweaks * fix tests & make more typesafe Co-authored-by: dwelle <luzar.david@gmail.com>
19 lines
737 B
TypeScript
19 lines
737 B
TypeScript
export const trackEvent =
|
|
typeof process !== "undefined" &&
|
|
process.env?.REACT_APP_GOOGLE_ANALYTICS_ID &&
|
|
typeof window !== "undefined" &&
|
|
window.gtag
|
|
? (category: string, action: string, label?: string, value?: number) => {
|
|
window.gtag("event", action, {
|
|
event_category: category,
|
|
event_label: label,
|
|
value,
|
|
});
|
|
}
|
|
: typeof process !== "undefined" && process.env?.JEST_WORKER_ID
|
|
? (category: string, action: string, label?: string, value?: number) => {}
|
|
: (category: string, action: string, label?: string, value?: number) => {
|
|
// Uncomment the next line to track locally
|
|
// console.info("Track Event", category, action, label, value);
|
|
};
|