Skip to content

Commit

Permalink
Merge pull request #2323 from DataDog/jmoskovich/rum-6385/default-sr-…
Browse files Browse the repository at this point in the history
…sample-rate

RUM-6385: Default sample rate for session replay
  • Loading branch information
jonathanmos authored Oct 16, 2024
2 parents c3e7cb7 + 2837584 commit 774c798
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion features/dd-sdk-android-session-replay/api/apiSurface
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public final class com/datadog/android/sessionreplay/SessionReplayConfiguration
}

public final class com/datadog/android/sessionreplay/SessionReplayConfiguration$Builder {
public fun <init> ()V
public fun <init> (F)V
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 setDynamicOptimizationEnabled (Z)Lcom/datadog/android/sessionreplay/SessionReplayConfiguration$Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -196,5 +197,9 @@ data class SessionReplayConfiguration internal constructor(
private fun customMappers(): List<MapperTypeWrapper<*>> {
return extensionSupport.getCustomViewMappers()
}

internal companion object {
internal const val SAMPLE_IN_ALL_SESSIONS = 100.0f
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
}

Expand All @@ -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()
Expand Down

0 comments on commit 774c798

Please sign in to comment.