mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 12:05:41 +01:00
Script simplification: Less nesting
This commit is contained in:
parent
b26fc15fa0
commit
5369144b64
1 changed files with 39 additions and 43 deletions
|
|
@ -86,9 +86,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClicks = () => {
|
const handleClicks = () => {
|
||||||
document.addEventListener(
|
|
||||||
'click',
|
|
||||||
async e => {
|
|
||||||
const trackElement = async el => {
|
const trackElement = async el => {
|
||||||
const attr = el.getAttribute.bind(el);
|
const attr = el.getAttribute.bind(el);
|
||||||
const eventName = attr(eventNameAttribute);
|
const eventName = attr(eventNameAttribute);
|
||||||
|
|
@ -103,7 +100,7 @@
|
||||||
return track(eventName, eventData);
|
return track(eventName, eventData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const onClick = async e => {
|
||||||
const el = e.target;
|
const el = e.target;
|
||||||
const parentElement = el.closest('a,button');
|
const parentElement = el.closest('a,button');
|
||||||
if (!parentElement) return trackElement(el);
|
if (!parentElement) return trackElement(el);
|
||||||
|
|
@ -129,9 +126,8 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
true,
|
document.addEventListener('click', onClick, true);
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Tracking functions */
|
/* Tracking functions */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue