analytics.ts 727 B

123456789101112131415161718
  1. export const trackEvent =
  2. typeof process !== "undefined" &&
  3. process.env?.REACT_APP_GOOGLE_ANALYTICS_ID &&
  4. typeof window !== "undefined" &&
  5. window.gtag
  6. ? (category: string, name: string, label?: string, value?: number) => {
  7. window.gtag("event", name, {
  8. event_category: category,
  9. event_label: label,
  10. value,
  11. });
  12. }
  13. : typeof process !== "undefined" && process.env?.JEST_WORKER_ID
  14. ? (category: string, name: string, label?: string, value?: number) => {}
  15. : (category: string, name: string, label?: string, value?: number) => {
  16. // Uncomment the next line to track locally
  17. // console.info("Track Event", category, name, label, value);
  18. };