Remove logs produced by favicon library

This commit is contained in:
Juan Gilsanz Polo
2024-06-16 22:12:32 +02:00
parent 01c7499f37
commit e50f93ea12
2 changed files with 19 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:linkdy/utils/sentry_handle_error.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:receive_sharing_intent_plus/receive_sharing_intent_plus.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
@@ -57,6 +58,7 @@ void main() async {
(options) {
options.dsn = dotenv.env['SENTRY_DSN'];
options.sendDefaultPii = false;
options.beforeSend = sentryHandleError;
},
appRunner: () => startApp(),
);

View File

@@ -0,0 +1,17 @@
import 'dart:async';
import 'package:sentry_flutter/sentry_flutter.dart';
FutureOr<SentryEvent?> sentryHandleError(SentryEvent event, Hint hint) async {
// Remove logs coming from the favicon library
final containsFavicon = event.exceptions
?.where(
(e) => e.stackTrace?.frames.where((f) => f.fileName?.contains("favicon.dart") ?? false).isNotEmpty ?? false,
)
.isNotEmpty;
if (containsFavicon == true) {
return null;
}
return event;
}