Client-side SDKs
This feature is available in the observability plugin for the following client-side SDKs:Mobile SDKs
This feature is available in the observability plugin for the following mobile SDKs:JavaScript
Expand JavaScript code sample
Expand JavaScript code sample
The session replay plugin supports the following features. After the SDK and session replay plugin are initialized, you can access these from within your application.
If you need additional customization, you can define a function to edit or remove data in request/response pairs, and include the function in the The session replay plugin and the observability plugin each have their own To learn more, read To learn more, read To learn more, read Use session properties to attach metadata to sessions that you want to search or filter by later, without cluttering the timeline with track events.To learn more, read Inlining may negatively affect performance, so we only recommend setting these options if you are encountering issues with client-local stylesheets or images. Turning the settings on can also trigger CORS errors. To learn more, read:For WebGL canvas recording, the If your application is deployed into a cross-origin iframe of a parent application that you do not control, set the
Privacy
When you configure the plugin options, you can choose from the following privacy settings:- set
privacySettingtodefaultto obfuscate all inputs and any text that matches commonly used regex expressions for personally identifiable information (PII). - set
privacySettingtostrictto obfuscate all HTML DOM text and images. - set
privacySettingtononeif you don’t want to obfuscate anything.
strict privacy mode is enabled. This provides the safest option as no PII should be captured, but it may limit session replay usability.With default privacy mode, the plugin obfuscates all inputs and any text that matches commonly used regex expressions for personally identifiable information (PII). This functionality offers a base level protection from recording info such as addresses, phone numbers, social security numbers, and more. It does not obfuscate any images or media content. It may obfuscate other, non-PII text if that text matches the expressions that the plugin is using.Expand Regex expressions used in default privacy mode
Expand Regex expressions used in default privacy mode
Here are the regex expressions that the plugins use when
privacySetting is set to default:networkRecording.requestResponseSanitizer option in the plugin. To learn more, read RequestResponsePair and HighlightOptions.In addition to setting the privacySetting for the plugins, you can also make adjustments at the HTML element level:- Add
className="highlight-block"to elements that should be ignored. When the session recording is replayed, an empty placeholder replaces the content. - Add
className="highlight-mask"to obfuscate specific HTML elements. - Add
className="highlight-ignore"to input elements to preserve the styling of the input element, but ignore all end user input. This class is only available for<input>elements. - When
privacySettingisdefault, you can override obfuscation on a per HTML element basis by adding thedata-hl-record="true"attribute to the recorded HTML tag.
- Set
maskTextClassto specify a custom class name or RegExp for masking text elements. Default is'highlight-mask'. - Set
maskTextSelectorto specify a CSS selector for masking text elements and their descendants. - Set
ignoreClassto specify a custom class name for ignoring input elements. Default is'highlight-ignore'. - Set
ignoreSelectorto specify a CSS selector for ignoring input elements. - Set
blockClassto specify a custom class name or RegExp for blocking elements completely. Default is'highlight-block'. - Set
blockSelectorto specify a CSS selector for blocking elements completely.
Record network request headers and bodies
By default, the session replay Network tab shows the URL, method, status, timing, and size of each request. To also show request and response headers and bodies, set thenetworkRecording option on the session replay plugin:networkRecording option. The session replay plugin’s option controls what appears in the session replay Network tab. The observability plugin’s option controls what is attached to traces. To record headers and bodies in both places, set the option on both plugins.The session replay plugin supports the same redaction options as the observability plugin: networkHeadersToRedact, networkBodyKeysToRedact, headerKeysToRecord, bodyKeysToRecord, urlBlocklist, and requestResponseSanitizer. To learn more, read Recording network requests and WebSocket events.Record canvas
The session replay plugin can record a snapshot bitmap of anHTMLCanvasElement for WebGL capture.To set this up, pass the following options when you initialize the plugin:snapshot.Retrieve session URLs on the client
The session replay plugin also provides options for retrieving details about the current recorded session. This can be useful for building a custom integration with the session replay data.getSession returns details of the current recording session, including a URL to view the session, and a URL for the exact time the method is called, relative to the session recording. For example, suppose an error is thrown in your app and you want to save the session URL to another application. You can use the session details urlWithTimestamp to set the player to the time when the error occurs.Here’s how:getSession.To determine whether the current session is recording, use getRecordingState:getRecordingState.Add session properties
UseLDRecord.addSessionProperties() to add custom session-level properties. These properties are attached to the current session and are searchable in LaunchDarkly, but unlike track() events, they do not create timeline events.Call this after the session has started. If you start sessions manually, wait for LDRecord.start() to complete before adding properties so they are recorded correctly.Here’s how:addSessionProperties.Record styles, images, and videos
When you configure the plugin options for the session replay plugin, you can explicitly request to inline stylesheets, images, or videos into the recording. This means that assets that are local to the client are serialized into the session replay recording and will be valid on replay. Some common reasons to turn on these settings include: firewall blocking CSS stylesheet access at time of replay,<video> tags that reference blob: in-memory video streams, and images that are transformed client-side.Here’s how:Canvas and WebGL
When you configure the plugin options for the session replay plugin, you can set up recording of<canvas> elements. This includes <canvas> elements that use WebGL.Here’s how:canvasManualSnapshot option is used to enable manual capture of the canvas. This is necessary to avoid capturing the WebGL buffer while it is no longer in memory.The samplingStrategy options include the following:samplingStrategy.canvasis the frame per second rate used to record the HTML canvas with automated recording. This is the recommended default approach. We recommend using a value of less than 5 to ensure the recording is not too large and does not have issues with playback.samplingStrategy.canvasManualSnapshotis the frame per second rate used in manual snapshotting mode. Manual mode may be necessary in some cases, especially for WebGL applications.samplingStrategy.canvasFactoris the resolution scaling factor applied to both dimensions of the canvas.samplingStrategy.canvasMaxSnapshotDimensionis the maximum recording resolution of the largest dimension of the canvas.samplingStrategy.canvasClearWebGLBufferdisables WebGL buffer clearing when set tofalse. This may help if the canvas flickers when recording.samplingStrategy.canvasInitialSnapshotDelayis the time in milliseconds to wait before the initial snapshot of canvas/video elements.
snapshot:Working with iframes
You can record<canvas> elements within an <iframe>. However, you should be aware of the following caveats:- The iframe will not load if the source’s origin has a restrictive
X-Frame-Optionsheader. - If the iframe source becomes invalid after some time, or does not render content when inserted into a different domain, the session recording will not show the content that the end user saw.
iframe, you can record the events as a separate session.In some cases, you may need to record a cross-origin iframe. These are <iframe> elements in your application that reference a domain considered to be part of a different origin. When your iframe uses a src tag pointing to a different origin, the iframe is not accessible from the parent page. However, the iframe can still emit messages that the parent page can hear.To support cross-origin iframes, set the recordCrossOriginIframe option to true when you initialize the SDK in both the parent window and the iframe.Here’s how:recordCrossOriginIframe option to false. This starts the recording for the iframe in standalone mode, and records a session with just the contents of the iframe.To learn more, read recordCrossOriginIframe in HighlightOptions.Using a proxy
If your sessions are not appearing in LaunchDarkly, it may be that requests to LaunchDarkly are being blocked. This may be happening for any of several reasons, including third-party browser extensions, browser configuration, or VPN settings.If you have access to your domain’s DNS settings, you can set up a proxy from your domain to LaunchDarkly to avoid having requests blocked.Here’s how:-
On your domain, add two
CNAMErecords:- A
CNAMErecord that pointspub.ld.<your_domain>topub.observability.app.launchdarkly.com. - A
CNAMErecord that pointsotel.ld.<your_domain>tootel.observability.app.launchdarkly.com. This record is optional if you are only using the session replay plugin, but required if you are also using the observability plugin.
<your_domain>, your DNS records will pointpub.ld.<your_domain>andotel.ld.<your_domain>to the LaunchDarkly servers. - A
-
In your application, set the
backendUrloption when you configure the observability plugin. Set thebackendUrloption topub.ld.<your_domain>. Here’s how:
React Web
Expand React Web code sample
Expand React Web code sample
The session replay plugin supports the following features. After the SDK and session replay plugin are initialized, you can access these from within your application.To learn more, read Then, start session replay yourself:To stop session replay:To learn more, read To learn more, read To learn more, read Use session properties to attach metadata to sessions that you want to search or filter by later, without cluttering the timeline with track events.To learn more, read
Record canvas
The session replay plugin can record a snapshot bitmap of anHTMLCanvasElement for WebGL capture.To set this up, pass the following options when you initialize the plugin:snapshot.Manually control session recording
By default, sessions are automatically recorded after you initialize the session replay plugin. If you want to control recording manually, setmanualStart to true in the plugin options:LDRecord.start is asynchronous
LDRecord.start() returns a Promise.
You must wait for the session to start before calling other session methods such as addSessionProperties() or getSession(). Otherwise, session data may not be recorded.start and stop.Retrieve session URLs on the client
The session replay plugin also provides options for retrieving details about the current recorded session. This can be useful for building a custom integration with the session replay data.getSession returns details of the current recording session, including a URL to view the session, and a URL for the exact time the method is called, relative to the session recording. For example, suppose an error is thrown in your app and you want to save the session URL to another application. You can use the session details urlWithTimestamp to set the player to the time when the error occurs.Here’s how:getSession.To determine whether the current session is recording, use getRecordingState:getRecordingState.Add session properties
UseLDRecord.addSessionProperties() to add custom session-level properties. These properties are attached to the current session and are searchable in LaunchDarkly, but, unlike track() events, they do not create timeline events.Call this after the session has started. If you are manually starting sessions, wait for LDRecord.start() to complete first.addSessionProperties.Vue
Expand Vue code sample
Expand Vue code sample
The session replay plugin supports the following features. After the SDK and session replay plugin are initialized, you can access these from within your application.Then, start session replay yourself:To stop session replay:To learn more, read To learn more, read To learn more, read Use session properties to attach metadata to sessions that you want to search or filter by later, without cluttering the timeline with track events.To learn more, read
Record canvas
The session replay plugin can record a snapshot bitmap of anHTMLCanvasElement for WebGL capture.To set this up, pass the following options when you initialize the plugin:Manually control session recording
By default, sessions are automatically recorded after you initialize the session replay plugin. If you want to control recording manually, setmanualStart to true in the plugin options:LDRecord.start is asynchronous
LDRecord.start() returns a Promise.
You must wait for the session to start before calling other session methods such as addSessionProperties() or getSession(). Otherwise, session data may not be recorded.start and stop.Retrieve session URLs on the client
The session replay plugin also provides options for retrieving details about the current recorded session. This can be useful for building a custom integration with the session replay data.getSession returns details of the current recording session, including a URL to view the session, and a URL for the exact time the method is called, relative to the session recording. For example, suppose an error is thrown in your app and you want to save the session URL to another application. You can use the session details urlWithTimestamp to set the player to the time when the error occurs.Here’s how:getSession.To determine whether the current session is recording, use getRecordingState:getRecordingState.Add session properties
UseLDRecord.addSessionProperties() to add custom session-level properties. These properties are attached to the current session and are searchable in LaunchDarkly, but, unlike track() events, they do not create timeline events.Call this after the session has started. If you are manually starting sessions, wait for LDRecord.start() to complete first.addSessionProperties.Android
Expand Android code sample
Expand Android code sample
The session replay plugin for Android supports the following features. After the SDK and session replay plugin are initialized, you can access these from within your application.
Privacy
The Android session replay plugin usesPrivacyProfile to control how UI elements are masked. By default, text inputs are masked. Session replay for Android uses Jetpack Compose semantics to identify and mask UI elements. Test thoroughly before releasing to ensure masking meets your requirements.Here’s how to configure privacy settings:Sensitive keywords
WhenmaskBySemanticsKeywords is enabled, the SDK automatically masks any Compose UI text or content descriptions containing predetermined keywords. Keywords you specify are not case-sensitive. For the most up to date set of keywords, read PrivacyProfile.Flutter
Expand Flutter code sample
Expand Flutter code sample
To learn how to install and initialize the session replay plugin, read Configure session replay in the Flutter SDK observability reference.Session replay for Flutter is supported only on iOS and Android. Session replay is not supported on web.The session replay plugin for Flutter supports the following features:The available privacy options are:
Privacy
Enable session replay and configure privacy options by passingSessionReplayOptions to LDObserve.init or LDObserve.initStandalone:- maskTextInputs: Masks all text input fields. Defaults to
true. - maskWebViews: Masks the contents of web views. Defaults to
false. - maskLabels: Masks all text labels. Defaults to
false. - maskImages: Masks all images. Defaults to
false. - minimumAlpha: The opacity threshold, from
0.0to1.0, below which the plugin treats a widget as invisible and skips it during capture and masking. Defaults to0.02. - maskClickText: Drops the visible label from click events. Taps report the widget type and identifier but no text. Defaults to
false. This option is independent ofmaskLabels, which controls whether the plugin paints over text in captured frames. To learn more, read Record taps.
Per-widget masking
UseLDMask to redact an individual widget’s subtree in all captured frames, LDIgnore to exclude a subtree from session replay entirely, and LDUnmask to exempt a subtree from global masking rules:LDUnmask only overrides global masking rules. It does not override an explicit LDMask or LDIgnore.You can also match widgets by Type or Key instead of wrapping them, using the maskWidgetTypes, maskWidgetKeys, unmaskWidgetTypes, unmaskWidgetKeys, ignoreWidgetTypes, and ignoreWidgetKeys options in PrivacyOptions. To learn more, read Mask by widget type or key.Capture options
On Android and iOS,SessionReplayOptions also accepts several capture options. sampleRate is the probability from 0.0 to 1.0 that session replay starts when enabled. frameRate is the target capture rate in frames per second. scale is the resolution multiplier for captured frames. sampleRate, frameRate, and scale default to 1.0. imageQuality is the JPEG encoding quality of exported frames, from 0.0 (lowest quality, smallest payload) to 1.0 (highest quality, largest payload), and defaults to 0.3. To learn more, read Session replay configuration options.React Native
Expand React Native code sample
Expand React Native code sample
The session replay plugin for React Native supports the following features. After the SDK and session replay plugin are initialized, you can access these from within your application.Session replay for React Native is available on iOS and Android. To learn how to install and initialize the plugin, read Configure session replay in the React Native SDK observability reference.The available privacy options are:To learn more, read Initialize session replay manually in the React Native SDK observability reference.
Privacy
The React Native session replay plugin masks UI elements through options passed tocreateSessionReplayPlugin or configureSessionReplay. By default, text inputs are masked.For each view, the SDK evaluates these rules in order and stops at the first that applies:- Explicit masking (highest priority): The view, or any of its ancestors, is wrapped in
<LDMask>or has atestIDmatched bymaskTestIDs. - Explicit unmasking: The view, or any of its ancestors, is wrapped in
<LDUnmask>or has atestIDmatched byunmaskTestIDs. - Global configuration: The global privacy options (
maskTextInputs,maskLabels,maskImages,maskWebViews) apply.
- maskTextInputs: When
true, masks all<TextInput>components. Defaults totrue. - maskWebViews: When
true, masks the contents of<WebView>components. Web views are rendered as blank rectangles in session replays. Defaults tofalse. - maskLabels: When
true, masks all<Text>components. Defaults tofalse. - maskImages: When
true, masks all<Image>components. Defaults tofalse. - maskTestIDs: Masks an array of
testIDvalues. Matches use exact string equality. Applied on iOS and Android. - unmaskTestIDs: Excludes an array of
testIDvalues from masking. Matches use exact string equality. Applied on iOS and Android. - minimumAlpha (iOS only): Minimum alpha value for view visibility in recordings. Defaults to
0.02.
testID, wrap it in <LDMask>. <LDMask> propagates to all its descendants. After you wrap a subtree in <LDMask>, nothing inside of it can opt out of masking.Manually control session recording
By default, session recording starts when the plugin registers. To control recording manually, setisEnabled to false in the plugin options, then call startSessionReplay() when you are ready. startSessionReplay() starts recording regardless of the configured isEnabled value, and recording continues until you call stopSessionReplay(). Deferred recording requires session replay plugin version 0.24.0 or later.Here is an example: