Record and watch session replays
Turn on session replays for a project, add the Sentry browser SDK's replay integration with everything masked, then watch what a user did before an error, delete a replay, or erase one user's replays.
A session replay is a recording of what a user saw and did on your page: the page as it was drawn,
clicks, scrolling, page changes, console lines and network calls. The Sentry browser SDK records
it with replayIntegration(); App Monitoring keeps it next to the errors it recorded, so an issue
can open the replay at the moment of its error. Replace project-id with the project's id and
replay-id with a replay's id.
A replay is personal data. Read Tell your users before you turn it on.
Prerequisites
- Permission for
errors:UpdateProjecton the project to turn replays on. - In the console, also
errors:ListProjectson the project to open it (without it the project is not found). - Permission for
errors:ListReplayson the project to list replays, anderrors:GetReplayto watch one. The generated read-only policy lists replays but cannot watch them: watching is a sensitive read, and each replay opened is recorded in the audit log. - Permission for
errors:DeleteReplayson the project to delete a replay or erase a user's replays. - The Sentry browser SDK (
@sentry/browser,@sentry/nextjs,@sentry/reactand the other browser SDKs), version 8 or later.
Turn on session replays
Replays are off for a new project. While they are off, the ingest answers the SDK's replay with a
rate limit that stops its recording, keeps nothing, and counts the segments as filtered
(replays_off) on the project's Stats tab.
- Open the project, then Settings.
- Under Session replays, turn on Keep session replays.
- (Optional) Under Replay retention, choose 7, 14 (the default) or 30 days.
- Choose Save.
dcloud errors projects update project-id --replays-enabled true --replay-retention-days 14PATCH /errors/api/projects/project-id
Content-Type: application/json
{ "replaysEnabled": true, "replayRetentionDays": 14 }Add the replay integration
Add replayIntegration() where the SDK starts in the browser (for Next.js,
instrumentation-client.ts). The project's Setup tab has this snippet with your DSN.
Sentry.init({
dsn: '…',
integrations: [
Sentry.replayIntegration({
maskAllText: true,
maskAllInputs: true,
blockAllMedia: true,
}),
],
// Keep the minute before every error; record no whole sessions.
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0,
});maskAllText,maskAllInputsandblockAllMediaare the SDK's defaults; writing them out keeps anyone from turning them off unseen. Text is replaced by*, inputs are never recorded, images and videos are blank boxes.replaysOnErrorSampleRatekeeps up to the last minute before an error, and the rest of that session from then on.replaysSessionSampleRaterecords whole sessions from the start; 0.1 records one session in ten.- The SDK leaves request and response bodies and headers out unless you list URLs in
networkDetailAllowUrls.
Before anything is stored, App Monitoring removes Authorization, Cookie and other credential
headers, the values of query parameters and body fields whose names say secret (token,
password, session, api_key and the like), and the sender's IP address unless the project
keeps client addresses. Page addresses in the replay list are shown without their query.
Watch a replay
- Open the project, then the Replays tab. The list follows the environment and range of the bar above it; search by user or page, or turn on Only with errors.
- Choose a replay. Use Play, the speed buttons and Skip inactivity; choose a line under Timeline (Errors, Console, Network, Pages) to jump to it.
From an issue, choose Watch the replay on its event: the replay opens five seconds before the error.
dcloud errors replays list project-id --with-errors 1
dcloud errors replays get project-id replay-idGET /errors/api/projects/project-id/replays?withErrors=1GET /errors/api/projects/project-id/replays/replay-idOpening a replay answers with a playbackGrant valid for 15 minutes; its recording is read 30
segments at a time with that grant (…/replays/replay-id/segments?grant=…&from=0), as
rrweb events any rrweb player can replay.
Delete a replay or erase a user's replays
Deleting hides a replay at once; its recording is deleted within 10 minutes. Erasing deletes every replay recorded with that user id, email, username or IP address in any of its segments, and every replay in which an error event of that user happened. An IP address can match other people behind the same address.
- Open the replay, choose Delete replay, then Delete.
dcloud errors replays delete project-id replay-id
dcloud errors replays erase project-id --email user@example.comPOST /errors/api/projects/project-id/replays/erase
Content-Type: application/json
{ "email": "user@example.com" }Replays past the project's replay retention are deleted the same way, and a deleted project's replays go with it.
Tell your users
Under the GDPR you are the controller of the replays your SDK sends; Deutsche Cloud processes them on your behalf in Germany. Before you record:
- Say in your privacy notice that sessions on your site may be recorded to find and fix errors, which data that covers (pages visited, clicks and the page as drawn, with text and inputs masked), how long it is kept (your replay retention) and who can watch it.
- Name the legal basis you rely on. If your recording is not strictly necessary for the service
the user asked for, ePrivacy rules (in Germany § 25 TDDDG) may require consent before the SDK
starts: start it, or call
Sentry.getReplay()?.start(), only after consent. - Answer an erasure request with erase, above.
Price and limits
A replay is billed once, when its first segment is stored, whatever its length: the first 500 of
every month are free, then €2.50 per 1 000. Its stored bytes count toward the organization's
App Monitoring storage. Replays have their own quotas (errors.replays-per-month,
errors.replay-segments-per-minute); a refused replay stops that recording and errors keep
flowing (see Quotas).