mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-14 16:09:31 +01:00
40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
//@dart=2.12
|
|
|
|
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.setItem(SettingKeys.sentry, enableSentry.toString());
|
|
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,
|
|
);
|
|
}
|
|
}
|
|
}
|