Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Could you send the beacon every five minutes? When the beacon stops coming in for 30 minutes assume that the tab closed or the user went off-line.




> every five minutes

This is tricky in JavaScript, because timers are asleep/throttled in inactive tabs: https://developer.mozilla.org/en-US/docs/Web/API/Window/setT...

And if onbeforeleave analytics is not evil, doing stuff in inactive tabs is certainly is.


You could just have a websocket open then. But its unreliable because if the user's internet cuts out maybe they still on the tab, so watching websocket disconnect is not perfect either



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: