From 91e55ceddaa4d5dddd4d57a832cfbefe24c43687 Mon Sep 17 00:00:00 2001 From: Chris Zuber Date: Fri, 12 Apr 2024 17:28:48 -0700 Subject: [PATCH 1/2] Disable Google Analytics --- js/consts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/consts.js b/js/consts.js index ae14740..b6428f5 100644 --- a/js/consts.js +++ b/js/consts.js @@ -1,5 +1,5 @@ -export const GA = 'UA-119717465-13'; - +//export const GA = 'UA-119717465-13'; +export const GA = null; export const env = (location.hostname === 'localhost' || location.hostname.endsWith('.netlify.live')) ? 'development' : 'production'; From 8d4efb0c6453c7bead780cb49e97ed1c2708029b Mon Sep 17 00:00:00 2001 From: Chris Zuber Date: Fri, 12 Apr 2024 19:23:07 -0700 Subject: [PATCH 2/2] Try different loading strategy --- js/consts.js | 3 +-- js/index.js | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/js/consts.js b/js/consts.js index b6428f5..415aa23 100644 --- a/js/consts.js +++ b/js/consts.js @@ -1,5 +1,4 @@ -//export const GA = 'UA-119717465-13'; -export const GA = null; +export const GA = 'UA-119717465-13'; export const env = (location.hostname === 'localhost' || location.hostname.endsWith('.netlify.live')) ? 'development' : 'production'; diff --git a/js/index.js b/js/index.js index 1bbe521..d42cd60 100644 --- a/js/index.js +++ b/js/index.js @@ -19,20 +19,19 @@ toggleClass([document.documentElement], { if (typeof GA === 'string' && GA.length !== 0) { const policy = getGooglePolicy(); - scheduler.postTask(() => { - requestIdleCallback(async () => { - const { ga, hasGa } = await importGa(GA, {}, { policy }); - - if (hasGa()) { - ga('create', GA, 'auto'); - ga('set', 'transport', 'beacon'); - ga('send', 'pageview'); - - on('a[rel~="external"]', 'click', externalHandler, { passive: true, capture: true }); - on('a[href^="tel:"]', 'click', telHandler, { passive: true, capture: true }); - on('a[href^="mailto:"]', 'click', mailtoHandler, { passive: true, capture: true }); - } - }); + + scheduler.postTask(async () => { + const { ga, hasGa } = await importGa(GA, {}, { policy }); + + if (hasGa()) { + ga('create', GA, 'auto'); + ga('set', 'transport', 'beacon'); + ga('send', 'pageview'); + + on('a[rel~="external"]', 'click', externalHandler, { passive: true, capture: true }); + on('a[href^="tel:"]', 'click', telHandler, { passive: true, capture: true }); + on('a[href^="mailto:"]', 'click', mailtoHandler, { passive: true, capture: true }); + } }, { priority: 'background' }); } else { createPolicy('goog#html', {});