after we noticed discrepencies in our tracking data we did some testing and it seems as if beacons sent via the navigator.sendBeacon API are not arriving at our servers in all cases. Specifically when leaving the page and trying to send the beacon via the visibilitychange, pagehide or unload event it is shown as (pending) in the dev tools console but does not reach our backend.
This only happens if a service worker is active. In this case the beacons are not even reaching the service worker. When we bypass the service worker all beacons are sent correctly and arrive at the backend. We tested this with a very simplistic service worker which would just fetch any request it receives.
So far we tested with this local device:
“Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G950F) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/13.2 Chrome/83.0.4103.106 Mobile Safari/537.36”