Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Revert tracker logic. Bump search depth.

Mike Cao938047ce458f
diff --git a/tracker/index.js b/tracker/index.js
index f643bdae2..1c40036e9 100644
--- a/tracker/index.js
+++ b/tracker/index.js
@@ -112,21 +112,22 @@
};
const callback = e => {
- const findATagParent = rootElem => {
+ const findATagParent = (rootElem, maxSearchDepth) => {
let currentElement = rootElem;
-
- while (currentElement) {
+ for (let i = 0; i < maxSearchDepth; i++) {
if (currentElement.tagName === 'A') {
return currentElement;
}
currentElement = currentElement.parentElement;
+ if (!currentElement) {
+ return null;
+ }
}
-
return null;
};
const el = e.target;
- const anchor = el.tagName === 'A' ? el : findATagParent(el);
+ const anchor = el.tagName === 'A' ? el : findATagParent(el, 10);
if (anchor) {
const { href, target } = anchor;