Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename errorSampleRate to onErrorSampleRate #2270

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)):

Expand All @@ -13,7 +13,7 @@
(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 @@ -199,7 +199,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 @@
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 Expand Up @@ -1046,7 +1046,7 @@
final imageBytes =
await DefaultAssetBundle.of(context).load('assets/sentry-wordmark.png');
await showDialog<void>(
context: context,

Check notice on line 1049 in flutter/example/lib/main.dart

View workflow job for this annotation

GitHub Actions / analyze / analyze

Don't use 'BuildContext's across async gaps.

Try rewriting the code to not use the 'BuildContext', or guard the use with a 'mounted' check. See https://dart.dev/diagnostics/use_build_context_synchronously to learn more about this problem.
// gets tracked if using SentryNavigatorObserver
routeSettings: const RouteSettings(
name: 'AssetBundle dialog',
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 @@ -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));
}

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
Loading