diff --git a/features/dd-sdk-android-session-replay/api/apiSurface b/features/dd-sdk-android-session-replay/api/apiSurface index 93f2e1338d..5e7255cb31 100644 --- a/features/dd-sdk-android-session-replay/api/apiSurface +++ b/features/dd-sdk-android-session-replay/api/apiSurface @@ -24,6 +24,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() constructor(Float = SAMPLE_IN_ALL_SESSIONS) fun addExtensionSupport(ExtensionSupport): Builder fun useCustomEndpoint(String): 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 2ae760309d..bc9e29de31 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 @@ -59,10 +59,8 @@ public final class com/datadog/android/sessionreplay/SessionReplayConfiguration$ 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 getLogger ()Lcom/datadog/android/api/InternalLogger; public final fun setDynamicOptimizationEnabled (Z)Lcom/datadog/android/sessionreplay/SessionReplayConfiguration$Builder; public final fun setImagePrivacy (Lcom/datadog/android/sessionreplay/ImagePrivacy;)Lcom/datadog/android/sessionreplay/SessionReplayConfiguration$Builder; - public final fun setLogger (Lcom/datadog/android/api/InternalLogger;)V public final fun setPrivacy (Lcom/datadog/android/sessionreplay/SessionReplayPrivacy;)Lcom/datadog/android/sessionreplay/SessionReplayConfiguration$Builder; public final fun setSystemRequirements (Lcom/datadog/android/sessionreplay/SystemRequirementsConfiguration;)Lcom/datadog/android/sessionreplay/SessionReplayConfiguration$Builder; public final fun setTextAndInputPrivacy (Lcom/datadog/android/sessionreplay/TextAndInputPrivacy;)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 0e42f3e79d..303756a218 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 @@ -32,19 +32,31 @@ 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. */ @Suppress("TooManyFunctions") - class Builder( - @FloatRange(from = 0.0, to = 100.0) private val sampleRate: Float = SAMPLE_IN_ALL_SESSIONS - ) { - private var logger = InternalLogger.UNBOUND + class Builder { + private val logger: InternalLogger + private val sampleRate: Float + + /** + * Calling this constructor will default to a 100% session sampling rate. + */ + constructor() : this(SAMPLE_IN_ALL_SESSIONS, InternalLogger.UNBOUND) + + /** + * @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. + */ + constructor( + @FloatRange(from = 0.0, to = 100.0) sampleRate: Float = SAMPLE_IN_ALL_SESSIONS + ) : this(sampleRate, InternalLogger.UNBOUND) + internal constructor( - @FloatRange(from = 0.0, to = 100.0) sampleRate: Float = SAMPLE_IN_ALL_SESSIONS, + @FloatRange(from = 0.0, to = 100.0) sampleRate: Float, logger: InternalLogger - ) : this(sampleRate) { + ) { + this.sampleRate = sampleRate this.logger = logger } 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 6f6f898eee..1af44b49cf 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 @@ -264,9 +264,8 @@ internal class SessionReplayConfigurationBuilderTest { val config = testedBuilder.build() // Then - assertThat(config.customDrawableMappers).containsAll( - setOf(mockFirstDrawableMapper, mockSecondDrawableMapper) - ) + assertThat(config.customDrawableMappers) + .containsOnly(mockFirstDrawableMapper, mockSecondDrawableMapper) } @Test @@ -292,9 +291,8 @@ internal class SessionReplayConfigurationBuilderTest { val config = testedBuilder.build() // Then - assertThat(config.customOptionSelectorDetectors).containsAll( - setOf(mockFirstOptionSelectorDetector, mockSecondOptionSelectorDetector) - ) + assertThat(config.customOptionSelectorDetectors) + .containsOnly(mockFirstOptionSelectorDetector, mockSecondOptionSelectorDetector) } @Test @@ -330,9 +328,8 @@ internal class SessionReplayConfigurationBuilderTest { val config = testedBuilder.build() // Then - assertThat(config.customMappers).containsAll( - setOf(fakeTextMapperTypeWrapper, fakeImageMapperTypeWrapper) - ) + assertThat(config.customMappers) + .containsOnly(fakeTextMapperTypeWrapper, fakeImageMapperTypeWrapper) } @Test