Configuration

General Integration Configuration

The following options can be configured on the root level of your browser-based Sentry SDK, in init({}):

KeyTypeDefaultDescription
replaysSessionSampleRatenumber0The sample rate for replays that begin recording immediately and last the entirety of the user's session. 1.0 collects all replays, and 0 collects none.
replaysOnErrorSampleRatenumber0The sample rate for replays that are recorded when an error happens. This type of replay will record up to a minute of events prior to the error and continue recording until the session ends. 1.0 captures all sessions with an error, and 0 captures none.

The following can be configured as integration options in new Replay({}):

KeyTypeDefaultDescription
stickySessionbooleantrueKeep track of users across page loads. Note, because closing a tab ends the session, a single user using multiple tabs will be recorded as multiple sessions.
mutationLimitnumber10000The upper bound of mutations to process before Session Replay stops recording due to performance impacts. See Mutation Limits
mutationBreadcrumbLimitnumber750The upper bound of mutations to process before Session Replay sends a breadcrumb to warn of large mutations. See Mutation Limits
minReplayDurationnumber5000The length of the replay, in milliseconds, before the SDK should start sending to Sentry. Max value is 15000.
networkDetailAllowUrls(string | RegExp)[][]Capture request and response details for XHR and fetch requests that match the given URLs.
networkCaptureBodiesbooleantrueDecide whether to capture request and response bodies for URLs defined in networkDetailAllowUrls.
networkRequestHeadersstring[][]Additional request headers to capture for URLs defined in networkDetailAllowUrls. See Network Details to learn more.
networkResponseHeadersstring[][]Additional response headers to capture for URLs defined in networkDetailAllowUrls. See Network Details to learn more.
beforeAddRecordingEvent(event) => event | nulli => iFilter additional recording events that include console logs and network requests/responses.

Privacy Configuration

We take privacy seriously, so we provide a number of privacy-oriented settings. Learn more about these in our our Session Replay privacy documentation.

The following options can be configured as options to the integration, in new Replay({}):

keytypedefaultdescription
maskstring[].sentry-mask, [data-sentry-mask]Mask all elements that match the given DOM selectors. See Masking section for an example. Note that any configured selectors will be in addition to the defaults.
maskAllTextbooleantrueMask all text content. Will pass text content through maskFn before sending to server.
maskAllInputsbooleantrueMask values of <input> elements. Passes input values through maskFn before sending to server.
blockstring[].sentry-block, [data-sentry-block]Redact all elements that match the DOM selector(s). See Blocking section for an example. Note that any configured selectors will be in addition to the defaults.
blockAllMediabooleantrueBlock all media elements (img, svg, video, object, picture, embed, map, audio).
ignorestring[].sentry-ignore, [data-sentry-ignore]Ignores all events on the matching input fields. See Ignoring above for an example.
maskFn(text: string) => string(text) => '*'.repeat(text.length)Function to customize how text content is masked before sending to server. By default, masks text with *.
unblockstring[].sentry-unblock, [data-sentry-unblock]Don't redact any elements that match the DOM selectors. Used to unblock specific media elements that are blocked with blockAllMedia. This doesn't affect sensitive elements such as password.
unmaskstring[].sentry-unmask, [data-sentry-unmask]Unmask all elements that match the given DOM selectors. Used to unmask specific elements that are masked with maskAllText.

Sampling

To learn more about how session sampling works, check out our Default Session Initialization docs.

Network Details

By default, Replay will capture basic information about all outgoing fetch and XHR requests in your application. This includes the URL, request and response body size, method, and status code. The intention is to limit the chance of collecting private data.

To capture additional information such as request and response headers or bodies, you'll need to opt-in via networkDetailAllowUrls (requires SDK version >= 7.50.0). This will make it possible for you to elect to only add URLs that are safe for capturing bodies and avoid any endpoints that may contain Personal Identifiable Information, (PII).

Any URL matching the given pattern(s) will then be captured with additional details:

Copied
new Replay({
  networkDetailAllowUrls: [window.location.origin],
});

If you give us a string, we'll match any URL that contains that string. You can use a regex to handle exact or more complex matches.

Requests to a URL matched by the configured patterns will be enhanced with the request and response body, as well as the following default headers:

  • Content-Type
  • Content-Length
  • Accept

If you want to capture additional headers, you'll have to configure them with the options networkRequestHeaders and networkResponseHeaders, for example:

Copied
new Replay({
  networkDetailAllowUrls: [
    window.location.origin,
    "api.example.com",
    /^https:\/\/api\.example\.com/,
  ],
  networkRequestHeaders: ["Cache-Control"],
  networkResponseHeaders: ["Referrer-Policy"],
});

Mutation Limits

Session Replay works by recording incremental DOM changes that occur in your web application. Generally these changes occur in small batches and cause minimal overhead. However, it can be easy to overlook cases that will cause a large amount of DOM mutations to happen in a single update. An example is a custom dropdown component that has an unbounded list of options to render. This can negatively impact performance without Session Replay and its effects will be magnified with Session Replay enabled. In order to avoid this scenario, Session Replay will stop recording if it detects a large number of mutations (default: 10,000), which can be configured by setting mutationLimit. Additionally, we provide breadcrumbs in the replay to warn you when a large number of mutations are detected (default: 750).

Copied
new Replay({
  mutationBreadcrumbLimit: 1000,
  mutationLimit: 1500,
});

Identifying Users

You can use the Sentry SDK to link a user to a session. Read more about it in our docs.

Copied
Sentry.setUser({ email: "jane.doe@example.com" });
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").