analytics.ts 1020 B

123456789101112131415161718192021222324252627
  1. export const EVENT_ACTION = "action";
  2. export const EVENT_ALIGN = "align";
  3. export const EVENT_CHANGE = "change";
  4. export const EVENT_DIALOG = "dialog";
  5. export const EVENT_EXIT = "exit";
  6. export const EVENT_IO = "io";
  7. export const EVENT_LAYER = "layer";
  8. export const EVENT_LIBRARY = "library";
  9. export const EVENT_LOAD = "load";
  10. export const EVENT_SHAPE = "shape";
  11. export const EVENT_SHARE = "share";
  12. export const EVENT_MAGIC = "magic";
  13. export const trackEvent =
  14. typeof window !== "undefined" && window.gtag
  15. ? (category: string, name: string, label?: string, value?: number) => {
  16. window.gtag("event", name, {
  17. event_category: category,
  18. event_label: label,
  19. value,
  20. });
  21. }
  22. : typeof process !== "undefined" && process?.env?.JEST_WORKER_ID
  23. ? (category: string, name: string, label?: string, value?: number) => {}
  24. : (category: string, name: string, label?: string, value?: number) => {
  25. console.info("Track Event", category, name, label, value);
  26. };