8104068bd5
Revert "build: Migrate to Vite 🚀 (#6713)" This reverts commit e93bbc577613a6de6bb43c40c3b57286b4994ca5.
33 lines
761 B
TypeScript
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);
|
|
}
|
|
};
|