Skip to main content

Session replay

Session replay records what happened in the browser — DOM mutations, clicks, navigation, console — and plays it back next to the error it produced.

Setup​

import * as Sentry from "@sentry/browser";

Sentry.init({
dsn: "https://<public_key>@<your-errora-host>/<project_id>",
integrations: [
Sentry.replayIntegration({
maskAllText: true, // privacy defaults: on
blockAllMedia: true,
maskAllInputs: true,
}),
],
replaysSessionSampleRate: 0.1, // 10% of all sessions
replaysOnErrorSampleRate: 1.0, // 100% of sessions that hit an error
});

Two sample rates, deliberately:

  • replaysSessionSampleRate — ordinary browsing. Keep it low; every recorded session costs.
  • replaysOnErrorSampleRate — sessions where an error happened. Keep this at 1.0: this is the recording you will actually want to watch.

Privacy​

Replay records your users' screens, so treat it as sensitive by default:

ControlEffect
maskAllText: trueText nodes are replaced with blocks
maskAllInputs: trueInput values never leave the browser
blockAllMedia: trueImages/video are not recorded
class="sentry-mask"Mask one specific element
class="sentry-block"Do not record the element at all
class="sentry-ignore"Record the element but not interactions with it

Masking happens in the browser, before anything is sent. Turn masking off only for elements you have deliberately reviewed.

In the UI​

Replays lists recorded sessions with user, duration, error count, browser and OS. Open one for:

  • Playback of the rrweb recording with a timeline
  • Visited pages during the session
  • Errors raised in that session, linked to their issues
  • Linked traces, when tracing is on

From an issue, the Replay panel jumps straight to the moment the error happened. From user feedback, a replay_id does the same.

API​

GET /api/v1/projects/{project_id}/replays?stats_period=24h&limit=&offset=
GET /api/v1/projects/{project_id}/replays/{replay_id}
GET /api/v1/projects/{project_id}/replays/{replay_id}/events

Cost​

Replays are metered as the Session Replay service, per recorded session — the most expensive unit in the price list. Sampling is your cost control; see Wallet.

Troubleshooting​

SymptomCause / fix
No replays at allreplayIntegration() missing, or both sample rates are 0
Replays but no error linkageThe error was captured in a different session/tab, or replay started after the error
Blank/broken playbackCross-origin stylesheets can't be inlined — serve CSS from your own origin or allow CORS
Recording is hugeLong sessions on heavy DOMs; lower replaysSessionSampleRate and block noisy widgets with sentry-block
Sensitive data visibleMasking was turned off somewhere — audit mask* options and per-element classes