Mobile Session Replay Setup and Configuration

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Setup

All Session Replay SDK versions can be found in the Maven Snapshots Repository.

To set up Mobile Session Replay for Android:

  1. Make sure you’ve setup and initialized the Datadog Android RUM SDK with views instrumentation enabled.

  2. Declare the Datadog Session Replay as a dependency:

build.gradle

    implementation("com.datadoghq:dd-sdk-android-rum:[datadog_version]")
    implementation("com.datadoghq:dd-sdk-android-session-replay:[datadog_version]")
    // in case you need material support
    implementation("com.datadoghq:dd-sdk-android-session-replay-material:[datadog_version]")
   
  1. Enable Session Replay in your app:

Application.kt

   val sessionReplayConfig = SessionReplayConfiguration.Builder([sampleRate])
    // in case you need material extension support
    .addExtensionSupport(MaterialExtensionSupport()) 
    .build()
   SessionReplay.enable(sessionReplayConfig)
   

To set up Mobile Session Replay for iOS:

  1. Make sure you’ve set up and initialized the Datadog iOS RUM SDK with views instrumentation enabled.

  2. Link the Datadog Session Replay library to your project based on your package manager:

    Package managerInstallation step
    CocoaPodsAdd pod 'DatadogSessionReplay' to your Podfile.
    Swift Package ManagerAdd DatadogSessionReplay library as a dependency to your app target.
    CarthageAdd DatadogSessionReplay.xcframework as a dependency to your app target.
  3. Enable Session Replay in your app:

AppDelegate.swift

   import DatadogSessionReplay

   SessionReplay.enable(
       with: SessionReplay.Configuration(
           replaySampleRate: sampleRate
       )
   )
   

Additional configuration

Set the sample rate for recorded sessions to appear

Sample rate is a required parameter in Session Replay configuration. It must be a number between 0.0 and 100.0, where 0 means no replays will be recorded and 100 means all RUM sessions will contain replay.

This sample rate is applied in addition to the RUM sample rate. For example, if RUM uses a sample rate of 80% and Session Replay uses a sample rate of 20%, it means that out of all user sessions, 80% will be included in RUM, and within those sessions, only 20% will have replays.

Application.kt

val sessionReplayConfig = SessionReplayConfiguration.Builder([sampleRate])
 ...
.build()

AppDelegate.swift

var sessionReplayConfig = SessionReplay.Configuration(
    replaySampleRate: sampleRate
)

Validate whether Session Replay data is being sent

To validate whether Session Replay data is being sent from the app, you can enable debug option in Datadog SDK:

Application.kt

Datadog.setVerbosity(Log.DEBUG)

AppDelegate.swift

Datadog.verbosityLevel = .debug

If everything is fine, following logs should appear in the Xcode debug console in about 30 seconds after launching the app:

Xcode console

[DATADOG SDK] 🐶 → 10:21:29.812 ⏳ (session-replay) Uploading batch...
[DATADOG SDK] 🐶 → 10:21:30.442    → (session-replay) accepted, won't be retransmitted: [response code: 202 (accepted), request ID: BD445EA-...-8AFCD3F3D16]

Privacy options

See Privacy Options.

Further reading