FurryChat/lib/utils/sentry_controller.dart

43 lines
1.4 KiB
Dart
Raw Normal View History

2020-09-08 08:55:32 +00:00
import 'package:bot_toast/bot_toast.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
2020-10-28 09:56:24 +00:00
import 'package:fluffychat/config/app_config.dart';
2020-09-08 08:55:32 +00:00
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
2020-10-28 09:56:24 +00:00
import 'package:sentry/sentry.dart';
2020-10-13 10:20:13 +00:00
import 'famedlysdk_store.dart';
2020-09-08 08:55:32 +00:00
abstract class SentryController {
static Future<void> toggleSentryAction(BuildContext context) async {
final enableSentry = await SimpleDialogs(context).askConfirmation(
titleText: L10n.of(context).sendBugReports,
contentText: L10n.of(context).sentryInfo,
confirmText: L10n.of(context).ok,
cancelText: L10n.of(context).no,
);
2020-10-25 15:59:55 +00:00
final storage = Store();
await storage.setItem('sentry', enableSentry.toString());
2020-09-08 08:55:32 +00:00
BotToast.showText(text: L10n.of(context).changesHaveBeenSaved);
return;
}
static Future<bool> getSentryStatus() async {
2020-10-25 15:59:55 +00:00
final storage = Store();
return await storage.getItem('sentry') == 'true';
2020-09-08 08:55:32 +00:00
}
2020-10-28 09:56:24 +00:00
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,
);
}
}
2020-09-08 08:55:32 +00:00
}