Replace Sentry with Crashlytics

This commit is contained in:
Yegor Vialov 2020-02-11 12:06:19 +00:00
parent 2c35dd7c21
commit b750417415
5 changed files with 18 additions and 15 deletions

View File

@ -84,4 +84,5 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

View File

@ -2,11 +2,15 @@ buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
@ -14,6 +18,9 @@ allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
}

View File

@ -27,7 +27,7 @@ import 'plugins/spoiler_card.dart';
import 'package:workmanager/workmanager.dart' as workManager;
import 'package:geolocator/geolocator.dart';
import 'package:battery/battery.dart';
import 'package:sentry/sentry.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'utils/logger.dart';
@ -137,7 +137,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 SentryClient _sentry = SentryClient(dsn: "https://03ef364745cc4c23a60ddbc874c69925@sentry.io/1836118");
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
const String appName = "HA Client";
@ -150,27 +150,21 @@ Future<void> _reportError(dynamic error, dynamic stackTrace) async {
if (Logger.isInDebugMode) {
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,
);
}
Crashlytics.instance.recordError(error, stackTrace);
}
void main() async {
//TODO remove when configured
Crashlytics.instance.enableInDevMode = true;
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);
}
Crashlytics.instance.recordFlutterError(details);
};
runZoned(() {

View File

@ -131,6 +131,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
}
});
eventBus.fire(RefreshDataFinishedEvent());
throw new Exception("There is an error thrown specifically for Crashlitycs reporting test!");
}
@override

View File

@ -29,7 +29,7 @@ dependencies:
geolocator: ^5.2.1
workmanager: ^0.2.0
battery: ^0.3.1+7
sentry: ^2.3.1
firebase_crashlytics: ^0.1.2+5
dev_dependencies: