Declare the Datadog Session Replay as a dependency:
build.gradle.kts
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]")
Enable Session Replay in your app:
Application.kt
valsessionReplayConfig=SessionReplayConfiguration.Builder([sampleRate])// in case you need Material extension support
.addExtensionSupport(MaterialExtensionSupport()).build()SessionReplay.enable(sessionReplayConfig)
Add the DatadogSessionReplay iOS library as a link-only dependency. For instructions, see the guide.
Declare Datadog Session Replay as a dependency:
build.gradle.kts
kotlin{sourceSets{commonMain.dependencies{implementation("com.datadoghq:dd-sdk-kotlin-multiplatform-rum:[datadog_version]")implementation("com.datadoghq:dd-sdk-kotlin-multiplatform-session-replay:[datadog_version]")}// in case you need Material support on Android
androidMain.dependencies{implementation("com.datadoghq:dd-sdk-android-session-replay-material:[datadog_version]")}}}
Enable Session Replay in your app:
Application.kt
// in common source set
valsessionReplayConfig=SessionReplayConfiguration.Builder([sampleRate]).build()SessionReplay.enable(sessionReplayConfig)
In case you need Material support on Android, call the SessionReplayConfiguration.Builder.addExtensionSupport(MaterialExtensionSupport()) method, available in the Android source set.
Web view instrumentation
You can record the entire user journey across both web and native views on iOS or Android and watch it in a single Session Replay.
The Session Replay is recorded through the Browser SDK, then the Mobile SDK handles the batching and uploading of the webview recording.
To instrument your consolidated web and native Session Replay views for Android:
Ensure you are using version 2.8.0 or higher of the Android SDK.
Enable Session Replay for your mobile application (see setup instructions above).
Additional configuration
Set the sample rate for recorded sessions to appear
The sample rate is an optional parameter in the Session Replay configuration. It must be a number between 0.0 and 100.0, where 0 indicates that no replays are recorded and 100 means that all RUM sessions include a replay. If the sample rate is not specified in the configuration, the default value of 100 is applied.
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% are included in RUM, and within those sessions, only 20% have replays.
By default, Session Replay starts recording automatically. However, if you prefer to manually start recording at a specific point in your application, you can use the optional startRecordingImmediately parameter as shown below, and later call SessionReplay.startRecording(). You can also use SessionReplay.stopRecording() to stop the recording anytime.
Application.kt
valsessionReplayConfig=SessionReplayConfiguration.Builder([sampleRate]).startRecordingImmediately(false).build()// Do something
SessionReplay.startRecording()SessionReplay.stopRecording()
AppDelegate.swift
letsessionReplayConfig=SessionReplay.Configuration(replaySampleRate:sampleRate,startRecordingImmediately:false)// Do something SessionReplay.startRecording()SessionReplay.stopRecording()
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: