From 6b0218b01251dfd2143cd974279b70e10a2180a6 Mon Sep 17 00:00:00 2001 From: Milos Vetesnik Date: Thu, 27 Apr 2023 19:11:42 +0200 Subject: [PATCH] feat: testing simple analytics and fathom analytics for better privacy of the users (#6529) Co-authored-by: dwelle --- public/index.html | 45 ++++++++++++++++++++------------------------- src/analytics.ts | 17 ++++++++++++++--- src/global.d.ts | 4 ++-- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/public/index.html b/public/index.html index a8633fc4..f65e481f 100644 --- a/public/index.html +++ b/public/index.html @@ -150,6 +150,14 @@ <% if (process.env.REACT_APP_DISABLE_TRACKING !== 'true') { %> + + + + <% if (process.env.REACT_APP_GOOGLE_ANALYTICS_ID) { %> - <% } %> - - <% } %> @@ -244,5 +227,17 @@

Excalidraw

+ + + diff --git a/src/analytics.ts b/src/analytics.ts index 1e9a429b..e952bc68 100644 --- a/src/analytics.ts +++ b/src/analytics.ts @@ -20,9 +20,20 @@ export const trackEvent = ( }); } - // MATOMO event tracking _paq must be same as the one in index.html - if (window._paq) { - window._paq.push(["trackEvent", category, action, label, value]); + if (window.sa_event) { + window.sa_event(action, { + category, + label, + value, + }); + } + + if (window.fathom) { + window.fathom.trackEvent(action, { + category, + label, + value, + }); } } catch (error) { console.error("error during analytics", error); diff --git a/src/global.d.ts b/src/global.d.ts index 73c8fc81..3a666e11 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -18,8 +18,8 @@ interface Window { EXCALIDRAW_EXPORT_SOURCE: string; EXCALIDRAW_THROTTLE_RENDER: boolean | undefined; gtag: Function; - _paq: any[]; - _mtm: any[]; + sa_event: Function; + fathom: { trackEvent: Function }; } interface CanvasRenderingContext2D {