I have a react app and I want to know how many times a user switch tabs in the browser and how many times the user minimize the browser separately. Is there a way to do it?
EDIT the current solution uses a combination of blur/focus and visibility API which covers all the cases of user navigating away. However, what I want is to count separately how many times user switched tabs vs how many times user minimized window. Blur/focus and visibility API events get fired in both tab switch and window minimize .