I am currently developing a feature for my web application that tracks the amount of time a user spends on a specific page. Our backend is built with Django, and the frontend is using React and PostgreSQL as the database. I'm looking for advice on the best practices or approaches to implement this feature efficiently.
I have implemented a system where a REST API is called every three seconds and each time creates a new record, then We aggregate the total time spent by all users on each page. However, I believe there might be a more efficient and accurate way to handle this.
I didn't find any platforms that helps me to do this with the details that I need.