Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions contents/docs/support/javascript-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,41 @@ setInterval(async () => {
}, 5000)
```

## Recover tickets across browsers

Tickets are tied to the browser's widget session ID, so switching browsers or clearing storage means losing access. You can recover tickets by requesting a recovery link via email.

### Request a recovery link

```javascript
await posthog.conversations.requestRestoreLink('user@example.com')
```

This sends an email containing a recovery link to the provided address. The link includes a `ph_conv_restore` token as a query parameter and expires after one hour.

**Parameters:**
- `email` (string) - The email address used in previous conversations

The method is rate limited. If you send too many requests, it throws an error with a 429 status.

### Restore tickets from a recovery link

```javascript
const result = await posthog.conversations.restoreFromUrlToken()
```

Reads the `ph_conv_restore` query parameter from the current URL and migrates the associated tickets to the current browser session. After processing, the query parameter is removed from the URL.

**Response:**
```typescript
interface RestoreResult {
status: 'success'
migrated_ticket_ids: string[] // IDs of tickets migrated to this session
}
```

The default widget calls `restoreFromUrlToken()` automatically on load, so you only need to call this yourself if you're building a custom UI.

## Events captured

The conversations module automatically captures these events:
Expand Down Expand Up @@ -317,3 +352,5 @@ try {
| `getTickets(options?)` | Fetch tickets list | `Promise<GetTicketsResponse \| null>` |
| `getCurrentTicketId()` | Get current ticket ID | `string \| null` |
| `getWidgetSessionId()` | Get widget session ID | `string \| null` |
| `requestRestoreLink(email)` | Send a recovery email to restore tickets | `Promise<void>` |
| `restoreFromUrlToken()` | Restore tickets from URL recovery token | `Promise<RestoreResult \| null>` |
13 changes: 13 additions & 0 deletions contents/docs/support/widget.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ posthog.init('YOUR_API_KEY', {

This is different from hiding the widget – it completely disables the feature.

## Recover tickets across browsers

Support tickets are tied to the browser session by default. If a user switches browsers or clears their storage, they won't see their previous tickets. The widget includes a **Recover your tickets** link to handle this.

### How recovery works

1. The user clicks **Recover your tickets** in the ticket list
2. They enter the email address used in previous conversations
3. A recovery link is sent to that email (expires in one hour)
4. Clicking the link opens the widget and restores their tickets in the new browser

If the page URL contains a `ph_conv_restore` query parameter (from clicking the recovery link), tickets are automatically restored on page load. The parameter is removed from the URL after processing.

## Email notifications

Configure your team to receive email alerts when new tickets arrive.
Expand Down