Overview
reset() clears the current user identity set by identify(). Call it when a user logs out to prevent their events from being mixed with the next user’s events on the same device.
Signature
Parameters
None.reset() takes no arguments.
Example
When to call it
Always callreset() when a user logs out:
What it clears
| Cleared | Description |
|---|---|
userId (memory) | Removes the user set by identify(). Future events are anonymous. |
userId (localStorage) | Clears the persisted userId so the user is not re-identified on next page load. |
| Offline event queue | Clears any events saved to localStorage while the user was offline. |
| Event queue (memory) | Clears any events queued before init() was called |
| Dedup cache | Clears the 300ms deduplication memory |
Why this matters
If you don’t callreset() on logout:
- User A logs out
- User B logs in on the same browser
- User B’s events are attributed to User A’s identity on the dashboard
reset() prevents this by wiping User A’s identity from both memory and localStorage.