Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Ref: Disable `print()` breadcrumbs by default on Flutter

# 6.0.0-beta.1

* Feat: Browser detection (#502)
Expand Down
3 changes: 3 additions & 0 deletions dart/lib/src/sentry_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class SentryOptions {

/// Enable this option if you want to record calls to `print()` as
/// breadcrumbs.
/// Enabling this on Flutter can result in excessive breadcrumbs as
/// [FlutterError.reportError](https://api.flutter.dev/flutter/foundation/FlutterError/reportError.html)
/// prints to console via `print()`.
bool enablePrintBreadcrumbs = true;

/// If [platformChecker] is provided, it is used get the envirnoment.
Expand Down
1 change: 1 addition & 0 deletions flutter/lib/src/sentry_flutter_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class SentryFlutterOptions extends SentryOptions {
SentryFlutterOptions({String? dsn, PlatformChecker? checker})
: super(dsn: dsn, checker: checker) {
enableBreadcrumbTrackingForCurrentPlatform();
enablePrintBreadcrumbs = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that the only option? I'd prefer rather a workaround if possible :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could intercept https://github.com/flutter/flutter/blob/f4abaa0735eba4dfd8f33f73363911d63931fe03/packages/flutter/lib/src/foundation/assertions.dart#L919

and disable recording when it's called.
Kinda like what we do it for FlutterError.onError.
Does that sound better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds better to me, rather than disabling the feature by default.
we can check if its the FlutterExceptionHandler type and do not log it if its a release build, because, on debug level, printing to console is rather useful

}

/// Enable or disable the Auto session tracking on the Native SDKs (Android/iOS)
Expand Down
7 changes: 7 additions & 0 deletions flutter/test/sentry_flutter_options_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,12 @@ void main() {
expect(options.enableMemoryPressureBreadcrumbs, isTrue);
expect(options.enableAutoNativeBreadcrumbs, isFalse);
});

testWidgets('enablePrintBreadcrumbs is disabled on Flutter by default',
(WidgetTester tester) async {
final options = SentryFlutterOptions();

expect(options.enablePrintBreadcrumbs, isFalse);
});
});
}