Merge branch 'krille/remove-sentry' into 'main'

chore: Remove error logging with sentry

See merge request famedly/fluffychat!983
This commit is contained in:
Krille Fear 2022-08-14 14:31:43 +00:00
commit cdcef393e7
13 changed files with 9 additions and 119 deletions

View File

@ -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<a id="2"/>
FluffyChat uses Sentry for crash reports if the user allows it.
More information is available at: [https://sentry.io](https://sentry.io)
## Database<a id="3"/>
FluffyChat caches some data received from the server in a local database on the device of the user.

View File

@ -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),
);
}

View File

@ -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

View File

@ -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<AudioPlayerWidget> {
content: Text(L10n.of(context)!.oopsSomethingWentWrong),
),
);
SentryController.captureException(e, s);
Logs().w('Error while playing audio', e, s);
});
}

View File

@ -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<EventVideoPlayer> {
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));

View File

@ -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<RecordingDialog> {
_duration += const Duration(milliseconds: 100);
});
});
} catch (e, s) {
SentryController.captureException(e, s);
} catch (_) {
setState(() => error = true);
rethrow;
}
}

View File

@ -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,

View File

@ -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;
}

View File

@ -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<void> toggleSentryAction(
BuildContext context, bool enableSentry) async {
if (!AppConfig.enableSentry) return;
final storage = Store();
await storage.setItemBool(SettingKeys.sentry, enableSentry);
return;
}
static Future<bool> 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,
);
}
}
}

View File

@ -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<Matrix> with WidgetsBindingObserver {
}
} catch (e, s) {
client.onLoginStateChanged.addError(e, s);
SentryController.captureException(e, s);
rethrow;
}
}
@ -273,12 +271,6 @@ class MatrixState extends State<Matrix> 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<Matrix> 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) =>

View File

@ -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<SentrySwitchListTile> {
bool _enabled = false;
@override
Widget build(BuildContext context) {
return FutureBuilder<bool>(
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(() {}),
),
);
});
}
}

View File

@ -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:

View File

@ -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