From 2e93bab4ceb4ae3b5824ef6bf1adc5ab20513f7c Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:34:16 +0200 Subject: [PATCH] chore: rename errorSampleRate to onErrorSampleRate (#2270) * chore: rename errorSampleRate to onErrorSampleRate * Update CHANGELOG.md --- CHANGELOG.md | 7 +++---- .../src/main/kotlin/io/sentry/flutter/SentryFlutter.kt | 2 +- .../test/kotlin/io/sentry/flutter/SentryFlutterTest.kt | 2 +- flutter/example/lib/main.dart | 2 +- flutter/ios/Classes/SentryFlutter.swift | 2 +- flutter/lib/src/native/cocoa/sentry_native_cocoa.dart | 2 +- flutter/lib/src/native/java/sentry_native_java.dart | 2 +- flutter/lib/src/native/sentry_native_channel.dart | 2 +- flutter/lib/src/sentry_replay_options.dart | 10 +++++----- flutter/test/integrations/init_native_sdk_test.dart | 6 +++--- flutter/test/replay/replay_native_test.dart | 4 ++-- 11 files changed, 20 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 898a65cde..c637354d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ ### Features -- Session replay Alpha for Android and iOS ([#2208](https://github.com/getsentry/sentry-dart/pull/2208), [#2269](https://github.com/getsentry/sentry-dart/pull/2269), [#2236](https://github.com/getsentry/sentry-dart/pull/2236), [#2275](https://github.com/getsentry/sentry-dart/pull/2275). - +- Session replay Alpha for Android and iOS ([#2208](https://github.com/getsentry/sentry-dart/pull/2208), [#2269](https://github.com/getsentry/sentry-dart/pull/2269), [#2236](https://github.com/getsentry/sentry-dart/pull/2236), [#2275](https://github.com/getsentry/sentry-dart/pull/2275), [#2270](https://github.com/getsentry/sentry-dart/pull/2270)). To try out replay, you can set following options (access is limited to early access orgs on Sentry. If you're interested, [sign up for the waitlist](https://sentry.io/lp/mobile-replay-beta/)): ```dart @@ -13,7 +12,7 @@ (options) { ... options.experimental.replay.sessionSampleRate = 1.0; - options.experimental.replay.errorSampleRate = 1.0; + options.experimental.replay.onErrorSampleRate = 1.0; }, appRunner: () => runApp(MyApp()), ); @@ -205,7 +204,7 @@ SentryNavigatorObserver(ignoreRoutes: ["/ignoreThisRoute"]), (options) { ... options.experimental.replay.sessionSampleRate = 1.0; - options.experimental.replay.errorSampleRate = 1.0; + options.experimental.replay.onErrorSampleRate = 1.0; }, appRunner: () => runApp(MyApp()), ); diff --git a/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutter.kt b/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutter.kt index 88d9016a4..d38872f6e 100644 --- a/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutter.kt +++ b/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutter.kt @@ -158,7 +158,7 @@ class SentryFlutter( data: Map, ) { options.sessionSampleRate = data["sessionSampleRate"] as? Double - options.errorSampleRate = data["errorSampleRate"] as? Double + options.errorSampleRate = data["onErrorSampleRate"] as? Double } } diff --git a/flutter/android/src/test/kotlin/io/sentry/flutter/SentryFlutterTest.kt b/flutter/android/src/test/kotlin/io/sentry/flutter/SentryFlutterTest.kt index c43b2807e..efab67297 100644 --- a/flutter/android/src/test/kotlin/io/sentry/flutter/SentryFlutterTest.kt +++ b/flutter/android/src/test/kotlin/io/sentry/flutter/SentryFlutterTest.kt @@ -155,7 +155,7 @@ class Fixture { "replay" to mapOf( "sessionSampleRate" to 0.5, - "errorSampleRate" to 0.6, + "onErrorSampleRate" to 0.6, ), ) diff --git a/flutter/example/lib/main.dart b/flutter/example/lib/main.dart index 3454696b3..dd870eb58 100644 --- a/flutter/example/lib/main.dart +++ b/flutter/example/lib/main.dart @@ -91,7 +91,7 @@ Future setupSentry( options.navigatorKey = navigatorKey; options.experimental.replay.sessionSampleRate = 1.0; - options.experimental.replay.errorSampleRate = 1.0; + options.experimental.replay.onErrorSampleRate = 1.0; _isIntegrationTest = isIntegrationTest; if (_isIntegrationTest) { diff --git a/flutter/ios/Classes/SentryFlutter.swift b/flutter/ios/Classes/SentryFlutter.swift index 3f77fad59..987528987 100644 --- a/flutter/ios/Classes/SentryFlutter.swift +++ b/flutter/ios/Classes/SentryFlutter.swift @@ -110,7 +110,7 @@ public final class SentryFlutter { options.experimental.sessionReplay.sessionSampleRate = (replayOptions["sessionSampleRate"] as? NSNumber)?.floatValue ?? 0 options.experimental.sessionReplay.onErrorSampleRate = - (replayOptions["errorSampleRate"] as? NSNumber)?.floatValue ?? 0 + (replayOptions["onErrorSampleRate"] as? NSNumber)?.floatValue ?? 0 } #endif } diff --git a/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart b/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart index 566624647..00728d511 100644 --- a/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart +++ b/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart @@ -26,7 +26,7 @@ class SentryNativeCocoa extends SentryNativeChannel { if (options.experimental.replay.isEnabled && options.platformChecker.platform.isIOS) { // We only need the integration when error-replay capture is enabled. - if ((options.experimental.replay.errorSampleRate ?? 0) > 0) { + if ((options.experimental.replay.onErrorSampleRate ?? 0) > 0) { options.addEventProcessor(ReplayEventProcessor(this)); } diff --git a/flutter/lib/src/native/java/sentry_native_java.dart b/flutter/lib/src/native/java/sentry_native_java.dart index df5e11b81..5890ca5db 100644 --- a/flutter/lib/src/native/java/sentry_native_java.dart +++ b/flutter/lib/src/native/java/sentry_native_java.dart @@ -24,7 +24,7 @@ class SentryNativeJava extends SentryNativeChannel { // so let's set it up conditionally. This allows Dart to trim the code. if (options.experimental.replay.isEnabled) { // We only need the integration when error-replay capture is enabled. - if ((options.experimental.replay.errorSampleRate ?? 0) > 0) { + if ((options.experimental.replay.onErrorSampleRate ?? 0) > 0) { options.addEventProcessor(ReplayEventProcessor(this)); } diff --git a/flutter/lib/src/native/sentry_native_channel.dart b/flutter/lib/src/native/sentry_native_channel.dart index 2820ac28e..360290230 100644 --- a/flutter/lib/src/native/sentry_native_channel.dart +++ b/flutter/lib/src/native/sentry_native_channel.dart @@ -69,7 +69,7 @@ class SentryNativeChannel if (options.proxy != null) 'proxy': options.proxy?.toJson(), 'replay': { 'sessionSampleRate': options.experimental.replay.sessionSampleRate, - 'errorSampleRate': options.experimental.replay.errorSampleRate, + 'onErrorSampleRate': options.experimental.replay.onErrorSampleRate, }, }); } diff --git a/flutter/lib/src/sentry_replay_options.dart b/flutter/lib/src/sentry_replay_options.dart index e98aed741..e52fbb287 100644 --- a/flutter/lib/src/sentry_replay_options.dart +++ b/flutter/lib/src/sentry_replay_options.dart @@ -13,15 +13,15 @@ class SentryReplayOptions { _sessionSampleRate = value; } - double? _errorSampleRate; + double? _onErrorSampleRate; /// A percentage of errors that will be accompanied by a 30 seconds replay. /// The value needs to be >= 0.0 and <= 1.0. /// Specifying 0 means none, 1.0 means 100 %. Defaults to null (disabled). - double? get errorSampleRate => _errorSampleRate; - set errorSampleRate(double? value) { + double? get onErrorSampleRate => _onErrorSampleRate; + set onErrorSampleRate(double? value) { assert(value == null || (value >= 0 && value <= 1)); - _errorSampleRate = value; + _onErrorSampleRate = value; } /// Redact all text content. Draws a rectangle of text bounds with text color @@ -36,5 +36,5 @@ class SentryReplayOptions { @internal bool get isEnabled => - ((sessionSampleRate ?? 0) > 0) || ((errorSampleRate ?? 0) > 0); + ((sessionSampleRate ?? 0) > 0) || ((onErrorSampleRate ?? 0) > 0); } diff --git a/flutter/test/integrations/init_native_sdk_test.dart b/flutter/test/integrations/init_native_sdk_test.dart index 4b89d3cfe..bfce621eb 100644 --- a/flutter/test/integrations/init_native_sdk_test.dart +++ b/flutter/test/integrations/init_native_sdk_test.dart @@ -67,7 +67,7 @@ void main() { 'appHangTimeoutIntervalMillis': 2000, 'replay': { 'sessionSampleRate': null, - 'errorSampleRate': null, + 'onErrorSampleRate': null, }, }); }); @@ -118,7 +118,7 @@ void main() { pass: '0000', ) ..experimental.replay.sessionSampleRate = 0.1 - ..experimental.replay.errorSampleRate = 0.2; + ..experimental.replay.onErrorSampleRate = 0.2; fixture.options.sdk.addIntegration('foo'); fixture.options.sdk.addPackage('bar', '1'); @@ -172,7 +172,7 @@ void main() { }, 'replay': { 'sessionSampleRate': 0.1, - 'errorSampleRate': 0.2, + 'onErrorSampleRate': 0.2, }, }); }); diff --git a/flutter/test/replay/replay_native_test.dart b/flutter/test/replay/replay_native_test.dart index 81c6f456c..e9b047d8b 100644 --- a/flutter/test/replay/replay_native_test.dart +++ b/flutter/test/replay/replay_native_test.dart @@ -76,7 +76,7 @@ void main() { test('init sets $ReplayEventProcessor when error replay is enabled', () async { - options.experimental.replay.errorSampleRate = 0.1; + options.experimental.replay.onErrorSampleRate = 0.1; await sut.init(hub); expect(options.eventProcessors.map((e) => e.runtimeType.toString()), @@ -95,7 +95,7 @@ void main() { group('replay recorder', () { setUp(() async { options.experimental.replay.sessionSampleRate = 0.1; - options.experimental.replay.errorSampleRate = 0.1; + options.experimental.replay.onErrorSampleRate = 0.1; await sut.init(hub); });