Skip to content

Conversation

@schuyler1d
Copy link

@schuyler1d schuyler1d commented Jun 6, 2018

https://github.com/segment-integrations/analytics.js-integration-segmentio.git
Depends on this library to send the json requests to track page/event tracking.

However, during beforeunload or unload events, many browsers (esp. Safari) do not send the tracking request. However the sendBeacon call reliably does and integration-segmentio does not seem to send anything more sophisticated than what's possible with sendBeacon.

This PR is conservative and only uses it when headers are nothing beyond a standard cors xhr request. If any additional headers are sent, then it fallsback to a regular xhr request.

@atrivedi1
Copy link

@f2prateek - If you have a sec, do you mind taking a look at this PR? in principle, it seems reasonable.

@schuyler1d is trying to track form-abandonment (e.g. via a tab/window close and/or manual location change). If he were to implement this manually, the code would be something like:

window.onbeforeunload = function(evt) {
window.analytics.track({event: 'form_dropoff', properties: {result: 'dropoff', ....}})
}

however, he's hoping Segment can handle this out of the box going forward. hence the PR.

@atrivedi1
Copy link

@schuyler1d - apologies for the delayed response!

after speaking to the engineering team, i can confirm that this is indeed something that is on our radar. in fact we even implemented a fix a while back: segment-integrations/analytics.js-integration-segmentio#19. however we had to revert this once we realized that beacon and localstorage-retry don't play nice with one another. rolling out a more robust version of localstorage-retry is something we are going to be actively working on in the next quarter or so and so our goal is to address this then.

i know that's probably not the answer you wanted to hear, but hopefully that at least provides you with a bit more context!

@schuyler1d
Copy link
Author

@atrivedi1 Thanks for the context. If there's an issue I can track to see when this lands, please let me know. Otherwise, I wish you and your team the best -- looking forward to an even better segment!

@schuyler1d schuyler1d closed this Jun 20, 2018
@schuyler1d
Copy link
Author

I'd be interested to know if there's movement on this?

@schuyler1d schuyler1d reopened this Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants