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.

Allow tracker to traverse all levels to find anchor.

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