diff --git a/lib/main.dart b/lib/main.dart index 0c5ab5f..ffc5c81 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,11 @@ +import 'dart:async'; + import 'package:checker/db.dart'; import 'package:checker/strings.dart'; import 'package:flutter/material.dart'; import 'package:checker/screens/splash.dart'; import 'package:flutter/services.dart'; +import 'package:sentry/sentry.dart'; const platform = const MethodChannel('com.dinect.checker/instance_id'); @@ -50,8 +53,23 @@ createSettingsTable(String app, String name, SqliteHelper helper) { } start(String app, String name, String locale, SqliteHelper helper) { + final SentryClient sentry = new SentryClient( + dsn: 'https://42166056b75d4fe49455555a9bc576a0@sentry.io/1376057'); + + FlutterError.onError = (FlutterErrorDetails details) { + FlutterError.dumpErrorToConsole(details); + Zone.current.handleUncaughtError(details.exception, details.stack); + }; + StringsLocalization.load(locale).then((_) { - runApp(new Checker(app, name, helper)); + runZoned>(() async { + runApp(new Checker(app, name, helper)); + }, onError: (error, stackTrace) async { + sentry.captureException( + exception: error, + stackTrace: stackTrace, + ); + }); }); } diff --git a/pubspec.lock b/pubspec.lock index 79befe2..23f48b0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -76,6 +76,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.2" + sentry: + dependency: "direct main" + description: + name: sentry + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" sky_engine: dependency: transitive description: flutter @@ -102,6 +109,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.2+1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.3" string_scanner: dependency: transitive description: @@ -123,6 +137,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.6" + usage: + dependency: transitive + description: + name: usage + url: "https://pub.dartlang.org" + source: hosted + version: "3.4.1" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5772327..5746b44 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,6 +8,7 @@ dependencies: sqflite: "0.12.2+1" image_picker: '^0.4.1' # use for ask permissions @ iOS xml: "^3.0.0" + sentry: 2.2.0 flutter: sdk: flutter