> ## Documentation Index
> Fetch the complete documentation index at: https://bhavishaya.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# reset()

> Clear the current user identity, event queue, and deduplication cache. Call this on logout.

## 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

```ts theme={null}
reset(): void
```

## Parameters

None. `reset()` takes no arguments.

## Example

```js theme={null}
import { reset } from 'analytiq'

reset()
```

## When to call it

Always call `reset()` when a user logs out:

```js theme={null}
import { reset } from 'analytiq'

async function handleLogout() {
  await api.post('/auth/logout')  // your own logout API call
  reset()                          // clear Analytiq identity
  navigate('/login')               // redirect to login page
}
```

## 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 call `reset()` 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

Calling `reset()` prevents this by wiping User A's identity from both memory **and** `localStorage`.

## Complete login/logout flow

```js theme={null}
import { identify, track, reset } from 'analytiq'

// On login:
async function onLoginSuccess(user) {
  identify(user.id)                            // link events to this user
  track('login', { method: 'email' })          // track the login event
  navigate('/dashboard')
}

// On logout:
async function onLogout() {
  track('logout')                              // track the logout event
  reset()                                      // clear identity
  navigate('/login')
}
```
