UncleGedd commented on issue #50: URL: https://github.com/apache/incubator-flagon-useralejs/issues/50#issuecomment-806553427
I don't think we are going to be able to send an HTTP request in those page unload event handlers, see this [SO thread](https://stackoverflow.com/questions/6162188/javascript-browsers-window-close-send-an-ajax-request-or-run-a-script-on-win). I know the answerer mentions the `unload` and `beforeunload` events, but I'm sure the same reasoning applies to `visibilitychange` It is indeed hard to ignore the stats from Rob's [link](https://volument.com/blog/sendbeacon-is-broken) regarding `sendBeacon`. Regardless, I don't think there is a way to get around using the `visibilitychange` event, and there are [solutions](https://www.smashingmagazine.com/2018/07/logging-activity-web-beacon-api/) to achieve a similar effect in Safari (search for "safari" in that link). Other ideas I'd like to test/mull over: 1. [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Worker): basic idea is to spawn a web worker whenever userale starts and do a `postMessage` on the `visibilitychange` (or any other) event, no more `sendBeacon`. (There may also be a larger conversation around using web workers in Userale as opposed to sending HTTP requests in the main browser thread, but I'm pretty inexperienced with this sort of thing, maybe @confusingstraw knows more about this) 2. [Websockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket): establish a websocket connection and send messages on the appropriate event, requires an [elasticsearch plugin](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-websocket.html) Both of these solutions are more complicated than just using `sendBeacon` though. Regarding @poorejc's comment above: 1. `navigator.sendBeacon` may not be as reliable as expected, but it's simple to use 2. I think any solution will be difficult to test, although `sendBeacon` wasn't so bad to unit test, I'll write a journey test around it today 3. Agreed, but there may be a workaround as described in the link above -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org