Skip to content

Commit

Permalink
chore: rename errorSampleRate to onErrorSampleRate (#2270)
Browse files Browse the repository at this point in the history
* chore: rename errorSampleRate to onErrorSampleRate

* Update CHANGELOG.md
  • Loading branch information
vaind authored Sep 9, 2024
1 parent 7efd9cf commit 2e93bab
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 21 deletions.
7 changes: 3 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

### 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
await SentryFlutter.init(
(options) {
...
options.experimental.replay.sessionSampleRate = 1.0;
options.experimental.replay.errorSampleRate = 1.0;
options.experimental.replay.onErrorSampleRate = 1.0;
},
appRunner: () => runApp(MyApp()),
);
Expand Down Expand Up @@ -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()),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class SentryFlutter(
data: Map<String, Any>,
) {
options.sessionSampleRate = data["sessionSampleRate"] as? Double
options.errorSampleRate = data["errorSampleRate"] as? Double
options.errorSampleRate = data["onErrorSampleRate"] as? Double
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Fixture {
"replay" to
mapOf(
"sessionSampleRate" to 0.5,
"errorSampleRate" to 0.6,
"onErrorSampleRate" to 0.6,
),
)

Expand Down
2 changes: 1 addition & 1 deletion flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Future<void> 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) {
Expand Down
2 changes: 1 addition & 1 deletion flutter/ios/Classes/SentryFlutter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/src/native/cocoa/sentry_native_cocoa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/src/native/java/sentry_native_java.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/src/native/sentry_native_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SentryNativeChannel
if (options.proxy != null) 'proxy': options.proxy?.toJson(),
'replay': <String, dynamic>{
'sessionSampleRate': options.experimental.replay.sessionSampleRate,
'errorSampleRate': options.experimental.replay.errorSampleRate,
'onErrorSampleRate': options.experimental.replay.onErrorSampleRate,
},
});
}
Expand Down
10 changes: 5 additions & 5 deletions flutter/lib/src/sentry_replay_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,5 +36,5 @@ class SentryReplayOptions {

@internal
bool get isEnabled =>
((sessionSampleRate ?? 0) > 0) || ((errorSampleRate ?? 0) > 0);
((sessionSampleRate ?? 0) > 0) || ((onErrorSampleRate ?? 0) > 0);
}
6 changes: 3 additions & 3 deletions flutter/test/integrations/init_native_sdk_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void main() {
'appHangTimeoutIntervalMillis': 2000,
'replay': <String, dynamic>{
'sessionSampleRate': null,
'errorSampleRate': null,
'onErrorSampleRate': null,
},
});
});
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -172,7 +172,7 @@ void main() {
},
'replay': <String, dynamic>{
'sessionSampleRate': 0.1,
'errorSampleRate': 0.2,
'onErrorSampleRate': 0.2,
},
});
});
Expand Down
4 changes: 2 additions & 2 deletions flutter/test/replay/replay_native_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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);
});

Expand Down

0 comments on commit 2e93bab

Please sign in to comment.