Replace Sentry with Crashlytics
This commit is contained in:
		@@ -84,4 +84,5 @@ dependencies {
 | 
				
			|||||||
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
 | 
					    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					apply plugin: 'io.fabric'
 | 
				
			||||||
apply plugin: 'com.google.gms.google-services'
 | 
					apply plugin: 'com.google.gms.google-services'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,11 +2,15 @@ buildscript {
 | 
				
			|||||||
    repositories {
 | 
					    repositories {
 | 
				
			||||||
        google()
 | 
					        google()
 | 
				
			||||||
        jcenter()
 | 
					        jcenter()
 | 
				
			||||||
 | 
					        maven {
 | 
				
			||||||
 | 
					            url 'https://maven.fabric.io/public'
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dependencies {
 | 
					    dependencies {
 | 
				
			||||||
        classpath 'com.android.tools.build:gradle:3.3.2'
 | 
					        classpath 'com.android.tools.build:gradle:3.3.2'
 | 
				
			||||||
        classpath 'com.google.gms:google-services:4.3.3'
 | 
					        classpath 'com.google.gms:google-services:4.3.3'
 | 
				
			||||||
 | 
					        classpath 'io.fabric.tools:gradle:1.26.1'
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -14,6 +18,9 @@ allprojects {
 | 
				
			|||||||
    repositories {
 | 
					    repositories {
 | 
				
			||||||
        google()
 | 
					        google()
 | 
				
			||||||
        jcenter()
 | 
					        jcenter()
 | 
				
			||||||
 | 
					        maven {
 | 
				
			||||||
 | 
					            url 'https://maven.fabric.io/public'
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ import 'plugins/spoiler_card.dart';
 | 
				
			|||||||
import 'package:workmanager/workmanager.dart' as workManager;
 | 
					import 'package:workmanager/workmanager.dart' as workManager;
 | 
				
			||||||
import 'package:geolocator/geolocator.dart';
 | 
					import 'package:geolocator/geolocator.dart';
 | 
				
			||||||
import 'package:battery/battery.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 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'utils/logger.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';
 | 
					part 'pages/whats_new.page.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EventBus eventBus = new EventBus();
 | 
					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();
 | 
					final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
 | 
				
			||||||
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
 | 
					FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
 | 
				
			||||||
const String appName = "HA Client";
 | 
					const String appName = "HA Client";
 | 
				
			||||||
@@ -150,27 +150,21 @@ Future<void> _reportError(dynamic error, dynamic stackTrace) async {
 | 
				
			|||||||
    if (Logger.isInDebugMode) {
 | 
					    if (Logger.isInDebugMode) {
 | 
				
			||||||
      Logger.e('Caught error: $error');
 | 
					      Logger.e('Caught error: $error');
 | 
				
			||||||
      Logger.p(stackTrace);
 | 
					      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 {
 | 
					void main() async {
 | 
				
			||||||
 | 
					  //TODO remove when configured
 | 
				
			||||||
 | 
					  Crashlytics.instance.enableInDevMode = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  FlutterError.onError = (FlutterErrorDetails details) {
 | 
					  FlutterError.onError = (FlutterErrorDetails details) {
 | 
				
			||||||
    Logger.e(" Caut Flutter runtime error: ${details.exception}");
 | 
					    Logger.e(" Caut Flutter runtime error: ${details.exception}");
 | 
				
			||||||
    if (Logger.isInDebugMode) {
 | 
					    if (Logger.isInDebugMode) {
 | 
				
			||||||
      FlutterError.dumpErrorToConsole(details);
 | 
					      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(() {
 | 
					  runZoned(() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -131,6 +131,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    eventBus.fire(RefreshDataFinishedEvent());
 | 
					    eventBus.fire(RefreshDataFinishedEvent());
 | 
				
			||||||
 | 
					    throw new Exception("There is an error thrown specifically for Crashlitycs reporting test!");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ dependencies:
 | 
				
			|||||||
  geolocator: ^5.2.1
 | 
					  geolocator: ^5.2.1
 | 
				
			||||||
  workmanager: ^0.2.0
 | 
					  workmanager: ^0.2.0
 | 
				
			||||||
  battery: ^0.3.1+7
 | 
					  battery: ^0.3.1+7
 | 
				
			||||||
  sentry: ^2.3.1
 | 
					  firebase_crashlytics: ^0.1.2+5
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dev_dependencies:
 | 
					dev_dependencies:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user