APM - Track clicks on webtop resources
Problem this snippet solves: This configuration sample provide to the administrator a way to log all APM webtop resources clicked by a logged-in user. Those logs can be exported to external systems ...
Updated Jun 06, 2023
Version 2.0Yann_Desmarest
Cirrus
Joined September 11, 2012
Yann_Desmarest
Sep 18, 2018Cirrus
Hi Brad,
I have done several tests using all kind of available resources on the webtop and I'm able to log everything. I found that when someone click on the icon of the resource and not the text, the script fails. So I added a piece of code to handle this case :
if (e.target.parentNode.className == "image" && e.target.parentNode.parentNode.className == "favorite") {
var xhttp = new XMLHttpRequest();
console.log(e.target.parentNode.id);
var uri = "/analytics?t=" + Math.random() + "&r=" + encodeURIComponent(window.btoa(e.target.parentNode.parentNode.id)) + "&d=" + Date.now();
xhttp.open("GET", uri, true);
xhttp.send();
}
In fact, the class of all icons is image, not favorite. So I check the parent element of the parent of the icon.
I tested again and now it looks like it matches 100% of clicks. Let me know if it works fine for you.
Have a nice day
Yann