-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Beacon API support #1167
Comments
Hey @erykpiast, Do you know if sendBeacon has improvements over keep-alive? I wasn't around for the discussion, but IIRC By default, segment is unbatched -- it will send events as soon as they enter the Segmentio plugin, so it was not obvious that the risk of losing a single event would outweigh the competing request gotcha, and it's not something that we could conditionally turn 'on' when the page unloads, because per ^, there's nothing to 'flush'. So, no real reason |
Hey @silesky, thanks for your answer! That's strange I didn't get a notification about it. I had no idea about the keep alive option! It was quite well hidden in the docs. I found a comment about it here now when you mentioned it. Do I get it right, that I need to enable it for all requests? I think this should be fine, but originally I was thinking about tagging one particular track call as "possibly interrupted". That's my use case after all - I know well which event doesn't get in because of the hard page reload. |
Did you consider adding support for the Beacon API as a "transport layer" alternative to
fetch
/XHR
? This native API is created with analytics in mind and helps increasing reliability of client-side data collection.To quote MDN.
Nowadays the browser support for Beacon API is excellent (96%+), from my perspective is a no-brainer.
To give you an example of what it could help with practically - checkout flows provided externally, e.g. by Stripe. Imagine you have a payment plan selection in your webapp, but the payment itself happens on a different domain. Measuring the conversion - a ratio of clicks on the "Checkout" button in your app and successful payment - it's quite difficult with regular async HTTP requests as they're interrupted when the page unloads. If you redirect to an external domain right in the button click handler and you don't wait for the analytics request to finish, the risk of missing an event is quite high. Delaying the redirection it is not ideal, as it degrades user experience. Beacon API would solve this issue ultimately.
I wonder if there are any concerns about having this as an option? I found this comment from @f2prateek mentioning Beacon API and some reasons to not introduce it. Apart from that, no serious take on it there and no mention whatsoever in this repository, which is quite surprising.
The text was updated successfully, but these errors were encountered: