1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-11 19:53:59 +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 { declare global {
interface Window { interface Window {
// To selectively enable/disable debug logs
__DEBUG__: boolean;
gtag: any; gtag: any;
fireEvent: (props: GAEventType) => void; fireEvent: (props: {
}
}
export type GAEventType = {
action: string; action: string;
category: string; category: string;
label?: string; label?: string;
value?: string; value?: string;
}; }) => void;
}
}
/** /**
* Tracks the event on google analytics * Tracks the event on google analytics
@@ -22,7 +16,7 @@ export type GAEventType = {
* @param props Event properties * @param props Event properties
* @returns void * @returns void
*/ */
window.fireEvent = (props: GAEventType) => { window.fireEvent = (props) => {
const { action, category, label, value } = props; const { action, category, label, value } = props;
if (!window.gtag) { if (!window.gtag) {
console.warn('Missing GTAG - Analytics disabled'); console.warn('Missing GTAG - Analytics disabled');