From cde01f25f2c619bb7f53fca9099f1067defdc594 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Wed, 8 May 2024 16:22:01 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20If=20umami=20is=20broken,=20don'?= =?UTF-8?q?t=20prevent=20following=20links?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build/app.js b/build/app.js index 4a22048..6e75657 100644 --- a/build/app.js +++ b/build/app.js @@ -5,26 +5,30 @@ document.addEventListener('click', getFollows); function getFollows(evt) { const el = evt.target; if (el.tagName.toLowerCase() !== 'a') { - return; + return true; } const name = el.dataset.name; if (!name) { - return; + return true; } const url = el.href; if (!url) { - return; + return true; } if (!window.umami) { - return; + return true; } const umProm = umami.trackEvent('visit', { type: 'click', site: name }); + if (!umProm) { + return true; + } + if (!el.target || el.target.match(/^_(self|parent|top)$/i)) { // If we're not opening in a new tab, then try to send event before navigating away // Don't wait too long though (half a second, at most)