1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-12 12:13:58 +02:00

Refactor analytics

This commit is contained in:
Kamran Ahmed
2023-05-08 21:06:33 +01:00
parent 9e37076d0d
commit 7a8d97b1cd

View File

@@ -1,20 +1,14 @@
export { };
declare global {
interface Window {
// To selectively enable/disable debug logs
__DEBUG__: boolean;
gtag: any;
fireEvent: (props: GAEventType) => void;
}
}
export type GAEventType = {
fireEvent: (props: {
action: string;
category: string;
label?: string;
value?: string;
};
}) => void;
}
}
/**
* Tracks the event on google analytics
@@ -22,7 +16,7 @@ export type GAEventType = {
* @param props Event properties
* @returns void
*/
window.fireEvent = (props: GAEventType) => {
window.fireEvent = (props) => {
const { action, category, label, value } = props;
if (!window.gtag) {
console.warn('Missing GTAG - Analytics disabled');