How to log everything that user does in the application?

I have an Ionic 3 application and I need to log everything that user does in the application such as the button that user clicks or the page that user enters etc. After that, I am going to send these logs to the database. I tried to do this with HostListeners but it makes things confusing. Because even I click onto an empty space, it still continues to log. Acutally, I don’t want to write function to every single function into app, beucase I have already over 300 functions. So, I am curious about if there is any best practice for this situation or not. Thank you for your help! :slight_smile: