Skip to content

Commit

Permalink
RUM-7150: Split configuration constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmos committed Nov 14, 2024
1 parent 2cbb9c1 commit 6e09dbf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
1 change: 1 addition & 0 deletions features/dd-sdk-android-session-replay/api/apiSurface
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ public final class com/datadog/android/sessionreplay/SessionReplayConfiguration$
public synthetic fun <init> (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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6e09dbf

Please sign in to comment.