Skip to content

Commit 014dbef

Browse files
authored
[SR] Rename errorSampleRate to onErrorSampleRate (#3637)
* Rename errorSampleRate to onErrorSampleRate * pr id
1 parent a22aea0 commit 014dbef

File tree

14 files changed

+45
-38
lines changed

14 files changed

+45
-38
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
*Breaking changes*:
6+
7+
- `options.experimental.sessionReplay.errorSampleRate` was renamed to `options.experimental.sessionReplay.onErrorSampleRate` ([#3637](https://github.com/getsentry/sentry-java/pull/3637))
8+
- Manifest option `io.sentry.session-replay.error-sample-rate` was renamed to `io.sentry.session-replay.on-error-sample-rate` ([#3637](https://github.com/getsentry/sentry-java/pull/3637))
9+
310
## 7.14.0
411

512
### Features

sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ final class ManifestMetadataReader {
106106

107107
static final String REPLAYS_SESSION_SAMPLE_RATE = "io.sentry.session-replay.session-sample-rate";
108108

109-
static final String REPLAYS_ERROR_SAMPLE_RATE = "io.sentry.session-replay.error-sample-rate";
109+
static final String REPLAYS_ERROR_SAMPLE_RATE = "io.sentry.session-replay.on-error-sample-rate";
110110

111111
static final String REPLAYS_REDACT_ALL_TEXT = "io.sentry.session-replay.redact-all-text";
112112

@@ -399,10 +399,10 @@ static void applyMetadata(
399399
}
400400
}
401401

402-
if (options.getExperimental().getSessionReplay().getErrorSampleRate() == null) {
403-
final Double errorSampleRate = readDouble(metadata, logger, REPLAYS_ERROR_SAMPLE_RATE);
404-
if (errorSampleRate != -1) {
405-
options.getExperimental().getSessionReplay().setErrorSampleRate(errorSampleRate);
402+
if (options.getExperimental().getSessionReplay().getOnErrorSampleRate() == null) {
403+
final Double onErrorSampleRate = readDouble(metadata, logger, REPLAYS_ERROR_SAMPLE_RATE);
404+
if (onErrorSampleRate != -1) {
405+
options.getExperimental().getSessionReplay().setOnErrorSampleRate(onErrorSampleRate);
406406
}
407407
}
408408

sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ class ManifestMetadataReaderTest {
14221422
}
14231423

14241424
@Test
1425-
fun `applyMetadata reads replays errorSampleRate from metadata`() {
1425+
fun `applyMetadata reads replays onErrorSampleRate from metadata`() {
14261426
// Arrange
14271427
val expectedSampleRate = 0.99f
14281428

@@ -1433,34 +1433,34 @@ class ManifestMetadataReaderTest {
14331433
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
14341434

14351435
// Assert
1436-
assertEquals(expectedSampleRate.toDouble(), fixture.options.experimental.sessionReplay.errorSampleRate)
1436+
assertEquals(expectedSampleRate.toDouble(), fixture.options.experimental.sessionReplay.onErrorSampleRate)
14371437
}
14381438

14391439
@Test
1440-
fun `applyMetadata does not override replays errorSampleRate from options`() {
1440+
fun `applyMetadata does not override replays onErrorSampleRate from options`() {
14411441
// Arrange
14421442
val expectedSampleRate = 0.99f
1443-
fixture.options.experimental.sessionReplay.errorSampleRate = expectedSampleRate.toDouble()
1443+
fixture.options.experimental.sessionReplay.onErrorSampleRate = expectedSampleRate.toDouble()
14441444
val bundle = bundleOf(ManifestMetadataReader.REPLAYS_ERROR_SAMPLE_RATE to 0.1f)
14451445
val context = fixture.getContext(metaData = bundle)
14461446

14471447
// Act
14481448
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
14491449

14501450
// Assert
1451-
assertEquals(expectedSampleRate.toDouble(), fixture.options.experimental.sessionReplay.errorSampleRate)
1451+
assertEquals(expectedSampleRate.toDouble(), fixture.options.experimental.sessionReplay.onErrorSampleRate)
14521452
}
14531453

14541454
@Test
1455-
fun `applyMetadata without specifying replays errorSampleRate, stays null`() {
1455+
fun `applyMetadata without specifying replays onErrorSampleRate, stays null`() {
14561456
// Arrange
14571457
val context = fixture.getContext()
14581458

14591459
// Act
14601460
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
14611461

14621462
// Assert
1463-
assertNull(fixture.options.experimental.sessionReplay.errorSampleRate)
1463+
assertNull(fixture.options.experimental.sessionReplay.onErrorSampleRate)
14641464
}
14651465

14661466
@Test

sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class SentryAndroidTest {
369369
options.release = "prod"
370370
options.dsn = "https://[email protected]/123"
371371
options.isEnableAutoSessionTracking = true
372-
options.experimental.sessionReplay.errorSampleRate = 1.0
372+
options.experimental.sessionReplay.onErrorSampleRate = 1.0
373373
optionsConfig(options)
374374
}
375375

sentry-android-replay/src/main/java/io/sentry/android/replay/ReplayIntegration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public class ReplayIntegration(
143143

144144
val isFullSession = random.sample(options.experimental.sessionReplay.sessionSampleRate)
145145
if (!isFullSession && !options.experimental.sessionReplay.isSessionReplayForErrorsEnabled) {
146-
options.logger.log(INFO, "Session replay is not started, full session was not sampled and errorSampleRate is not specified")
146+
options.logger.log(INFO, "Session replay is not started, full session was not sampled and onErrorSampleRate is not specified")
147147
return
148148
}
149149

sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BufferCaptureStrategy.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ internal class BufferCaptureStrategy(
6363
isTerminating: Boolean,
6464
onSegmentSent: (Date) -> Unit
6565
) {
66-
val sampled = random.sample(options.experimental.sessionReplay.errorSampleRate)
66+
val sampled = random.sample(options.experimental.sessionReplay.onErrorSampleRate)
6767

6868
if (!sampled) {
69-
options.logger.log(INFO, "Replay wasn't sampled by errorSampleRate, not capturing for event")
69+
options.logger.log(INFO, "Replay wasn't sampled by onErrorSampleRate, not capturing for event")
7070
return
7171
}
7272

sentry-android-replay/src/test/java/io/sentry/android/replay/AnrWithReplayIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class AnrWithReplayIntegrationTest {
151151
it.cacheDirPath = cacheDir
152152
it.isDebug = true
153153
it.setLogger(SystemOutLogger())
154-
it.experimental.sessionReplay.errorSampleRate = 1.0
154+
it.experimental.sessionReplay.onErrorSampleRate = 1.0
155155
// beforeSend is called after event processors are applied, so we can assert here
156156
// against the enriched ANR event
157157
it.beforeSend = SentryOptions.BeforeSendCallback { event, _ ->

sentry-android-replay/src/test/java/io/sentry/android/replay/ReplayIntegrationTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ class ReplayIntegrationTest {
9797
fun getSut(
9898
context: Context,
9999
sessionSampleRate: Double = 1.0,
100-
errorSampleRate: Double = 1.0,
100+
onErrorSampleRate: Double = 1.0,
101101
recorderProvider: (() -> Recorder)? = null,
102102
replayCaptureStrategyProvider: ((isFullSession: Boolean) -> CaptureStrategy)? = null,
103103
recorderConfigProvider: ((configChanged: Boolean) -> ScreenshotRecorderConfig)? = null,
104104
gestureRecorderProvider: (() -> GestureRecorder)? = null,
105105
dateProvider: ICurrentDateProvider = CurrentDateProvider.getInstance()
106106
): ReplayIntegration {
107107
options.run {
108-
experimental.sessionReplay.errorSampleRate = errorSampleRate
108+
experimental.sessionReplay.onErrorSampleRate = onErrorSampleRate
109109
experimental.sessionReplay.sessionSampleRate = sessionSampleRate
110110
}
111111
return ReplayIntegration(
@@ -204,7 +204,7 @@ class ReplayIntegrationTest {
204204
@Test
205205
fun `does not start replay when session is not sampled`() {
206206
val captureStrategy = mock<CaptureStrategy>()
207-
val replay = fixture.getSut(context, errorSampleRate = 0.0, sessionSampleRate = 0.0, replayCaptureStrategyProvider = { captureStrategy })
207+
val replay = fixture.getSut(context, onErrorSampleRate = 0.0, sessionSampleRate = 0.0, replayCaptureStrategyProvider = { captureStrategy })
208208

209209
replay.register(fixture.hub, fixture.options)
210210
replay.start()

sentry-android-replay/src/test/java/io/sentry/android/replay/ReplaySmokeTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class ReplaySmokeTest {
154154
captured.set(true)
155155
}
156156

157-
fixture.options.experimental.sessionReplay.errorSampleRate = 1.0
157+
fixture.options.experimental.sessionReplay.onErrorSampleRate = 1.0
158158
fixture.options.cacheDirPath = tmpDir.newFolder().absolutePath
159159

160160
val replay: ReplayIntegration = fixture.getSut(context)

sentry-android-replay/src/test/java/io/sentry/android/replay/capture/BufferCaptureStrategyTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ class BufferCaptureStrategyTest {
8383
)
8484

8585
fun getSut(
86-
errorSampleRate: Double = 1.0,
86+
onErrorSampleRate: Double = 1.0,
8787
dateProvider: ICurrentDateProvider = CurrentDateProvider.getInstance(),
8888
replayCacheDir: File? = null
8989
): BufferCaptureStrategy {
9090
replayCacheDir?.let {
9191
whenever(replayCache.replayCacheDir).thenReturn(it)
9292
}
9393
options.run {
94-
experimental.sessionReplay.errorSampleRate = errorSampleRate
94+
experimental.sessionReplay.onErrorSampleRate = onErrorSampleRate
9595
}
9696
return BufferCaptureStrategy(
9797
options,
@@ -256,7 +256,7 @@ class BufferCaptureStrategyTest {
256256

257257
@Test
258258
fun `captureReplay does not replayId to scope when not sampled`() {
259-
val strategy = fixture.getSut(errorSampleRate = 0.0)
259+
val strategy = fixture.getSut(onErrorSampleRate = 0.0)
260260
strategy.start(fixture.recorderConfig)
261261

262262
strategy.captureReplay(false) {}

0 commit comments

Comments
 (0)