Senty reporting. Fix background location tracking crash
This commit is contained in:
@ -30,6 +30,7 @@ import 'package:uni_links/uni_links.dart';
|
||||
import 'package:workmanager/workmanager.dart' as workManager;
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:battery/battery.dart';
|
||||
import 'package:sentry/sentry.dart';
|
||||
|
||||
import 'utils/logger.dart';
|
||||
|
||||
@ -138,6 +139,7 @@ part 'entities/media_player/widgets/media_player_progress_bar.widget.dart';
|
||||
part 'pages/whats_new.page.dart';
|
||||
|
||||
EventBus eventBus = new EventBus();
|
||||
final SentryClient _sentry = SentryClient(dsn: "https://03ef364745cc4c23a60ddbc874c69925@sentry.io/1836118");
|
||||
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
||||
const String appName = "HA Client";
|
||||
@ -145,11 +147,31 @@ const appVersionNumber = "0.7.4";
|
||||
const appVersionAdd = "";
|
||||
const appVersion = "$appVersionNumber$appVersionAdd";
|
||||
|
||||
void main() async {
|
||||
FlutterError.onError = (errorDetails) {
|
||||
Logger.e( "${errorDetails.exception}");
|
||||
Future<void> _reportError(dynamic error, dynamic stackTrace) async {
|
||||
// Print the exception to the console.
|
||||
if (Logger.isInDebugMode) {
|
||||
FlutterError.dumpErrorToConsole(errorDetails);
|
||||
Logger.e('Caught error: $error');
|
||||
Logger.p(stackTrace);
|
||||
return;
|
||||
} else {
|
||||
Logger.e('Caught error: $error. Reporting to Senrty.');
|
||||
// Send the Exception and Stacktrace to Sentry in Production mode.
|
||||
_sentry.captureException(
|
||||
exception: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() async {
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
Logger.e(" Caut Flutter runtime error: ${details.exception}");
|
||||
if (Logger.isInDebugMode) {
|
||||
FlutterError.dumpErrorToConsole(details);
|
||||
} else {
|
||||
// In production mode, report to the application zone to report to
|
||||
// Sentry.
|
||||
Zone.current.handleUncaughtError(details.exception, details.stack);
|
||||
}
|
||||
};
|
||||
|
||||
@ -161,11 +183,7 @@ void main() async {
|
||||
runApp(new HAClientApp());
|
||||
|
||||
}, onError: (error, stack) {
|
||||
Logger.e("$error");
|
||||
Logger.e("$stack");
|
||||
if (Logger.isInDebugMode) {
|
||||
debugPrint("$stack");
|
||||
}
|
||||
_reportError(error, stack);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user