2 ms·
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.
by Hnrobert42 1y ago
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.
- ivanjermakov 1y ago> 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/setTimeout#description 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.
- hoppp 1y agoYou 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