diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 3a2514fc43..b3ec82ce10 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -41,10 +41,8 @@ class Sentry { @internal bool callAppRunnerInRunZonedGuarded = true, @internal RunZonedGuardedOnError? runZonedGuardedOnError, @internal SentryOptions? options, - @internal bool devMode = false, }) async { final sentryOptions = options ?? SentryOptions(); - sentryOptions.devMode = devMode; await _initDefaultValues(sentryOptions); diff --git a/dart/test/environment_test.dart b/dart/test/environment_test.dart index a7a8c8f355..6a409022c5 100644 --- a/dart/test/environment_test.dart +++ b/dart/test/environment_test.dart @@ -23,11 +23,11 @@ void main() { release: 'release-9.8.7', dist: 'bar', ); + options.devMode = true; await Sentry.init( (options) => options, options: options, - devMode: true, ); expect(options.dsn, fakeDsn); @@ -44,11 +44,11 @@ void main() { release: 'release-9.8.7', dist: 'bar', ); + options.devMode = true; await Sentry.init( (options) => options, options: options, - devMode: true, ); expect(options.dsn, 'foo-bar'); diff --git a/dart/test/event_processor/deduplication_event_processor_test.dart b/dart/test/event_processor/deduplication_event_processor_test.dart index ffab8c444e..47540cf035 100644 --- a/dart/test/event_processor/deduplication_event_processor_test.dart +++ b/dart/test/event_processor/deduplication_event_processor_test.dart @@ -77,13 +77,14 @@ void main() { final transport = MockTransport(); + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( (options) { options.dsn = fakeDsn; options.transport = transport; options.enableDeduplication = true; }, - devMode: true, + options: options, ); // The test doesn't work if `outerTestMethod` is passed as diff --git a/dart/test/event_processor/enricher/io_enricher_test.dart b/dart/test/event_processor/enricher/io_enricher_test.dart index 1c21bf2746..3c1108a863 100644 --- a/dart/test/event_processor/enricher/io_enricher_test.dart +++ b/dart/test/event_processor/enricher/io_enricher_test.dart @@ -159,17 +159,18 @@ void main() { }); test('$IoEnricherEventProcessor gets added on init', () async { - late SentryOptions sentryOptions; + final options = SentryOptions(dsn: fakeDsn)..devMode = true; + late SentryOptions configuredOptions; await Sentry.init( (options) { options.dsn = fakeDsn; - sentryOptions = options; + configuredOptions = options; }, - devMode: true, + options: options, ); await Sentry.close(); - final ioEnricherCount = sentryOptions.eventProcessors + final ioEnricherCount = configuredOptions.eventProcessors .whereType() .length; expect(ioEnricherCount, 1); diff --git a/dart/test/initialization_test.dart b/dart/test/initialization_test.dart index 37e082e267..fae9f26e82 100644 --- a/dart/test/initialization_test.dart +++ b/dart/test/initialization_test.dart @@ -14,11 +14,12 @@ void main() { }); test('async re-initilization', () async { + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( (options) { options.dsn = fakeDsn; }, - devMode: true, + options: options, ); await Sentry.close(); @@ -27,24 +28,28 @@ void main() { (options) { options.dsn = fakeDsn; }, - devMode: true, + options: options, ); }); // This is the failure from // https://github.com/getsentry/sentry-dart/issues/508 test('re-initilization', () async { + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( (options) { options.dsn = fakeDsn; }, - devMode: true, + options: options, ); await Sentry.close(); - await Sentry.init((options) { - options.dsn = fakeDsn; - }); + await Sentry.init( + (options) { + options.dsn = fakeDsn; + }, + options: options, + ); }); } diff --git a/dart/test/sentry_test.dart b/dart/test/sentry_test.dart index f4f954cf5d..2705f23161 100644 --- a/dart/test/sentry_test.dart +++ b/dart/test/sentry_test.dart @@ -18,12 +18,13 @@ void main() { var anException = Exception(); setUp(() async { + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) => { options.dsn = fakeDsn, options.tracesSampleRate = 1.0, }, - devMode: true, ); anException = Exception('anException'); @@ -136,10 +137,11 @@ void main() { }); test('null DSN', () async { + final options = SentryOptions(dsn: fakeDsn)..devMode = true; expect( () async => await Sentry.init( + options: options, (options) => options.dsn = null, - devMode: true, ), throwsArgumentError, ); @@ -148,17 +150,19 @@ void main() { test('appRunner should be optional', () async { expect(Sentry.isEnabled, false); + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) => options.dsn = fakeDsn, - devMode: true, ); expect(Sentry.isEnabled, true); }); test('empty DSN', () async { + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) => options.dsn = '', - devMode: true, ); expect(Sentry.isEnabled, false); }); @@ -166,21 +170,23 @@ void main() { test('empty DSN disables the SDK but runs the integrations', () async { final integration = MockIntegration(); + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) { options.dsn = ''; options.addIntegration(integration); }, - devMode: true, ); expect(integration.callCalls, 1); }); test('close disables the SDK', () async { + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) => options.dsn = fakeDsn, - devMode: true, ); Sentry.bindClient(MockSentryClient()); @@ -201,12 +207,13 @@ void main() { test('should install integrations', () async { final integration = MockIntegration(); + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) { options.dsn = fakeDsn; options.addIntegration(integration); }, - devMode: true, ); expect(integration.callCalls, 1); @@ -214,13 +221,14 @@ void main() { test('should add default integrations', () async { late SentryOptions optionsReference; + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) { options.dsn = fakeDsn; optionsReference = options; }, appRunner: appRunner, - devMode: true, ); expect( optionsReference.integrations @@ -237,7 +245,9 @@ void main() { }, onPlatform: {'browser': Skip()}); test('should add only web compatible default integrations', () async { + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) { options.dsn = fakeDsn; expect( @@ -245,19 +255,19 @@ void main() { 0, ); }, - devMode: true, ); }, onPlatform: {'vm': Skip()}); test('should close integrations', () async { final integration = MockIntegration(); + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) { options.dsn = fakeDsn; options.addIntegration(integration); }, - devMode: true, ); await Sentry.close(); @@ -267,7 +277,9 @@ void main() { }); test('$DeduplicationEventProcessor is added on init', () async { + final options = SentryOptions(dsn: fakeDsn)..devMode = true; await Sentry.init( + options: options, (options) { options.dsn = fakeDsn; final count = options.eventProcessors @@ -275,7 +287,6 @@ void main() { .length; expect(count, 1); }, - devMode: true, ); }); @@ -283,12 +294,13 @@ void main() { final completer = Completer(); var completed = false; + final options = SentryOptions(dsn: fakeDsn)..devMode = true; final init = Sentry.init( + options: options, (options) { options.dsn = fakeDsn; }, appRunner: () => completer.future, - devMode: true, ).whenComplete(() => completed = true); await Future(() { @@ -309,13 +321,14 @@ void main() { final completer = Completer(); var completed = false; + final options = SentryOptions(dsn: fakeDsn)..devMode = true; final init = Sentry.init( + options: options, (options) { options.dsn = fakeDsn; }, appRunner: () => completer.future, callAppRunnerInRunZonedGuarded: false, - devMode: true, ).whenComplete(() => completed = true); await Future(() { @@ -332,8 +345,11 @@ void main() { test('options.environment debug', () async { final sentryOptions = SentryOptions(dsn: fakeDsn) + ..devMode = true ..platformChecker = FakePlatformChecker.debugMode(); + final options = SentryOptions(); + options.devMode = true; await Sentry.init( (options) { options.dsn = fakeDsn; @@ -341,13 +357,13 @@ void main() { expect(options.debug, false); }, options: sentryOptions, - devMode: true, ); }); test('options.environment profile', () async { final sentryOptions = - SentryOptions(dsn: fakeDsn, checker: FakePlatformChecker.profileMode()); + SentryOptions(dsn: fakeDsn, checker: FakePlatformChecker.profileMode()) + ..devMode = true; await Sentry.init( (options) { @@ -356,14 +372,13 @@ void main() { expect(options.debug, false); }, options: sentryOptions, - devMode: true, ); }); test('options.environment production (defaultEnvironment)', () async { final sentryOptions = - SentryOptions(dsn: fakeDsn, checker: FakePlatformChecker.releaseMode()); - + SentryOptions(dsn: fakeDsn, checker: FakePlatformChecker.releaseMode()) + ..devMode = true; await Sentry.init( (options) { options.dsn = fakeDsn; @@ -371,13 +386,13 @@ void main() { expect(options.debug, false); }, options: sentryOptions, - devMode: true, ); }); test('options.logger is set by setting the debug flag', () async { final sentryOptions = - SentryOptions(dsn: fakeDsn, checker: FakePlatformChecker.debugMode()); + SentryOptions(dsn: fakeDsn, checker: FakePlatformChecker.debugMode()) + ..devMode = true; await Sentry.init( (options) { @@ -391,7 +406,6 @@ void main() { expect(options.logger, noOpLogger); }, options: sentryOptions, - devMode: true, ); // ignore: deprecated_member_use_from_same_package @@ -403,6 +417,7 @@ void main() { test('throw is handled and logged', () async { final sentryOptions = SentryOptions(dsn: fakeDsn) + ..devMode = false ..debug = true ..logger = fixture.mockLogger; @@ -412,7 +427,6 @@ void main() { throw exception; }, options: sentryOptions, - devMode: false, ); expect(fixture.loggedException, exception); @@ -425,6 +439,7 @@ void main() { test('throw is handled and logged', () async { final sentryOptions = SentryOptions(dsn: fakeDsn) + ..devMode = false ..debug = true ..logger = fixture.mockLogger; @@ -434,7 +449,6 @@ void main() { throw exception; }, options: sentryOptions, - devMode: false, ); expect(fixture.loggedException, exception); diff --git a/e2e_test/bin/e2e_test.dart b/e2e_test/bin/e2e_test.dart index 454f4b3b82..785f98ea72 100644 --- a/e2e_test/bin/e2e_test.dart +++ b/e2e_test/bin/e2e_test.dart @@ -18,12 +18,15 @@ void main(List arguments) async { print('AUTH TOKEN is not set'); exit(1); } + final options = SentryOptions(dsn: _exampleDsn) + // ignore: invalid_use_of_internal_member + ..devMode = true; await Sentry.init( (options) { options.dsn = _exampleDsn; }, // ignore: invalid_use_of_internal_member - devMode: true, + options: options, ); var id = SentryId.empty(); diff --git a/flutter/lib/src/sentry_flutter.dart b/flutter/lib/src/sentry_flutter.dart index 41552ea58d..13aa7cc552 100644 --- a/flutter/lib/src/sentry_flutter.dart +++ b/flutter/lib/src/sentry_flutter.dart @@ -37,7 +37,6 @@ mixin SentryFlutter { @internal MethodChannel channel = _channel, @internal PlatformChecker? platformChecker, @internal RendererWrapper? rendererWrapper, - @internal bool devMode = false, }) async { final flutterOptions = SentryFlutterOptions(); @@ -92,8 +91,6 @@ mixin SentryFlutter { callAppRunnerInRunZonedGuarded: !isOnErrorSupported, // ignore: invalid_use_of_internal_member runZonedGuardedOnError: runZonedGuardedOnError, - // ignore: invalid_use_of_internal_member - devMode: devMode, ); } diff --git a/flutter/test/initialization_test.dart b/flutter/test/initialization_test.dart index 1d4e92e909..cf1374df37 100644 --- a/flutter/test/initialization_test.dart +++ b/flutter/test/initialization_test.dart @@ -17,8 +17,9 @@ void main() { await SentryFlutter.init( (options) { options.dsn = fakeDsn; + // ignore: invalid_use_of_internal_member + options.devMode = true; }, - devMode: true, ); await Sentry.close(); @@ -26,8 +27,9 @@ void main() { await SentryFlutter.init( (options) { options.dsn = fakeDsn; + // ignore: invalid_use_of_internal_member + options.devMode = true; }, - devMode: true, ); await Sentry.close(); @@ -39,8 +41,9 @@ void main() { await SentryFlutter.init( (options) { options.dsn = fakeDsn; + // ignore: invalid_use_of_internal_member + options.devMode = true; }, - devMode: true, ); await Sentry.close(); @@ -48,8 +51,9 @@ void main() { await SentryFlutter.init( (options) { options.dsn = fakeDsn; + // ignore: invalid_use_of_internal_member + options.devMode = true; }, - devMode: true, ); await Sentry.close(); diff --git a/flutter/test/sentry_flutter_test.dart b/flutter/test/sentry_flutter_test.dart index b3d9dacc5c..b5770d6dda 100644 --- a/flutter/test/sentry_flutter_test.dart +++ b/flutter/test/sentry_flutter_test.dart @@ -64,13 +64,13 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; sentryFlutterOptions = options; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.android()), - devMode: true, ); testTransport( @@ -112,13 +112,13 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; sentryFlutterOptions = options; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.iOs()), - devMode: true, ); testTransport( @@ -158,13 +158,13 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; sentryFlutterOptions = options; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.macOs()), - devMode: true, ); testTransport( @@ -204,13 +204,13 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; sentryFlutterOptions = options; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.windows()), - devMode: true, ); testTransport( @@ -253,13 +253,13 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; sentryFlutterOptions = options; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.linux()), - devMode: true, ); testTransport( @@ -302,6 +302,7 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; sentryFlutterOptions = options; @@ -311,7 +312,6 @@ void main() { isWeb: true, platform: MockPlatform.linux(), ), - devMode: true, ); testTransport( @@ -353,6 +353,7 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; }, @@ -361,7 +362,6 @@ void main() { isWeb: true, platform: MockPlatform.iOs(), ), - devMode: true, ); testTransport( @@ -397,6 +397,7 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; }, @@ -405,7 +406,6 @@ void main() { isWeb: true, platform: MockPlatform.macOs(), ), - devMode: true, ); testTransport( @@ -440,6 +440,7 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; transport = options.transport; }, @@ -448,7 +449,6 @@ void main() { isWeb: true, platform: MockPlatform.android(), ), - devMode: true, ); testTransport( @@ -487,12 +487,12 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.iOs()), rendererWrapper: MockRendererWrapper(FlutterRenderer.skia), - devMode: true, ); expect( @@ -510,12 +510,12 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.iOs()), rendererWrapper: MockRendererWrapper(FlutterRenderer.canvasKit), - devMode: true, ); expect( @@ -533,12 +533,12 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.iOs()), rendererWrapper: MockRendererWrapper(FlutterRenderer.html), - devMode: true, ); expect( @@ -556,12 +556,12 @@ void main() { await SentryFlutter.init( (options) async { options.dsn = fakeDsn; + options.devMode = true; integrations = options.integrations; }, appRunner: appRunner, platformChecker: getPlatformChecker(platform: MockPlatform.iOs()), rendererWrapper: MockRendererWrapper(FlutterRenderer.unknown), - devMode: true, ); expect( @@ -584,6 +584,7 @@ void main() { await SentryFlutter.init( (options) { options.dsn = fakeDsn; + options.devMode = true; expect(false, options.debug); expect('debug', options.environment); @@ -597,7 +598,6 @@ void main() { platform: MockPlatform.android(), isWeb: true, ), - devMode: true, ); await Sentry.close();