Session replay plugin
The LaunchDarkly observability features are available for early access
Observability features in the LaunchDarkly UI are only available in early access for customers on select plans. To request early access, navigate to Sessions, Errors, Logs, or Traces in the LaunchDarkly UI and join the waitlist.
The SDK session replay plugin is designed for use with the in-app observability features. It is currently in an alpha version.
Overview
This topic documents how to get started with the LaunchDarkly session replay plugin, which is compatible with the LaunchDarkly client-side JavaScript-based SDKs.
SDK quick links
LaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:
For use in client applications only
This session replay plugin is for LaunchDarkly client-side JavaScript-based browser SDKs.
To learn more about LaunchDarkly’s different SDK types, read Client-side, server-side, and edge SDKs.
Prerequisites and dependencies
This reference guide assumes that you are somewhat familiar with the LaunchDarkly JavaScript SDK.
The session replay plugin is compatible with the JavaScript SDK, version 3.7.0 and later.
Most customers who use the session replay plugin also use the observability plugin. However, there is no dependency between the plugins, and you can use only one or the other if you like.
Get started
Follow these steps to get started using the observability plugin:
- Install the plugin
- Initialize the SDK client
- Configure the plugin options
- Explore supported features
- Review session replays in LaunchDarkly
Install the plugin
LaunchDarkly uses a plugin to the JavaScript SDK to provide observability.
The first step is to make both the SDK and the session replay plugin available as dependencies.
The observability plugin is available separately. To learn more, read Observability plugin.
Here’s how:
Then, import the plugin into your code:
Initialize the client
Next, initialize the SDK and the session replay plugin. As usual, you’ll need your LaunchDarkly environment’s client-side ID for this. To learn more, read Initialize the client in the JavaScript SDK reference guide.
You will also need your observability project ID. To request your observability project ID, start a Support ticket or contact your LaunchDarkly account representative.
Here’s how:
You can also initialize the plugin before you initialize the SDK if you like. This may be helpful if you need observability data very early in your application’s lifecycle.
Here’s how:
Finally, you can optionally register the plugin after you initialize the SDK:
We do not recommend this option because you will miss observability data generated before you register the plugin.
Configure the plugin options
You can configure options for the session replay plugin when you initialize the SDK if you like. The plugin constructor takes an optional object with the configuration details.
Here is an example:
For more information on plugin options, read Client-side observability.
Explore supported features
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. The plugin hooks into your WebGL render function after you paint to the WebGL context.
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
.
Record sessions
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
.
Get session information
The session replay plugin also provides options for retrieving information about the recorded sessions.
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
:
Review session replays in LaunchDarkly
After you initialize the SDK and session replay plugin, your application automatically starts sending session replay data back to LaunchDarkly. You can review this information in the LaunchDarkly user interface. To learn how, read Observability and Session replays.