|
|
@ -1,28 +1,22 @@ |
|
|
|
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: { |
|
|
|
|
|
|
|
action: string; |
|
|
|
|
|
|
|
category: string; |
|
|
|
|
|
|
|
label?: string; |
|
|
|
|
|
|
|
value?: string; |
|
|
|
|
|
|
|
}) => void; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export type GAEventType = { |
|
|
|
|
|
|
|
action: string; |
|
|
|
|
|
|
|
category: string; |
|
|
|
|
|
|
|
label?: string; |
|
|
|
|
|
|
|
value?: string; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Tracks the event on google analytics |
|
|
|
* Tracks the event on google analytics |
|
|
|
* @see https://developers.google.com/analytics/devguides/collection/gtagjs/events
|
|
|
|
* @see https://developers.google.com/analytics/devguides/collection/gtagjs/events
|
|
|
|
* @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'); |
|
|
|