fix: Sentry

This commit is contained in:
Christian Pauly 2020-10-28 10:56:24 +01:00
parent 4e2f489a52
commit b903ea9071
4 changed files with 22 additions and 19 deletions

View file

@ -7,6 +7,7 @@ import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/utils/firebase_controller.dart'; import 'package:fluffychat/utils/firebase_controller.dart';
import 'package:fluffychat/utils/matrix_locals.dart'; import 'package:fluffychat/utils/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/sentry_controller.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -17,7 +18,6 @@ import 'package:fluffychat/config/app_config.dart';
import 'package:dbus/dbus.dart'; import 'package:dbus/dbus.dart';
import 'package:desktop_notifications/desktop_notifications.dart';*/ import 'package:desktop_notifications/desktop_notifications.dart';*/
import '../main.dart';
import '../utils/app_route.dart'; import '../utils/app_route.dart';
import '../utils/beautify_string_extension.dart'; import '../utils/beautify_string_extension.dart';
import '../utils/famedlysdk_store.dart'; import '../utils/famedlysdk_store.dart';
@ -98,7 +98,7 @@ class MatrixState extends State<Matrix> {
} }
} catch (e, s) { } catch (e, s) {
client.onLoginStateChanged.sink.addError(e, s); client.onLoginStateChanged.sink.addError(e, s);
captureException(e, s); SentryController.captureException(e, s);
rethrow; rethrow;
} }
} }

View file

@ -6,4 +6,6 @@ abstract class AppConfig {
'https://gitlab.com/ChristianPauly/fluffychat-flutter'; 'https://gitlab.com/ChristianPauly/fluffychat-flutter';
static const String supportUrl = static const String supportUrl =
'https://gitlab.com/ChristianPauly/fluffychat-flutter/issues'; 'https://gitlab.com/ChristianPauly/fluffychat-flutter/issues';
static const String sentryDsn =
'https://8591d0d863b646feb4f3dda7e5dcab38@o256755.ingest.sentry.io/5243143';
} }

View file

@ -3,39 +3,24 @@ import 'dart:io';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/sentry_controller.dart';
import 'package:fluffychat/views/homeserver_picker.dart'; import 'package:fluffychat/views/homeserver_picker.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:sentry/sentry.dart';
import 'package:universal_html/prefer_universal/html.dart' as html; import 'package:universal_html/prefer_universal/html.dart' as html;
import 'components/matrix.dart'; import 'components/matrix.dart';
import 'components/theme_switcher.dart'; import 'components/theme_switcher.dart';
import 'utils/famedlysdk_store.dart';
import 'views/chat_list.dart'; import 'views/chat_list.dart';
final sentry = SentryClient(dsn: '8591d0d863b646feb4f3dda7e5dcab38');
void captureException(error, stackTrace) async {
debugPrint(error.toString());
debugPrint(stackTrace.toString());
final storage = Store();
if (await storage.getItem('sentry') == 'true') {
await sentry.captureException(
exception: error,
stackTrace: stackTrace,
);
}
}
void main() { void main() {
SystemChrome.setSystemUIOverlayStyle( SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent)); SystemUiOverlayStyle(statusBarColor: Colors.transparent));
runZonedGuarded( runZonedGuarded(
() => runApp(App()), () => runApp(App()),
captureException, SentryController.captureException,
); );
} }

View file

@ -1,7 +1,9 @@
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:sentry/sentry.dart';
import 'famedlysdk_store.dart'; import 'famedlysdk_store.dart';
@ -23,4 +25,18 @@ abstract class SentryController {
final storage = Store(); final storage = Store();
return await storage.getItem('sentry') == 'true'; return await storage.getItem('sentry') == 'true';
} }
static final sentry = SentryClient(dsn: AppConfig.sentryDsn);
static void captureException(error, stackTrace) async {
debugPrint(error.toString());
debugPrint(stackTrace.toString());
final storage = Store();
if (await storage.getItem('sentry') == 'true') {
await sentry.captureException(
exception: error,
stackTrace: stackTrace,
);
}
}
} }