Use of navigator `sendBeacon`?
See original GitHub issueHi,
Would you consider using navigator.sendBeacon
when available (modern browsers) rather than xhr requests? The advantages are:
- offline support (events are queued if loss of connectivity)
- execution in a worker thread
- page unloads doesn’t cancel in-flight requests
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:14
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Navigator.sendBeacon() - Web APIs | MDN
The navigator.sendBeacon() method asynchronously sends an HTTP POST request containing a small amount of data to a web server.
Read more >How and why to use navigator.sendBeacon - Ben Borgers
The navigator.sendBeacon() method makes POST requests without waiting for a response. It's often used for analytics and diagnostics, ...
Read more >"sendbeacon" | Can I use... Support tables for HTML5, CSS3, etc
Allows data to be sent asynchronously to a server with navigator.sendBeacon , even after a page was closed. Useful for posting analytics data...
Read more >What is sendBeacon in JavaScript? - Educative.io
The sendBeacon will send an HTTP POST request. ... To overcome this problem, we can use sendBeacon , which includes the following benefits:...
Read more >JavaScript's sendBeacon - Medium
A method from the Beacon API, it allows you to send a POST request with two parameters — the URL endpoint for the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@joshunger and others, sendBeacon is now available in beta as of SDK version 8.5.0. There are notes on how to use it here, and let me know if you encounter any issues with it.
@joshunger theoretically, one could do that by making a fetch request directly to amplitude’s HTTP endpoint from the browser inside a
navigator.sendBeacon
call.However, this feature is actively being worked on now, and will be available in the JS SDK by the end of next week at the latest. So if you’re able to wait it will be ready natively soon