Skip to content

feat (event processor/pending events dispatcher): In browser entry point, add event listener for pagehide or unload that calls optimizely.close #347

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

Merged
merged 7 commits into from
Aug 16, 2019

Conversation

mjc1283
Copy link
Contributor

@mjc1283 mjc1283 commented Aug 16, 2019

Summary

With event batching, optimizely.close() needs to be called to ensure that events are flushed before the user navigates away. This PR ensures that optimizely.close() is called when the page unloads by hooking into the pagehide event or the unload event.

Test plan

Added a UMD bundle test. Manually tested.

@mjc1283 mjc1283 requested a review from mikeproeng37 August 16, 2019 19:39
@mjc1283 mjc1283 requested a review from a team as a code owner August 16, 2019 19:39
@mjc1283 mjc1283 removed their assignment Aug 16, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 97.597% when pulling 7bb511a on jordan/add-browser-event-handler into 5f49770 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 97.597% when pulling 7bb511a on jordan/add-browser-event-handler into 5f49770 on master.

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@@ -125,7 +131,24 @@ module.exports = {
config.eventFlushInterval = DEFAULT_EVENT_FLUSH_INTERVAL;
}

return new Optimizely(config);
var optimizely = new Optimizely(config);
Copy link
Contributor

@mikeproeng37 mikeproeng37 Aug 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should bother making this turnoffable in case the user is really adamant about doing it themselves. I don't see it as a hard blocker for this PR though. Just food for thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair question. I think this is the right default given that batching will be enabled by default. I'm willing to wait and see if there's any interest in turning it off from users.

@mjc1283 mjc1283 merged commit 1be4665 into master Aug 16, 2019
@mjc1283 mjc1283 deleted the jordan/add-browser-event-handler branch August 16, 2019 22:51
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.

4 participants