Best semantics when writing event tracking code

Hi there,

I want to use the event tracking feature to get the most of my users. Today my application is hybrid (Java PrimeFaces and React) and it is very user driven. They can do a lot of changes and that affects DOM, it’s a heavy in/out and updates. Since there is a big team working on the same project, I want to keep the .xhtml files free from changes and work solo in my custom Javascript file.

That being said, I circled back around some solutions like $(document).ready, document.querySelector().addEventListener and MutationObserver. Every time I’m getting issues where I cannot do a generic implementation (since I don’t want to change HTML structure) keeping in mind performance and good coding practices.

I was wondering if any one of you guys already faced the same scenario. For those who didn’t, how would you solve this issue? What is the best approach of tracking lots and lots of events doing in the right way.

Let me know if you need any additional information.