# Session replay

> Record masked sessions on the web (the page's DOM, or layout boxes only) and native wireframes on iOS, Android, Flutter and React Native, only with replay consent, with sampling, replay on error, console and network panels, and links from errors and surveys.

Source: https://apphelm.dev/docs/session-replay

A session replay shows what a person saw and did: the pages or screens, their clicks and taps, scrolling, typing (masked), and on the web the console and network requests. You watch it in **Session replay** in the app, and errors, surveys, logs and LLM traces link straight to the moment they happened.

Replay is not video. On the web the SDK records the page's structure (the DOM) and its changes, with every input value masked by default. On mobile it records a wireframe of the native views, never pixels. Nothing is recorded until the person has given **replay consent**, which your app collects; AppHelm never asks for you.

## Turn it on in the browser

Replay comes with the browser SDK; there is nothing extra to install. Set the `replay` option, then give consent from your consent banner. The recorder loads only once both analytics and replay consent are given.

Next.js — app/providers.tsx:
```tsx
"use client";
import { ApphelmNextProvider } from "@sansavision/apphelm/next";

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <ApphelmNextProvider options={{
      key: process.env.NEXT_PUBLIC_APPHELM_KEY!, workspaceId: "org_…", productId: "prd_…",
      replay: { sampleRate: 1 },
    }}>
      {children}
    </ApphelmNextProvider>
  );
}

// In your consent banner (any client component):
// const client = useApphelm();   from "@sansavision/apphelm/next"
// client?.setConsent({ analytics: true, replay: true });
```

React:
```tsx
import { ApphelmProvider, useApphelm } from "@sansavision/apphelm/react";

<ApphelmProvider options={{ key: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…", replay: { sampleRate: 1 } }}>
  <App />
</ApphelmProvider>;

function ConsentBanner() {
  const client = useApphelm();
  return <button onClick={() => client?.setConsent({ analytics: true, replay: true })}>Accept</button>;
}
```

Vue / Nuxt — main.ts:
```ts
import { apphelm, useApphelm } from "@sansavision/apphelm/vue";

app.use(apphelm, { options: { key: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…", replay: { sampleRate: 1 } } });

// In your consent banner component:
useApphelm()?.setConsent({ analytics: true, replay: true });
```

Svelte / SvelteKit — +layout.svelte:
```ts
import { createApphelm } from "@sansavision/apphelm/svelte";

const apphelm = createApphelm({ options: { key: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…", replay: { sampleRate: 1 } } });

// In your consent banner:
apphelm.client.setConsent({ analytics: true, replay: true });
```

JavaScript (browser):
```js
import { createBrowserSdk } from "@sansavision/apphelm/browser";

const analytics = createBrowserSdk({
  key: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…",
  replay: { sampleRate: 1 },
});

// From your consent banner:
analytics.setConsent({ analytics: true, replay: true });
```

The framework entries pass the same `replay` options to the browser client and add no replay options of their own. In Angular, pass `replay` inside `provideApphelm({ options })` and call `inject(ApphelmService).client.setConsent(…)`.

How consent works in the browser:

- Both start off: the default is `{ analytics: false, replay: false }`.
- Replay needs analytics consent too. `setConsent({ replay: true })` without `analytics: true` records nothing.
- Global Privacy Control (`navigator.globalPrivacyControl`) and `enabled: false` turn both off, whatever `setConsent` says.
- `setConsent({ analytics: true, replay: false })` stops the recording at once and discards anything not yet sent.
- `reset()` (on sign-out) ends the recording and starts a new one for the next person.

The project key (`ahl_pub_…`) must allow the page's origin. Add your site's origins to the key in **Settings → Keys**; a page on another origin is refused with `invalid_project_key`. See [Keys, scopes and environments](https://apphelm.dev/docs/keys-and-environments).

## DOM or schematic recording

| Mode | Records | Use it when |
| --- | --- | --- |
| `dom` (default) | The page as it looked: its elements, text and styles, with every input value masked, plus console and network metadata | You want to see what the person saw |
| `schematic` | Layout boxes only, at most 350 per snapshot. No text, no values, no images. `fidelity: "rich"` adds rounded colours, font sizes and corner radii, still with no text | You must not record any page text |

JavaScript (browser):
```js
createBrowserSdk({ key: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…", replay: { mode: "schematic" } });
```

Most options on this page apply to DOM mode only. Schematic mode reads `sampleRate`, `onErrorSampleRate`, `errorBufferMs`, `blockedPaths`, `sensitiveSelectors`, `consentPolicyVersion`, `snapshotIntervalMs` (default 1,500 ms, 750 to 10,000) and `fidelity`, and ignores the rest.

## Options

All of these go in `replay: { … }`.

| Option | Default | What it does |
| --- | --- | --- |
| `sampleRate` | `1` | Share of sessions recorded, 0 to 1 |
| `onErrorSampleRate` | `0` | Share of the sessions `sampleRate` didn't pick that are kept in memory and sent only if an error happens (see [Replay on error](#replay-on-error)) |
| `errorBufferMs` | `60000` | How much to keep in memory before an error, 10,000 to 120,000 ms |
| `maskAllInputs` | `true` | Mask every input value and `contenteditable` text. Password, one-time-code and card fields are never recorded either way |
| `maskAllText` | `false` | Mask every text node on the page too |
| `maskSelector` | none | CSS selector whose text and values are masked |
| `blockSelector` | none | CSS selector drawn as an empty box of the same size |
| `ignoreSelector` | none | CSS selector of inputs whose typing is not recorded |
| `sensitiveSelectors` | none | More selectors to mask, as a list |
| `blockedPaths` | none | Paths where recording pauses, added to the built-in list |
| `recordCanvas` | `false` | Record `<canvas>` frames, `canvasFps` times a second (default 1, 0.2 to 4) |
| `console` | on | `false` turns console capture off; `{ levels, mask }` picks levels or rewrites entries |
| `network` | on | `false` turns it off; `{ recordHeaders, recordBody, recordQuery, resources, mask }` records more or less |
| `minimumDurationMs` | `0` | Recordings shorter than this (at most 60,000 ms) are never sent |
| `idleTimeoutMs` | 30 minutes | A recording ends after this long without activity (1 minute to 1 hour); the next activity starts a new one |
| `linkedFlag` | none | Record only while this [feature flag](https://apphelm.dev/docs/feature-flags) is on for the person |
| `urlTriggers` | none | Start recording once the address contains one of these strings or matches one of these regular expressions |
| `consentPolicyVersion` | `"sdk_consent_v1"` | Your consent text's version, stored with each recording (at most 80 characters) |

JavaScript (browser):
```js
createBrowserSdk({
  key: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…",
  replay: {
    sampleRate: 0.25,
    maskAllText: true,
    blockSelector: ".account-number",
    blockedPaths: ["/settings/billing"],
    network: { recordHeaders: true },
    consentPolicyVersion: "consent_v3",
  },
});
```

## What is masked

Masking happens in the browser, before anything is sent. In DOM mode:

| What | Default |
| --- | --- |
| Input, `textarea` and `select` values | Masked with same-length asterisks (`maskAllInputs: true`), cut to 256 characters |
| Password, one-time-code and card fields (`type=password`, `autocomplete` `current-password`, `new-password`, `one-time-code` or `cc-…`) | Always `********`, whatever the options |
| Editable content (`contenteditable`) | Masked like an input value while `maskAllInputs` is on (the default), as schematic mode always masks it |
| Other text on the page | Recorded. Use `maskAllText`, `maskSelector` or a mask class to hide it |
| `.ph-no-capture`, `.apphelm-no-capture`, `[data-apphelm-block]` | An empty box of the same size, labelled "Hidden by the page" in the player |
| `.ph-mask`, `.apphelm-mask`, `[data-apphelm-mask]`, `[data-apphelm-sensitive]`, `[data-private]` | Text and values masked |
| `.ph-ignore-input`, `.apphelm-ignore-input` | Typing not recorded |
| `script`, `noscript`, `template`, `on…` attributes, `javascript:` links | Never recorded |
| Same-origin iframes | Recorded like the page |
| Cross-origin iframes | An empty frame |
| Canvas | Off. With `recordCanvas`, up to 10 canvases as compressed images, sent only when they change |

```html
<div class="apphelm-no-capture">Never recorded, drawn as a box</div>
<span data-apphelm-mask>Masked text</span>
<input class="apphelm-ignore-input" name="promo" />
```

> **Card fields:** Card fields are recognised by their `autocomplete="cc-…"` attribute. If you turn `maskAllInputs` off, give card inputs that attribute or a mask class, or their values are recorded.

### Pages that are never recorded

Recording pauses, and keeps nothing, on any path where one of these appears as a path segment, anywhere in the path: `auth`, `sign-in`, `sign-up`, `login`, `logout`, `billing`, `checkout`, `payment`, `admin` and `account/security`. So `/billing`, `/billing/invoices`, `/settings/billing` and `/team/admin` are all skipped, while `/billing-faq` is recorded. Your `blockedPaths` are added to these, each with every path under it. When the person leaves, recording resumes with a fresh snapshot.

The server applies the same rule and refuses any part of a recording that reaches such a path; the browser SDK checks it first, so it never sends one. Browser SDK 0.8.0 and earlier matched the words only at the start of the path, so with those versions, add nested paths such as `/settings/billing` to `blockedPaths`.

### Console and network

Both are on by default in DOM mode and show in the player's **Console** and **Network** panels.

- **Console**: `log`, `info`, `warn`, `error` and `debug`, plus uncaught errors and unhandled promise rejections. Each message is cut to 2,000 characters; at most 1,000 entries per recording and 50 a second. Emails, JWTs, bearer and basic tokens, long card-like numbers and long random strings are masked.
- **Network**: `fetch`, `XMLHttpRequest`, resource and navigation timings, at most 2,000 entries per recording. Method, URL, status, timing and size are recorded. Query values become `*` unless `recordQuery: true`, and sensitive query keys stay masked even then. Headers only with `recordHeaders` (`authorization`, `cookie`, `x-apphelm-key` and token, secret or session headers are always `[masked]`). Bodies only with `recordBody`, cut to 8,000 characters, with sensitive JSON and form fields masked. Requests to AppHelm itself are never recorded.

The server scrubs console and network text again with the built-in rules and your workspace's scrubbing rules. `beforeSend` does not see replay. See [Privacy, consent and data controls](https://apphelm.dev/docs/privacy).

## Replay on error

To record only sessions where something went wrong, turn the session rate down and the error rate up:

JavaScript (browser):
```js
createBrowserSdk({
  key: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…",
  replay: { sampleRate: 0, onErrorSampleRate: 1, errorBufferMs: 60_000 },
});
```

A session that `sampleRate` didn't pick is then recorded into memory only, keeping about the last `errorBufferMs`. Nothing is sent unless an error is captured. When one is, the buffer is uploaded and recording carries on as a normal replay. In the browser, `captureMessage` uploads the buffer too, and the decision is made before `beforeSend` runs. This needs replay consent like any replay.

On mobile the same two rates exist (`sessionSampleRate`, `onErrorSampleRate`); the buffer is 30 seconds by default, only exceptions upload it, and only after `beforeSend` keeps them.

## Turn it on in mobile apps

Every mobile SDK records wireframes of the native views: positions, sizes, masked text and taps, taken when the screen changes (checked once a second). Like the browser, they upload to the public collector, so they need the project key (`ahl_pub_…`) and an origin that key allows. Without `projectKey`/`origin` the survey key and origin are used. Nothing is recorded until you call `setReplayConsent(true)`; `false` stops at once and discards what wasn't sent.

React Native / Expo — apphelm.ts:
```tsx
// npm install @sansavision/apphelm @sansavision/apphelm-react-native-replay && cd ios && pod install
import { createReactNativeSdk } from "@sansavision/apphelm/react-native";
import { mobileReplay } from "@sansavision/apphelm/react-native-replay";
import { replayCapture } from "@sansavision/apphelm-react-native-replay";

export const mobile = createReactNativeSdk({
  apiKey: "ahl_live_…", workspaceId: "org_…", productId: "prd_…",
  storage: AsyncStorage, appState: AppState,
  surveyKey: "ahl_pub_…", surveyOrigin: "https://app.example.com",
  replay: mobileReplay({ capture: replayCapture, sessionSampleRate: 1, onErrorSampleRate: 0 }),
});

// From your consent prompt:
mobile.setReplayConsent(true);
```

iOS (Swift):
```swift
var options = ApphelmOptions(apiKey: "ahl_live_…", workspaceId: "org_…", productId: "prd_…")
options.replay = ReplayOptions(projectKey: "ahl_pub_…", origin: "https://app.example.com")
let client = ApphelmClient(options: options)

// From your consent prompt:
client.setReplayConsent(true)
```

Android (Kotlin):
```kotlin
Apphelm.setup(this, ApphelmConfig(BuildConfig.APPHELM_API_KEY, "org_…", "prd_…").apply {
    replay = ReplayOptions(projectKey = "ahl_pub_…", origin = "https://app.example.com")
})

// From your consent prompt:
Apphelm.setReplayConsent(true)
```

Flutter:
```dart
await Apphelm.setup(ApphelmConfig(
  apiKey: 'ahl_live_…', workspaceId: 'org_…', productId: 'prd_…',
  replay: const ApphelmReplayOptions(projectKey: 'ahl_pub_…', origin: 'https://app.example.com'),
));

// From your consent prompt:
Apphelm.instance.setReplayConsent(true);
```

**Only for React Native / Expo:**

The native module `@sansavision/apphelm-react-native-replay` does the view walking, so rebuild the app after installing it; a JavaScript reload is not enough. It doesn't work in Expo Go: there `replayCapture` is null and nothing is recorded. Screens are named from `mobile.screen(name)` or `navigationTracker()`. The client has `setReplayConsent`, `replaySessionId()`, `isReplayActive()` and `flushReplay()`. AppHelm has not yet run the React Native replay inside a real app, so test it in yours before you rely on it.

**Only for iOS (Swift):**

Only the key window is recorded. SwiftUI content that isn't backed by UIKit views shows as boxes without text. The client has `setReplayConsent(_:)`, `isReplayActive`, `replaySessionId` and `flushReplay()`. `ReplayOptions` also takes `checkIntervalSeconds` (default 1), `flushIntervalSeconds` (default 5), `blockedScreens` and `consentPolicyVersion`.

**Only for Android (Kotlin):**

Views are walked by the `apphelm-android` module. Jetpack Compose content (a `ComposeView`) is drawn as one box, and the Compose module has no replay API. NDK crashes carry no replay. `replaySessionId` and `flushReplay()` are on the client (`Apphelm.client`), not on the `Apphelm` facade. A plain JVM client records only what you pass to `client.replay?.capture(…)`.

**Only for Flutter:**

The wireframe is read from Flutter's widget and render trees. Replay runs on iOS and Android only; on Flutter web and desktop it is off. The client has `setReplayConsent`, `isReplayActive`, `replaySessionId` and `flushReplay()`.

Mobile options (names as in each SDK):

| Option | Default | What it does |
| --- | --- | --- |
| `projectKey`, `origin` | the survey key and origin | The public key and an origin it allows. A key that isn't `ahl_pub_…` turns replay off before anything is sent |
| `maskAllTextInputs` | `true` | Text fields show asterisks. Secure and password fields are always `********` and never read |
| `maskAllText` | `false` | Mask labels and button titles too |
| `sessionSampleRate` | `1` | Share of recordings kept, drawn at the first screen after consent, after 30 minutes in the background and after `reset()` |
| `onErrorSampleRate` | `0` | As in the browser, with a 30-second buffer (`errorBufferMs`, `errorBufferSeconds` on iOS, `errorBuffer` on Flutter; 10 to 120 seconds) |
| `blockedScreens` | none | Screens never recorded, added to the built-in auth, sign-in, sign-up, login, logout, billing, checkout, payment, admin and account/security names |

Mark views to mask or hide:

React Native / Expo:
```tsx
import { ApphelmReplayMask, ApphelmReplayNoCapture } from "@sansavision/apphelm-react-native-replay";

<ApphelmReplayMask><Text>{user.email}</Text></ApphelmReplayMask>
<ApphelmReplayNoCapture><CardView /></ApphelmReplayNoCapture>
```

iOS (Swift):
```swift
emailLabel.apphelmReplayMask = true
cardView.apphelmReplayNoCapture = true
```

Android (Kotlin):
```kotlin
Apphelm.replayMask(emailLabel)
Apphelm.replayNoCapture(cardView)
```

Flutter:
```dart
ApphelmReplayMask(child: Text(user.email))
ApphelmReplayNoCapture(child: CardView())
```

On every mobile platform an accessibility identifier, tag or content description containing `apphelm-mask` or `apphelm-no-capture` (or PostHog's `ph-mask`, `ph-no-capture`) works too. Mobile replays have no console or network panels.

## Watch a replay

Open **Session replay** in the app. Filter the list by person, identified or anonymous, duration, date, an event, a URL, device, browser, OS, country, platform or recording mode, or by errors, rage clicks, dead clicks, console errors or network errors. Sort by newest, oldest, longest, most active or most errors.

The player:

- Plays at 0.5×, 1×, 2×, 4× or 8×, and skips inactivity (gaps of 5 seconds or more) by default.
- **Space** plays and pauses; **←** and **→** jump 5 seconds.
- Marks the timeline with page views, events, errors, clicks, rage clicks (3 clicks within a second and 30 px), dead clicks (no response within a second), console errors, network errors and navigations.
- Has **Activity**, **Console** and **Network** panels (web DOM recordings only).
- Plays DOM recordings in a sandboxed frame, so no recorded script ever runs.

Save a set of filters as a **saved filter** (new recordings that match appear in it) or add recordings by hand to a **collection**. A workspace can have up to 200 of them, with up to 1,000 recordings per collection.

Replays can be viewed by owners, admins, product managers and analysts. Every view is recorded in an access audit.

## Links to errors, surveys and more

- An error captured while a recording runs carries `replay_session_id`, and the issue links to the replay at that moment. See [Errors and issues](https://apphelm.dev/docs/errors).
- A survey asked during a recording saves the recording first and links the answer to it. See [Surveys](https://apphelm.dev/docs/surveys).
- Logs, LLM traces and heatmaps link to the replay of the same session.

## Limits, plans and retention

| Limit | Value |
| --- | --- |
| Recordings per month | Set by your plan. A recording counts once, on its first upload. At the cap, new recordings are refused with `replay_limit` (429); ones already running keep uploading |
| Retention | Set by your plan: 14 days on Free, 30 on Builder, 90 on Portfolio and Scale. A shorter **Session replay** retention in **Settings → Privacy & collection** wins |
| Recording length | Ends after `idleTimeoutMs` without activity, or after almost 24 hours. Mobile recordings run at most a day, and returning after 30 minutes in the background starts a new one |
| Browser memory | A recording whose unsent data passes 8 MB is ended and discarded |
| One upload | At most 1 MB compressed, 5,000 events, and a start time no more than 26 hours ago |

The month is the UTC calendar month.

## API and MCP

Replay content stays in the app. The API and MCP return session metadata only, never what was recorded.

| Endpoint | Scope | What it does |
| --- | --- | --- |
| `GET /api/v1/sessions` | `sessions:read` | The newest matching sessions (up to 100, paged with `limit` and `cursor`), with the list's filters as query parameters: `productId`, `person`, `minDuration`, `maxDuration`, `from`, `to`, `event`, `errors`, `rage`, `dead`, `consoleErrors`, `networkErrors`, `url`, `device`, `browser`, `os`, `country`, `platform`, `mode`, `playlist`, `order`, `friction` |

```bash
curl "https://apphelm.dev/api/v1/sessions?productId=prd_…&errors=1&limit=20" \
  -H "Authorization: Bearer $APPHELM_API_KEY"
```

Node.js:
```ts
const sessions = await apphelm.searchSessions({ productId: "prd_…", errors: true, limit: 20 });
```

The [MCP server](https://apphelm.dev/docs/mcp) has `apphelm_search_sessions` (with `sessions:read`). There is no CLI command for replay. See the [API reference](https://apphelm.dev/docs/api) under Sessions.

To delete a person's recordings, use privacy deletion (`POST /api/v1/privacy/delete`, `privacy:write`): by distinct id it removes the recordings their events reference or that share their session (up to 500 per call), and by profile it removes the profile's recordings. There is no endpoint to delete one recording. See [Privacy, consent and data controls](https://apphelm.dev/docs/privacy).

## What replay doesn't do

- No server SDK (Node, Python, Go, Ruby, PHP, .NET, Rust, Elixir) records replays.
- No pixels or video on any platform.
- Flutter web and desktop, and Jetpack Compose content, aren't recorded (Compose shows as one box).
- Sentry SDK replay data sent to AppHelm is dropped; use AppHelm's replay instead. See [Migrate from Sentry](https://apphelm.dev/docs/migrate-sentry).
- In the browser there is no call to start or stop recording, or to read the replay id; use consent, `sampleRate`, `linkedFlag` and `urlTriggers`.

## Check it works

### Give consent
In your app, accept your consent banner, or call `setConsent({ analytics: true, replay: true })` (`setReplayConsent(true)` on mobile) from the console or a debug build.

### Use the page for a few seconds
Click and scroll on a page that isn't in the blocked list. The browser uploads every 5 seconds and when the page is hidden; mobile uploads every few seconds and when the app goes to the background.

### Open Session replay
The recording appears in the list after its first upload. Open it and check that inputs show asterisks and that your blocked elements are boxes.

### Check the network tab
In the browser's developer tools, requests to `/api/replay` should answer `202`. Any other answer is in the troubleshooting table below.

## Best practices

- **Ask for replay consent separately** from analytics, and say what is recorded.
- **Mask personal data on the page** with `data-apphelm-mask`, or set `maskAllText: true` in apps that show customer records.
- **Block whole areas** (account numbers, documents) with `.apphelm-no-capture` rather than masking them piece by piece.
- **Add your own sensitive paths** to `blockedPaths`, nested ones such as `/settings/billing` in particular.
- **Sample when traffic is high**: lower `sampleRate` and set `onErrorSampleRate: 1`, so the sessions you most want are still recorded.
- **Check the console and network panels** of a test recording before going live, especially if you turn on `recordHeaders` or `recordBody`.

## Troubleshooting

| Symptom | Likely cause | What to do |
| --- | --- | --- |
| No recordings at all | No replay consent, or no analytics consent, or Global Privacy Control is on | Call `setConsent({ analytics: true, replay: true })` after the person agrees; with GPC on, nothing is recorded by design |
| `/api/replay` answers 401 `invalid_project_key` | The key isn't a project key (`ahl_pub_…`), or the page's origin isn't allowed for it | Use the project key, and add the origin in Settings → Keys |
| 403 `scope_mismatch` | `workspaceId` or `productId` don't belong to the key | Use the ids from the key's product |
| 429 `replay_limit` | The month's recordings are used up | Wait for the next month, lower `sampleRate`, or raise the plan |
| 429 `rate_limited` | Too many requests from one address or key | The SDK retries after the wait |
| 202 with `collection_paused` | Collection is paused for the product | Resume collection for the product in AppHelm |
| 422 `invalid_replay_chunk` | Often a navigation to a path the server blocks, such as `/settings/billing` | Add the path to `blockedPaths` |
| 422 `invalid_start_time` | The device clock is far off | Recordings must start no more than 5 minutes ahead and 26 hours back |
| 413 `chunk_too_large` | A very large page or canvas | Block the large element, or turn `recordCanvas` off |
| Recording stops on some pages | The path is in the blocked list | Expected; recording resumes on the next allowed page |
| Recordings never start with `linkedFlag` or `urlTriggers` | The flag is off for the person, the address never matched, or you use schematic mode, which ignores both | Check the flag, test the trigger against `location.href`, or use DOM mode |
| Short sessions are missing | `minimumDurationMs` is set | Lower it |
| Text you expected to be hidden is visible | Page text is recorded by default (input values and `contenteditable` text are masked) | Add a mask class or `maskSelector`, or set `maskAllText: true` |
| React Native records nothing | Expo Go, a JavaScript reload without a rebuild, or no `surveyKey`/`projectKey` | Rebuild the app with the native module, and set the project key and origin |
| A mobile screen is never recorded | Its name matches a blocked screen | Rename it, or accept that sign-in, billing, checkout, payment and admin screens are skipped |
