-
-
Notifications
You must be signed in to change notification settings - Fork 278
Closed
Labels
Description
We use the following processor to stop events being sent to Sentry in debug/development:
Future<void> initializeSentry(String release, String environment, String dsn,
{FutureOr<void> Function() runApp, Transport transport}) =>
Sentry.init(
(options) => options
..dsn = dsn
..release = release
..environment = environment
..transport = transport ?? options.transport
..addEventProcessor(_noEventInDebug),
appRunner: runApp,
);
SentryEvent _noEventInDebug(SentryEvent event, {dynamic hint}) {
return isInDebugMode || disableSentry ? null : event;
}Prior to null safety this worked as expected, with this test passing:
class MockTransport extends Mock implements Transport {}
test('No sentry events should be sent in debug mode', () async {
expect(isInDebugMode, isTrue);
expect(overrideDisableSentry, isNull);
await initializeSentry('release', 'env', fakeDsn, transport: transport);
expect(Sentry.isEnabled, isTrue);
final event = SentryEvent();
await Sentry.captureEvent(event);
final callCount = verifyNever(
transport.send(captureAny),
).callCount;
expect(callCount, 0);
});However, when upgrading to null safety version of the package, this test now fails.
fzyzcjy