> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration for session replay

> This topic explains how to configure the SDK session replay plugin.

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

## Overview

This topic explains how to configure the SDK session replay plugin.

The session replay plugin supports several features, including privacy controls, WebGL capture (JavaScript SDKs), 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 available in JavaScript-based client-side SDKs and mobile 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 [Observability SDKs](/sdk/observability#observability-sdks).

Details about each SDK's configuration are available in the SDK-specific sections below:

* [Client-side SDKs](#client-side-sdks)
* [Mobile SDKs](#mobile-sdks)

## Client-side SDKs

This feature is available in the observability plugin for the following client-side SDKs:

* [JavaScript](#javascript)
* [React Web](#react-web)
* [Vue](#vue)

## Mobile SDKs

This feature is available in the observability plugin for the following mobile SDKs:

* [Android](#android)

### Java

Script

<Accordion title="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](/sdk/observability/javascript#configure-the-plugin-options), you can choose from the following privacy settings:

  * set `privacySetting` to `default` to obfuscate all inputs and any text that matches commonly used regex expressions for personally identifiable information (PII).
  * set `privacySetting` to `strict` to obfuscate all HTML DOM text and images.
  * set `privacySetting` to `none` 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.

  <Accordion title="Expand Regex expressions used in default privacy mode">
    Here are the regex expressions that the plugins use when `privacySetting` is set to `default`:

    <CodeGroup>
      ```title="Regex obfuscated when 'privacySetting' is 'default'" theme={null}
              Email: '[a-zA-Z0-9.!#$%&'*+=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*'
              SSN: '[0-9]{3}-?[0-9]{2}-?[0-9]{4}'
              Phone number: '[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,6}'
              Credit card: '[0-9]{4}-?[0-9]{4}-?[0-9]{4}-?[0-9]{4}'
              Unformatted SSN, phone number, credit card: '[0-9]{9,16}'
              Address: '[0-9]{1,5}.?[0-9]{0,3}\s[a-zA-Z]{2,30}\s[a-zA-Z]{2,15}'
              IP address: '(?:[0-9]{1,3}.){3}[0-9]{1,3}'
      ```
    </CodeGroup>
  </Accordion>

  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 `networkRecording.requestResponseSanitizer` option in the plugin. To learn more, read [`RequestResponsePair`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/modules/client.html#requestresponsepair) and [`HighlightOptions`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/types/client_types_types.HighlightOptions.html).

  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` is `default`, you can override obfuscation on a per HTML element basis by adding the `data-hl-record="true"` attribute to the recorded HTML tag.

  You can also customize the class names and selectors used for privacy settings:

  * Set `maskTextClass` to specify a custom class name or RegExp for masking text elements. Default is `'highlight-mask'`.
  * Set `maskTextSelector` to specify a CSS selector for masking text elements and their descendants.
  * Set `ignoreClass` to specify a custom class name for ignoring input elements. Default is `'highlight-ignore'`.
  * Set `ignoreSelector` to specify a CSS selector for ignoring input elements.
  * Set `blockClass` to specify a custom class name or RegExp for blocking elements completely. Default is `'highlight-block'`.
  * Set `blockSelector` to specify a CSS selector for blocking elements completely.

  Here's an example of using custom privacy classes:

  <CodeGroup>
    ```js title="Custom privacy classes example" theme={null}
          new SessionReplay({
            maskTextClass: 'my-mask-class',
            maskTextSelector: '[data-sensitive="true"]',
            ignoreClass: 'my-ignore-class', 
            ignoreSelector: '[data-ignore-input="true"]',
            blockClass: 'my-block-class',
            blockSelector: '[data-block="true"]'
          })
    ```
  </CodeGroup>

  #### 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:

  <Feature flag="docs-enable-browser-sdk-pkg" fallback={false} match={true}>
    <CodeGroup>
      ```js title="Recording options, JS Browser SDK v1" theme={null}
              const client = initialize('example-client-side-id', {
                sessionReplay: {
                  enableCanvasRecording: true, // enable canvas recording
                  samplingStrategy: {
                    canvas: 2, // snapshot at 2 fps
                    canvasMaxSnapshotDimension: 480, // snapshot at a max 480p resolution
                  },
                }
              });
      ```

      ```js title="Recording options, JS SDK v4.x" theme={null}
              const client = initialize('example-client-side-id', {
                plugins: [
                  new SessionReplay({
                    enableCanvasRecording: true, // enable canvas recording
                    samplingStrategy: {
                      canvas: 2, // snapshot at 2 fps
                      canvasMaxSnapshotDimension: 480, // snapshot at a max 480p resolution
                    },
                  })
                ]
              });
      ```

      ```js title="Recording options, JS SDK v3.7+" theme={null}
              const context = {
                kind: 'user',
                key: 'example-context-key'
              };

              const client = initialize('example-client-side-id', context, {
                plugins: [
                  new SessionReplay({
                    enableCanvasRecording: true, // enable canvas recording
                    samplingStrategy: {
                      canvas: 2, // snapshot at 2 fps
                      canvasMaxSnapshotDimension: 480, // snapshot at a max 480p resolution
                    },
                  })
                ]
              });
      ```
    </CodeGroup>
  </Feature>

  <Feature flag="docs-enable-browser-sdk-pkg" fallback={false} match={false}>
    <CodeGroup>
      ```js title="Recording options, JS SDK v4.x" theme={null}
              const client = initialize('example-client-side-id', {
                plugins: [
                  new SessionReplay({
                    enableCanvasRecording: true, // enable canvas recording
                    samplingStrategy: {
                      canvas: 2, // snapshot at 2 fps
                      canvasMaxSnapshotDimension: 480, // snapshot at a max 480p resolution
                    },
                  })
                ]
              });
      ```

      ```js title="Recording options, JS SDK v3.7+" theme={null}
              const context = {
                kind: 'user',
                key: 'example-context-key'
              };

              const client = initialize('example-client-side-id', context, {
                plugins: [
                  new SessionReplay({
                    enableCanvasRecording: true, // enable canvas recording
                    samplingStrategy: {
                      canvas: 2, // snapshot at 2 fps
                      canvasMaxSnapshotDimension: 480, // snapshot at a max 480p resolution
                    },
                  })
                ]
              });
      ```
    </CodeGroup>
  </Feature>

  To learn more, read [`snapshot`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#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:

  <CodeGroup>
    ```js title="Get session details" theme={null}
          LDRecord.getSession().then(({url, urlWithTimestamp}) => {
            console.log(url, urlWithTimestamp);
          });
    ```
  </CodeGroup>

  To learn more, read [`getSession`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#getsession).

  To determine whether the current session is recording, use `getRecordingState`:

  <CodeGroup>
    ```js title="Get session details" theme={null}
          // returns 'NotRecording' or 'Recording'
          const recordingState = LDRecord.getRecordingState();
    ```
  </CodeGroup>

  To learn more, read [`getRecordingState`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#getrecordingstate).

  #### Add session properties

  Use `LDRecord.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:

  <CodeGroup>
    ```js title="Add session properties" theme={null}
          LDRecord.addSessionProperties({
            plan: 'pro',
            favoriteColor: 'purple',
          });
    ```
  </CodeGroup>

  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 [`addSessionProperties`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#addsessionproperties).

  #### Record styles, images, and videos

  When you [configure the plugin options](/sdk/observability/javascript#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:

  <CodeGroup>
    ```js title="Inline options" theme={null}
          const options = {
            plugins: [
              new SessionReplay({
                  inlineStylesheet: true,
                  inlineImages: true,
                  inlineVideos: true,
                },
              })
            ]
          };
    ```
  </CodeGroup>

  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:

  * [`inlineStylesheet`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/types/client_types_types.HighlightOptions.html#default-9)
  * [`inlineImages`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/types/client_types_types.HighlightOptions.html#default-8)
  * [`inlineVideos`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/types/client_types_types.HighlightOptions.html#default-10)

  #### Canvas and Web

  GL

  When you [configure the plugin options](/sdk/observability/javascript#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:

  <CodeGroup>
    ```js title="Recording options" theme={null}
          const options = {
            plugins: [
              new SessionReplay({
                enableCanvasRecording: true, // enable canvas recording
                samplingStrategy: {
                  canvasManualSnapshot: 2, // snapshot at 2 fps
                  canvasMaxSnapshotDimension: 480, // snapshot at a max 480p resolution
                },
              })
            ]
          };
    ```
  </CodeGroup>

  For WebGL canvas recording, the `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.canvas` is 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.canvasManualSnapshot` is the frame per second rate used in manual snapshotting mode. Manual mode may be necessary in some cases, especially for WebGL applications.
  * `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 to `false`. 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.

  After you configure the plugin to your specifications, hook into your WebGL rendering code and call `snapshot`:

  <CodeGroup>
    ```js title="Record snapshot" theme={null}
          engine.runRenderLoop(() => {
            scene.render()
            LDRecord.snapshot(canvasElementRef.current)
          })
    ```
  </CodeGroup>

  ##### 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](https://learn.microsoft.com/en-us/skype-sdk/ucwa/cross_domainiframe). These are `<iframe>` elements in your application that reference a domain considered to be part of a [different origin](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy). 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:

  <CodeGroup>
    ```js title="Plugin options" theme={null}
          const options = {
            plugins: [
              new SessionReplay({
                recordCrossOriginIframe: true
              })
            ]
          };
    ```
  </CodeGroup>

  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`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/types/client_types_types.HighlightOptions.html).

  #### 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:

  1. On your domain, add two `CNAME` records:

     * A `CNAME` record that points `pub.ld.<your_domain>` to `pub.observability.app.launchdarkly.com`.
     * A `CNAME` record that points `otel.ld.<your_domain>` to `otel.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](/sdk/features/observability-config-client-side).

     Together, these records mean that if you have an app running at `<your_domain>`, your DNS records will point `pub.ld.<your_domain>` and `otel.ld.<your_domain>` to the LaunchDarkly servers.

  2. In your application, set the `backendUrl` option when you [configure the observability plugin](/sdk/observability/javascript#configure-the-plugin-options). Set the `backendUrl` option to `pub.ld.<your_domain>`.

     Here's how:

  <CodeGroup>
    ```js title="Plugin options" theme={null}
             // the examples assume your_domain is acme.com

             const options = {
               plugins: [
                 new SessionReplay({
                   backendUrl: 'https://pub.ld.acme.com',
                 })
               ]
             };
    ```
  </CodeGroup>
</Accordion>

### React Web

<Accordion title="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:

  <CodeGroup>
    ```js title="Recording options, React Web SDK v3.7+" theme={null}
          const LDProvider = withLDProvider({
            clientSideID: 'example-client-side-id',
            context,
            options: {
                plugins: [
                  new SessionReplay({
                    enableCanvasRecording: true, // enable canvas recording
                    samplingStrategy: {
                      canvas: 2, // snapshot at 2 fps
                      canvasMaxSnapshotDimension: 480, // snapshot at a max 480p resolution
                    },
                  })
                ]
            }
          })(App);
    ```
  </CodeGroup>

  To learn more, read [`snapshot`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#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:

  <CodeGroup>
    ```js title="Recording options, React Web SDK v3.7+" theme={null}
          const LDProvider = withLDProvider({
            clientSideID: 'example-client-side-id',
            context,
            options: {
              plugins: [
                new SessionReplay({ manualStart: true })
              ]
            }
          })(App);
    ```
  </CodeGroup>

  <Note title="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.
  </Note>

  Then, start session replay yourself:

  <CodeGroup>
    ```js title="Start recording" theme={null}
          await LDRecord.start({
            silent: false // if true, console.warn messages created in this method are skipped
          });
    ```
  </CodeGroup>

  To stop session replay:

  <CodeGroup>
    ```js title="Stop recording" theme={null}
          LDRecord.stop();
    ```
  </CodeGroup>

  To learn more, read [`start`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#start) and [`stop`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#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:

  <CodeGroup>
    ```js title="Get session details" theme={null}
          LDRecord.getSession().then(({url, urlWithTimestamp}) => {
            console.log(url, urlWithTimestamp);
          });
    ```
  </CodeGroup>

  To learn more, read [`getSession`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#getsession).

  To determine whether the current session is recording, use `getRecordingState`:

  <CodeGroup>
    ```js title="Get session details" theme={null}
          // returns 'NotRecording' or 'Recording'
          const recordingState = LDRecord.getRecordingState();
    ```
  </CodeGroup>

  To learn more, read [`getRecordingState`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#getrecordingstate).

  #### Add session properties

  Use `LDRecord.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.

  <CodeGroup>
    ```js title="Add session properties" theme={null}
          LDRecord.addSessionProperties({
            plan: 'pro',
            favoriteColor: 'purple',
          });

    ```
  </CodeGroup>

  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 [`addSessionProperties`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#addsessionproperties).
</Accordion>

### Vue

<Accordion title="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:

  <CodeGroup>
    ```js title="Recording options, Vue SDK v2.4+" theme={null}
          // main.js

          const app = createApp(App)
          app.use(LDPlugin, {
            clientSideID: 'example-client-side-id',
            options: {
              plugins: [
                new SessionReplay({
                  enableCanvasRecording: true, // enable canvas recording
                  samplingStrategy: {
                    canvas: 2, // snapshot at 2 fps
                    canvasMaxSnapshotDimension: 480, // snapshot at a max 480p resolution
                  },
              ]
            }
          })
          app.mount('#app')
    ```
  </CodeGroup>

  #### 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:

  <CodeGroup>
    ```js title="Recording options, Vue SDK v2.4+" theme={null}
          // main.js

          const app = createApp(App)
          app.use(LDPlugin, {
            clientSideID: 'example-client-side-id',
            options: {
              plugins: [
                new SessionReplay({ manualStart: true })
              ]
            }
          })
          app.mount('#app')
    ```
  </CodeGroup>

  <Note title="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.
  </Note>

  Then, start session replay yourself:

  <CodeGroup>
    ```js title="Start recording" theme={null}
          await LDRecord.start({
            silent: false // if true, console.warn messages created in this method are skipped
          });
    ```
  </CodeGroup>

  To stop session replay:

  <CodeGroup>
    ```js title="Stop recording" theme={null}
          LDRecord.stop();
    ```
  </CodeGroup>

  To learn more, read [`start`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#start) and [`stop`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#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:

  <CodeGroup>
    ```js title="Get session details" theme={null}
          LDRecord.getSession().then(({url, urlWithTimestamp}) => {
            console.log(url, urlWithTimestamp);
          });
    ```
  </CodeGroup>

  To learn more, read [`getSession`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#getsession).

  To determine whether the current session is recording, use `getRecordingState`:

  <CodeGroup>
    ```js title="Get session details" theme={null}
          // returns 'NotRecording' or 'Recording'
          const recordingState = LDRecord.getRecordingState();
    ```
  </CodeGroup>

  To learn more, read [`getRecordingState`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#getrecordingstate).

  #### Add session properties

  Use `LDRecord.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.

  <CodeGroup>
    ```js title="Add session properties" theme={null}
          LDRecord.addSessionProperties({
            plan: 'pro',
            favoriteColor: 'purple',
          });
    ```
  </CodeGroup>

  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 [`addSessionProperties`](https://launchdarkly.github.io/observability-sdk/packages/@launchdarkly/observability/interfaces/api_record.Record.html#addsessionproperties).
</Accordion>

### Android

<Accordion title="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 uses `PrivacyProfile` 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:

  <CodeGroup>
    ```kotlin title="Privacy profile configuration" theme={null}
          import com.launchdarkly.observability.replay.PrivacyProfile

          val ldConfig = LDConfig.Builder(AutoEnvAttributes.Enabled)
              .mobileKey("example-mobile-key")
              .plugins(
                Components.plugins().setPlugins(
                  listOf(
                    Observability(
                      this@BaseApplication,
                      Options(
                        instrumentations = listOf(
                          ReplayInstrumentation(
                            options = ReplayOptions(
                              privacyProfile = PrivacyProfile(
                                maskTextInputs = true,
                                maskText = false,
                                maskBySemanticsKeywords = true
                              )
                            )
                          )
                        )
                      )
                    )
                  )
                )
              )
              .build()
    ```
  </CodeGroup>

  ##### Sensitive keywords

  When `maskBySemanticsKeywords` 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`](https://github.com/launchdarkly/observability-sdk/blob/main/sdk/%40launchdarkly/observability-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/PrivacyProfile.kt).
</Accordion>
