excalidraw/src/analytics.ts
Aakansha Doshi 8104068bd5
revert: "build: Migrate to Vite 🚀" (#6814)
Revert "build: Migrate to Vite 🚀 (#6713)"

This reverts commit e93bbc577613a6de6bb43c40c3b57286b4994ca5.
2023-07-26 22:34:06 +05:30

33 lines
761 B
TypeScript

export const trackEvent = (
category: string,
action: string,
label?: string,
value?: number,
) => {
try {
// place here categories that you want to track as events
// KEEP IN MIND THE PRICING
const ALLOWED_CATEGORIES_TO_TRACK = [] as string[];
// Uncomment the next line to track locally
// console.log("Track Event", { category, action, label, value });
if (typeof window === "undefined" || process.env.JEST_WORKER_ID) {
return;
}
if (!ALLOWED_CATEGORIES_TO_TRACK.includes(category)) {
return;
}
if (window.sa_event) {
window.sa_event(action, {
category,
label,
value,
});
}
} catch (error) {
console.error("error during analytics", error);
}
};