Refactor analytics

pull/3904/head
Kamran Ahmed 1 year ago
parent 9e37076d0d
commit 7a8d97b1cd
  1. 20
      src/components/Analytics/analytics.ts

@ -1,28 +1,22 @@
export { };
declare global {
interface Window {
// To selectively enable/disable debug logs
__DEBUG__: boolean;
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
* @see https://developers.google.com/analytics/devguides/collection/gtagjs/events
* @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');

Loading…
Cancel
Save