Configuration for session replay
Overview
This topic explains how to configure the SDK session replay plugin.
The session replay plugin supports several features, including WebGL capture, manual control of session recording, and retrieving session URLs on the client. After the SDK and session replay plugin are initialized, you can access these features from within your application.
The session replay plugin is only available in JavaScript-based client-side SDKs. To get started with the session replay plugin, read the observability reference guide for your SDK. Use the docs site navigation on the left, or find your SDK under SDKs with observability support.
Details about each SDK’s configuration are available in the SDK-specific sections below:
Client-side SDKs
This feature is available in the observability plugin for the following client-side SDKs:
JavaScript
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.
Privacy
When you configure the plugin options, you can choose from the following privacy settings:
- set
privacySetting
todefault
to obfuscate all inputs and any text that matches commonly used regex expressions for personally identifiable information (PII). - set
privacySetting
tostrict
to obfuscate all HTML DOM text and images. - set
privacySetting
tonone
if you don’t want to obfuscate anything.
By default, 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
Here are the regex expressions that the plugins use when privacySetting
is set to default
:
If you need additional customization, you can define a function to edit or remove data in request/response pairs, and add include the function in the 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
class="highlight-block"
to elements that should be ignored. When the session recording is replayed, an empty placeholder replaces the content. - Add
class="highlight-mask"
to obfuscate specific HTML elements. - Add
class="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
privacySetting
isdefault
, you can override obfuscation on a per HTML element basis by adding thedata-hl-record="true"
attribute to the recorded HTML tag.
Record canvas
The session replay plugin can record a snapshot bitmap of an HTMLCanvasElement
for WebGL capture.
To set this up, pass the following options when you initialize the plugin:
Then, hook into your WebGL rendering code and call snapshot
:
To learn more, read 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:
To learn more, read getSession
.
To determine whether the current session is recording, use getRecordingState
:
To learn more, read getRecordingState
.
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:
The samplingStrategy
options include the following:
samplingStrategy.canvas
is the frame per second rate used to record the HTML canvas. 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.canvasManualSnapshot
is the frame per second rate used in manual snapshotting mode.samplingStrategy.canvasFactor
is the resolution scaling factor applied to both dimensions of the canvas.samplingStrategy.canvasMaxSnapshotDimension
is the maximum recording resolution of the largest dimension of the canvas.samplingStrategy.canvasClearWebGLBuffer
disables WebGL buffer clearing when set tofalse
. This may help if the canvas flickers when recording.samplingStrategy.canvasInitialSnapshotDelay
is the time in milliseconds to wait before the initial snapshot of canvas/video elements.
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-Options
header. - 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.
By default, LaunchDarkly only supports recording same-origin iframes. If you can initialize the SDK and observability plugin within the 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:
If your application is deployed into a cross-origin iframe of a parent application that you do not control, set the 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
CNAME
records:- A
CNAME
record that pointspub.ld.<your_domain>
topub.observability.app.launchdarkly.com
. - A
CNAME
record 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.
Together, these records mean that if you have an app running at
<your_domain>
, your DNS records will pointpub.ld.<your_domain>
andotel.ld.<your_domain>
to the LaunchDarkly servers. - A
-
In your application, set the
backendUrl
option when you configure the observability plugin. Set thebackendUrl
option topub.ld.<your_domain>
.Here’s how:
Plugin options
React Web
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.
Record canvas
The session replay plugin can record a snapshot bitmap of an HTMLCanvasElement
for WebGL capture.
To set this up, pass the following options when you initialize the plugin:
Then, hook into your WebGL rendering code and call snapshot
:
To learn more, read 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, set manualStart
to true
in the plugin options:
Then, start session replay yourself:
To stop session replay:
To learn more, read 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:
To learn more, read getSession
.
To determine whether the current session is recording, use getRecordingState
:
To learn more, read getRecordingState
.
Vue
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.
Record canvas
The session replay plugin can record a snapshot bitmap of an HTMLCanvasElement
for WebGL capture.
To set this up, pass the following options when you initialize the plugin:
Then, hook into your WebGL rendering code and call snapshot
:
To learn more, read 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, set manualStart
to true
in the plugin options:
Then, start session replay yourself:
To stop session replay:
To learn more, read 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:
To learn more, read getSession
.
To determine whether the current session is recording, use getRecordingState
:
To learn more, read getRecordingState
.