From f1e03bb7abc07df673d32b81625225808a8f43c9 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Tue, 20 Aug 2024 10:38:59 +0200 Subject: [PATCH 1/2] chore: rename errorSampleRate to onErrorSampleRate --- CHANGELOG.md | 4 ++-- .../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, 19 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b915e3dcf6..befeafd872 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ (options) { ... options.experimental.replay.sessionSampleRate = 1.0; - options.experimental.replay.errorSampleRate = 1.0; + options.experimental.replay.onErrorSampleRate = 1.0; }, appRunner: () => runApp(MyApp()), ); @@ -198,7 +198,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 88d9016a47..d38872f6ee 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 c43b2807ed..efab672972 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 ed8961741c..c617dd8292 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 3f77fad598..987528987c 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 5666246472..00728d511d 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 5ccd3a1c67..ca8dfedd4c 100644 --- a/flutter/lib/src/native/java/sentry_native_java.dart +++ b/flutter/lib/src/native/java/sentry_native_java.dart @@ -21,7 +21,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 2820ac28ef..360290230d 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 e98aed7418..e52fbb2877 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 4b89d3cfe0..bfce621eb3 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 319bb5f88f..ec98d4c56d 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); }); From 109b5ae31a2877180194720708511656d23b34bb Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Thu, 5 Sep 2024 08:31:34 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17f631f07c..7dff7854d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +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)). +- 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), [#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/)):