diff --git a/features/dd-sdk-android-session-replay/api/apiSurface b/features/dd-sdk-android-session-replay/api/apiSurface index 81ec329a4b..debfc1b947 100644 --- a/features/dd-sdk-android-session-replay/api/apiSurface +++ b/features/dd-sdk-android-session-replay/api/apiSurface @@ -19,7 +19,7 @@ object com.datadog.android.sessionreplay.SessionReplay fun stopRecording(com.datadog.android.api.SdkCore = Datadog.getInstance()) data class com.datadog.android.sessionreplay.SessionReplayConfiguration class Builder - constructor(Float) + constructor(Float = SAMPLE_IN_ALL_SESSIONS) fun addExtensionSupport(ExtensionSupport): Builder fun useCustomEndpoint(String): Builder DEPRECATED fun setPrivacy(SessionReplayPrivacy): Builder diff --git a/features/dd-sdk-android-session-replay/api/dd-sdk-android-session-replay.api b/features/dd-sdk-android-session-replay/api/dd-sdk-android-session-replay.api index 7b04236aa1..e5d712484c 100644 --- a/features/dd-sdk-android-session-replay/api/dd-sdk-android-session-replay.api +++ b/features/dd-sdk-android-session-replay/api/dd-sdk-android-session-replay.api @@ -51,7 +51,9 @@ public final class com/datadog/android/sessionreplay/SessionReplayConfiguration } public final class com/datadog/android/sessionreplay/SessionReplayConfiguration$Builder { + public fun ()V public fun (F)V + public synthetic fun (FILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun addExtensionSupport (Lcom/datadog/android/sessionreplay/ExtensionSupport;)Lcom/datadog/android/sessionreplay/SessionReplayConfiguration$Builder; public final fun build ()Lcom/datadog/android/sessionreplay/SessionReplayConfiguration; public final fun setDynamicOptimizationEnabled (Z)Lcom/datadog/android/sessionreplay/SessionReplayConfiguration$Builder; diff --git a/features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/SessionReplayConfiguration.kt b/features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/SessionReplayConfiguration.kt index 983f493d13..425d57c349 100644 --- a/features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/SessionReplayConfiguration.kt +++ b/features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/SessionReplayConfiguration.kt @@ -31,8 +31,9 @@ data class SessionReplayConfiguration internal constructor( * A Builder class for a [SessionReplayConfiguration]. * @param sampleRate must be a value between 0 and 100. A value of 0 * means no session will be recorded, 100 means all sessions will be recorded. + * If this value is not provided then Session Replay will default to a 100 sample rate. */ - class Builder(@FloatRange(from = 0.0, to = 100.0) private val sampleRate: Float) { + class Builder(@FloatRange(from = 0.0, to = 100.0) private val sampleRate: Float = SAMPLE_IN_ALL_SESSIONS) { private var customEndpointUrl: String? = null private var privacy = SessionReplayPrivacy.MASK @@ -196,5 +197,9 @@ data class SessionReplayConfiguration internal constructor( private fun customMappers(): List> { return extensionSupport.getCustomViewMappers() } + + internal companion object { + internal const val SAMPLE_IN_ALL_SESSIONS = 100.0f + } } } diff --git a/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/SessionReplayConfigurationBuilderTest.kt b/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/SessionReplayConfigurationBuilderTest.kt index e6ab76ff75..f5217a4c08 100644 --- a/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/SessionReplayConfigurationBuilderTest.kt +++ b/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/SessionReplayConfigurationBuilderTest.kt @@ -7,6 +7,7 @@ package com.datadog.android.sessionreplay import android.view.View +import com.datadog.android.sessionreplay.SessionReplayConfiguration.Builder.Companion.SAMPLE_IN_ALL_SESSIONS import com.datadog.android.sessionreplay.forge.ForgeConfigurator import fr.xgouchet.elmyr.annotation.BoolForgery import fr.xgouchet.elmyr.annotation.FloatForgery @@ -47,7 +48,7 @@ internal class SessionReplayConfigurationBuilderTest { fun `set up`() { fakeExpectedCustomMappers = listOf(MapperTypeWrapper(View::class.java, mock())) whenever(mockExtensionSupport.getCustomViewMappers()).thenReturn(fakeExpectedCustomMappers) - testedBuilder = SessionReplayConfiguration.Builder(fakeSampleRate) + testedBuilder = SessionReplayConfiguration.Builder() } @Test @@ -60,9 +61,9 @@ internal class SessionReplayConfigurationBuilderTest { assertThat(sessionReplayConfiguration.privacy).isEqualTo(SessionReplayPrivacy.MASK) assertThat(sessionReplayConfiguration.imagePrivacy).isEqualTo(ImagePrivacy.MASK_ALL) assertThat(sessionReplayConfiguration.touchPrivacy).isEqualTo(TouchPrivacy.HIDE) + assertThat(sessionReplayConfiguration.sampleRate).isEqualTo(SAMPLE_IN_ALL_SESSIONS) assertThat(sessionReplayConfiguration.customMappers).isEmpty() assertThat(sessionReplayConfiguration.customOptionSelectorDetectors).isEmpty() - assertThat(sessionReplayConfiguration.sampleRate).isEqualTo(fakeSampleRate) assertThat(sessionReplayConfiguration.dynamicOptimizationEnabled).isEqualTo(true) } @@ -71,6 +72,7 @@ internal class SessionReplayConfigurationBuilderTest { @StringForgery(regex = "https://[a-z]+\\.com") sessionReplayUrl: String ) { // When + testedBuilder = SessionReplayConfiguration.Builder(fakeSampleRate) val sessionReplayConfiguration = testedBuilder .useCustomEndpoint(sessionReplayUrl) .build()