use beacon api? #190
Replies: 7 comments 3 replies
-
I think that the addition can be quite small, and restricted to the
One can make a simple I would be willing to make a PR for the tracking script if the maintainers are ok with it (the |
Beta Was this translation helpful? Give feedback.
-
https://github.com/plausible/analytics/blob/master/tracker/src/p.js#L63 if (navigator.sendBeacon) {
navigator.sendBeacon(plausibleHost + '/api/event', payload)
} else {
... The I don't know if this API route is called anywhere else but if this is the only place it's called, it shouldn't be a hard change. I am also not sure about the Maybe @ukutaht can take a look at it. |
Beta Was this translation helpful? Give feedback.
-
Interesting reading on the Beacon API: https://volument.com/blog/sendbeacon-is-broken Make sure to read the comments for the full context |
Beta Was this translation helpful? Give feedback.
-
Oops, found this after making a PR (#1730). Interesting read: https://volument.com/blog/sendbeacon-is-broken (last edited today?). I wonder if this data is still relevant since it was posted 2y ago. Pulled this link from the nested GitHub thread, as additional reference. https://calendar.perfplanet.com/2020/beaconing-in-practice/ |
Beta Was this translation helpful? Give feedback.
-
I was wondering if there is a particular reason not to use the beacon api ? |
Beta Was this translation helpful? Give feedback.
-
What's the status of this? sendBeacon seems to be the most reliable way to go when used with "visibilitychange" to get a "on leave" package. |
Beta Was this translation helpful? Give feedback.
-
Has there been any further progress on sendBeacon? Just trying to figure out if it's planned? Or canned? |
Beta Was this translation helpful? Give feedback.
-
i love how small the plausible script is, so i'm a little hesistant to suggest more stuff in it, but it would be nice to use the beacon api instead of xhr. that way, you can shoot off events "in the background", as opposed to having them block the page nav. browser support for this is ok but not supported on IE11 which maybe is a dealbreaker for some of your users. in our case, it isn't though.
i guess in theory you could have different scripts served based on the user agent, though i can see why that would be a hassle to maintain.
Beta Was this translation helpful? Give feedback.
All reactions