From 631485d3c51841602d1326ef3745b22ab6357719 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sun, 14 Aug 2022 16:18:18 +0200 Subject: [PATCH] chore: Remove error logging with sentry --- PRIVACY.md | 5 ---- lib/main.dart | 8 ++--- lib/pages/chat/chat_view.dart | 7 ----- lib/pages/chat/events/audio_player.dart | 3 +- lib/pages/chat/events/video_player.dart | 3 +- lib/pages/chat/recording_dialog.dart | 5 ++-- lib/utils/platform_infos.dart | 2 -- lib/utils/resize_image.dart | 5 ++-- lib/utils/sentry_controller.dart | 37 ------------------------ lib/widgets/matrix.dart | 11 ------- lib/widgets/sentry_switch_list_tile.dart | 34 ---------------------- pubspec.lock | 7 ----- pubspec.yaml | 1 - 13 files changed, 9 insertions(+), 119 deletions(-) delete mode 100644 lib/utils/sentry_controller.dart delete mode 100644 lib/widgets/sentry_switch_list_tile.dart diff --git a/PRIVACY.md b/PRIVACY.md index 60925577..a3a66629 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -19,11 +19,6 @@ FluffyChat only communicates with the selected server, with sentry.io if enabled More information is available at: [https://matrix.org](https://matrix.org) -## Sentry -FluffyChat uses Sentry for crash reports if the user allows it. - -More information is available at: [https://sentry.io](https://sentry.io) - ## Database FluffyChat caches some data received from the server in a local database on the device of the user. diff --git a/lib/main.dart b/lib/main.dart index 91e6579e..5473b25a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,7 +16,6 @@ import 'package:vrouter/vrouter.dart'; import 'package:fluffychat/config/routes.dart'; import 'package:fluffychat/utils/client_manager.dart'; import 'package:fluffychat/utils/platform_infos.dart'; -import 'package:fluffychat/utils/sentry_controller.dart'; import 'config/app_config.dart'; import 'config/themes.dart'; import 'utils/background_push.dart'; @@ -49,8 +48,8 @@ void main() async { .addAll(Uri.parse(html.window.location.href).queryParameters); } - runZonedGuarded( - () => runApp(PlatformInfos.isMobile + runApp( + PlatformInfos.isMobile ? AppLock( builder: (args) => FluffyChatApp( clients: clients, @@ -59,8 +58,7 @@ void main() async { lockScreen: const LockScreen(), enabled: false, ) - : FluffyChatApp(clients: clients, queryParameters: queryParameters)), - SentryController.captureException, + : FluffyChatApp(clients: clients, queryParameters: queryParameters), ); } diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index 9613ddc6..920f5354 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -16,7 +16,6 @@ import 'package:fluffychat/pages/chat/pinned_events.dart'; import 'package:fluffychat/pages/chat/reactions_picker.dart'; import 'package:fluffychat/pages/chat/reply_display.dart'; import 'package:fluffychat/pages/chat/tombstone_display.dart'; -import 'package:fluffychat/utils/sentry_controller.dart'; import 'package:fluffychat/widgets/chat_settings_popup_menu.dart'; import 'package:fluffychat/widgets/connection_status_header.dart'; import 'package:fluffychat/widgets/matrix.dart'; @@ -216,12 +215,6 @@ class ChatView extends StatelessWidget { onTap: controller.clearSingleSelectedEvent, child: Builder( builder: (context) { - if (snapshot.hasError) { - SentryController.captureException( - snapshot.error, - StackTrace.current, - ); - } if (controller.timeline == null) { return const Center( child: CircularProgressIndicator diff --git a/lib/pages/chat/events/audio_player.dart b/lib/pages/chat/events/audio_player.dart index 9b6177a7..c2620024 100644 --- a/lib/pages/chat/events/audio_player.dart +++ b/lib/pages/chat/events/audio_player.dart @@ -9,7 +9,6 @@ import 'package:matrix/matrix.dart'; import 'package:path_provider/path_provider.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; -import 'package:fluffychat/utils/sentry_controller.dart'; import '../../../utils/matrix_sdk_extensions.dart/event_extension.dart'; class AudioPlayerWidget extends StatefulWidget { @@ -124,7 +123,7 @@ class _AudioPlayerState extends State { content: Text(L10n.of(context)!.oopsSomethingWentWrong), ), ); - SentryController.captureException(e, s); + Logs().w('Error while playing audio', e, s); }); } diff --git a/lib/pages/chat/events/video_player.dart b/lib/pages/chat/events/video_player.dart index 9cbcb9bc..7443eea0 100644 --- a/lib/pages/chat/events/video_player.dart +++ b/lib/pages/chat/events/video_player.dart @@ -14,7 +14,6 @@ import 'package:video_player/video_player.dart'; import 'package:fluffychat/pages/chat/events/image_bubble.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart'; -import 'package:fluffychat/utils/sentry_controller.dart'; class EventVideoPlayer extends StatefulWidget { final Event event; @@ -70,7 +69,7 @@ class _EventVideoPlayerState extends State { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text(e.toLocalizedString(context)), )); - SentryController.captureException(e, s); + Logs().w('Error while playing video', e, s); } finally { // Workaround for Chewie needs time to get the aspectRatio await Future.delayed(const Duration(milliseconds: 100)); diff --git a/lib/pages/chat/recording_dialog.dart b/lib/pages/chat/recording_dialog.dart index 1958860d..d5e8fb12 100644 --- a/lib/pages/chat/recording_dialog.dart +++ b/lib/pages/chat/recording_dialog.dart @@ -10,7 +10,6 @@ import 'package:wakelock/wakelock.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/utils/platform_infos.dart'; -import 'package:fluffychat/utils/sentry_controller.dart'; import 'events/audio_player.dart'; class RecordingDialog extends StatefulWidget { @@ -64,9 +63,9 @@ class _RecordingDialogState extends State { _duration += const Duration(milliseconds: 100); }); }); - } catch (e, s) { - SentryController.captureException(e, s); + } catch (_) { setState(() => error = true); + rethrow; } } diff --git a/lib/utils/platform_infos.dart b/lib/utils/platform_infos.dart index a8071430..3d0ca933 100644 --- a/lib/utils/platform_infos.dart +++ b/lib/utils/platform_infos.dart @@ -8,7 +8,6 @@ import 'package:package_info_plus/package_info_plus.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:vrouter/vrouter.dart'; -import 'package:fluffychat/widgets/sentry_switch_list_tile.dart'; import '../config/app_config.dart'; abstract class PlatformInfos { @@ -62,7 +61,6 @@ abstract class PlatformInfos { onPressed: () => VRouter.of(context).to('logs'), child: const Text('Logs'), ), - SentrySwitchListTile.adaptive(label: L10n.of(context)!.sendBugReports), ], applicationIcon: Image.asset('assets/logo.png', width: 64, height: 64), applicationName: AppConfig.applicationName, diff --git a/lib/utils/resize_image.dart b/lib/utils/resize_image.dart index c18a8e29..abe7ae66 100644 --- a/lib/utils/resize_image.dart +++ b/lib/utils/resize_image.dart @@ -8,7 +8,6 @@ import 'package:path_provider/path_provider.dart'; import 'package:video_compress/video_compress.dart'; import 'package:fluffychat/utils/platform_infos.dart'; -import 'package:fluffychat/utils/sentry_controller.dart'; extension ResizeImage on MatrixFile { static const int max = 1200; @@ -23,7 +22,7 @@ extension ResizeImage on MatrixFile { // will throw an error e.g. on Android SDK < 18 mediaInfo = await VideoCompress.compressVideo(tmpFile.path); } catch (e, s) { - SentryController.captureException(e, s); + Logs().w('Error while compressing video', e, s); } return MatrixVideoFile( bytes: (await mediaInfo?.file?.readAsBytes()) ?? bytes, @@ -50,7 +49,7 @@ extension ResizeImage on MatrixFile { name: name, ); } catch (e, s) { - SentryController.captureException(e, s); + Logs().w('Error while compressing video', e, s); } return null; } diff --git a/lib/utils/sentry_controller.dart b/lib/utils/sentry_controller.dart deleted file mode 100644 index f81c6ca2..00000000 --- a/lib/utils/sentry_controller.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -import 'package:matrix/matrix.dart'; -import 'package:sentry/sentry.dart'; - -import 'package:fluffychat/config/app_config.dart'; -import '../config/setting_keys.dart'; -import 'famedlysdk_store.dart'; - -abstract class SentryController { - static Future toggleSentryAction( - BuildContext context, bool enableSentry) async { - if (!AppConfig.enableSentry) return; - final storage = Store(); - await storage.setItemBool(SettingKeys.sentry, enableSentry); - return; - } - - static Future getSentryStatus() async { - if (!AppConfig.enableSentry) return false; - final storage = Store(); - return await storage.getItemBool(SettingKeys.sentry); - } - - static final sentry = SentryClient(SentryOptions(dsn: AppConfig.sentryDns)); - - static void captureException(error, stackTrace) async { - Logs().e('Capture exception', error, stackTrace); - if (!kDebugMode && await getSentryStatus()) { - await sentry.captureException( - error, - stackTrace: stackTrace, - ); - } - } -} diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 927ba05d..51127711 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -24,7 +24,6 @@ import 'package:vrouter/vrouter.dart'; import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/utils/client_manager.dart'; import 'package:fluffychat/utils/platform_infos.dart'; -import 'package:fluffychat/utils/sentry_controller.dart'; import 'package:fluffychat/utils/uia_request_manager.dart'; import 'package:fluffychat/utils/voip_plugin.dart'; import '../config/app_config.dart'; @@ -211,7 +210,6 @@ class MatrixState extends State with WidgetsBindingObserver { } } catch (e, s) { client.onLoginStateChanged.addError(e, s); - SentryController.captureException(e, s); rethrow; } } @@ -273,12 +271,6 @@ class MatrixState extends State with WidgetsBindingObserver { } } - void _reportSyncError(SyncStatusUpdate update) => - SentryController.captureException( - update.error!.exception, - update.error!.stackTrace, - ); - void _registerSubs(String name) { final c = getClientByName(name); if (c == null) { @@ -286,9 +278,6 @@ class MatrixState extends State with WidgetsBindingObserver { 'Attempted to register subscriptions for non-existing client $name'); return; } - c.onSyncStatus.stream - .where((s) => s.status == SyncStatus.error) - .listen(_reportSyncError); onRoomKeyRequestSub[name] ??= c.onRoomKeyRequest.stream.listen((RoomKeyRequest request) async { if (widget.clients.any(((cl) => diff --git a/lib/widgets/sentry_switch_list_tile.dart b/lib/widgets/sentry_switch_list_tile.dart deleted file mode 100644 index d60df5ee..00000000 --- a/lib/widgets/sentry_switch_list_tile.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:fluffychat/utils/sentry_controller.dart'; - -class SentrySwitchListTile extends StatefulWidget { - final String label; - - const SentrySwitchListTile.adaptive({Key? key, required this.label}) - : super(key: key); - - @override - _SentrySwitchListTileState createState() => _SentrySwitchListTileState(); -} - -class _SentrySwitchListTileState extends State { - bool _enabled = false; - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: SentryController.getSentryStatus(), - builder: (context, snapshot) { - _enabled = snapshot.data ?? false; - return SwitchListTile.adaptive( - title: Text(widget.label), - value: _enabled, - onChanged: (b) => - SentryController.toggleSentryAction(context, b).then( - (_) => setState(() {}), - ), - ); - }); - } -} diff --git a/pubspec.lock b/pubspec.lock index 2a670aa4..5a693be5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1500,13 +1500,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.5" - sentry: - dependency: "direct main" - description: - name: sentry - url: "https://pub.dartlang.org" - source: hosted - version: "6.4.0" share_plus: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 4c5b62eb..5f2c71f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -76,7 +76,6 @@ dependencies: receive_sharing_intent: ^1.4.5 record: ^4.3.2 scroll_to_index: ^3.0.1 - sentry: ^6.3.0 share_plus: ^4.0.9 shared_preferences: ^2.0.13 slugify: ^2.0.0