I'd like to track user activity in my angular app by creating a log of the functions tied to buttons the user clicks.
I figured the best way would be to create an event listener which logs the function name and any parameters associated with the clicked element.
I've been able to retrieve the element, but am unsure of how to get the function name and parameters.
Any help would be much appreciated.
Here's my code so far, so if I click a button which includes myFunction, i'd like the clickListener to log that 'myFunction' was called and 'foo' was the parameter passed in.
$scope.clickListener = function () {
document.addEventListener("click", function (event) {
console.log(event.target);
}, false);
};
$scope.myFunction = function (foo) {
//do stuff
}
<button ng-click="myFunction('foo')"></button>