mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-30 00:41:24 +00:00
Log all clicks
This commit is contained in:
parent
1479b9e4af
commit
f80a13e8ea
1 changed files with 19 additions and 1 deletions
|
@ -51,7 +51,25 @@ document.addEventListener("click", event => {
|
||||||
var target = event.target;
|
var target = event.target;
|
||||||
while (target && target !== document) {
|
while (target && target !== document) {
|
||||||
if (target.matches("a") || target.matches("button")) {
|
if (target.matches("a") || target.matches("button")) {
|
||||||
// TODO: Log event
|
// TODO: Look into using accessiblity labels (this would also make the app more accessible)
|
||||||
|
let hrefParts = window.location.href.split("#");
|
||||||
|
let element = target.title || target.text.trim();
|
||||||
|
if (element) {
|
||||||
|
amplitude
|
||||||
|
.getInstance()
|
||||||
|
.logEvent("CLICK", {
|
||||||
|
target: element,
|
||||||
|
location:
|
||||||
|
hrefParts.length > 1 ? hrefParts[hrefParts.length - 1] : "/",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
amplitude
|
||||||
|
.getInstance()
|
||||||
|
.logEvent("UNMARKED_CLICK", {
|
||||||
|
location:
|
||||||
|
hrefParts.length > 1 ? hrefParts[hrefParts.length - 1] : "/",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
target.matches('a[href^="http"]') ||
|
target.matches('a[href^="http"]') ||
|
||||||
|
|
Loading…
Add table
Reference in a new issue