Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

how to clear segment data when window closes #644

Open
acollazomayer opened this issue Oct 5, 2020 · 2 comments
Open

how to clear segment data when window closes #644

acollazomayer opened this issue Oct 5, 2020 · 2 comments
Labels

Comments

@acollazomayer
Copy link

Is there a way to do a reset when the tab closes, Right now I store my user in sessionStorage, when I close the tab the user logs out. However the segment user id is still there.

Thanks

@pooyaj
Copy link
Contributor

pooyaj commented Oct 5, 2020

@acollazomayer have you tried hooking into the page unload event and reseting analytics? Something like this:

window.addEventListener('unload', function() {
        window.analytics.reset();
      });

@pooyaj pooyaj added the Question label Oct 5, 2020
@acollazomayer
Copy link
Author

@pooyaj Tried it, but session storage does not get clear on refresh. On beforeUnload or unload are triggered on refresh

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants