🐛 If umami is broken, don't prevent following links
This commit is contained in:
parent
2dfd947949
commit
cde01f25f2
1 changed files with 8 additions and 4 deletions
12
build/app.js
12
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue