16 lines
371 B
TypeScript
16 lines
371 B
TypeScript
type EventProperties = Record<string, string | number | boolean | null | undefined>;
|
|
|
|
declare global {
|
|
interface Window {
|
|
gtag?: (...args: unknown[]) => void;
|
|
}
|
|
}
|
|
|
|
export function trackEvent(name: string, properties: EventProperties = {}): void {
|
|
if (typeof window === "undefined" || !window.gtag) {
|
|
return;
|
|
}
|
|
|
|
window.gtag("event", name, properties);
|
|
}
|