From b65dc35cb75b81336544e62be2509eda93ef46a8 Mon Sep 17 00:00:00 2001 From: Juan Gilsanz Polo Date: Wed, 11 Sep 2024 22:43:26 +0200 Subject: [PATCH] Exclude some sentry logs --- lib/main.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index ecd9f7e..854dd43 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -169,6 +169,20 @@ void main() async { (options) { options.dsn = dotenv.env['SENTRY_DSN']; options.sendDefaultPii = false; + options.beforeSend = (event, hint) { + if (event.throwable is HttpException) { + return null; + } + + if ( + event.message?.formatted.contains("Unexpected character") ?? false || + (event.throwable != null && event.throwable!.toString().contains("Unexpected character")) + ) { + return null; // Exclude this event + } + + return event; + }; }, appRunner: () => startApp() );