From 79aca0e579b9f79dc2e5eebfc3342cac23bf9477 Mon Sep 17 00:00:00 2001 From: Aunali321 Date: Sat, 15 Oct 2022 15:01:31 +0530 Subject: [PATCH] feat: firebase crashlytics for improving manager. --- .gitignore | 4 +++- lib/main.dart | 15 +++++++++++++-- pubspec.yaml | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0bdfcfd0..bddb3226 100644 --- a/.gitignore +++ b/.gitignore @@ -140,4 +140,6 @@ Firebase related # Environment variables .env lib\utils\env_class.g.dart -/lib/utils/env_class.dart \ No newline at end of file +/lib/utils/env_class.dart +/lib/firebase_options.dart +android/app/google-services.json diff --git a/lib/main.dart b/lib/main.dart index d286d0ce..d4a0b34d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -12,6 +13,8 @@ import 'package:revanced_manager/utils/env_class.dart'; import 'package:stacked_themes/stacked_themes.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:timezone/data/latest.dart' as tz; +import 'package:firebase_core/firebase_core.dart'; +import 'firebase_options.dart'; Future main() async { await ThemeManager.initialise(); @@ -20,6 +23,8 @@ Future main() async { await locator().initialize(); String apiUrl = locator().getApiUrl(); await locator().initialize(apiUrl); + // Remove this line if you are building from source and don't have firebase + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); bool isSentryEnabled = locator().isSentryEnabled(); locator().initialize(); await locator().initialize(); @@ -27,7 +32,7 @@ Future main() async { await SentryFlutter.init( (options) { options - ..dsn = isSentryEnabled ? Env.SENTRY_DSN : '' + ..dsn = isSentryEnabled ? Env.sentry_dsn : '' ..environment = 'alpha' ..release = '0.1' ..tracesSampleRate = 1.0 @@ -45,7 +50,13 @@ Future main() async { } } as BeforeSendCallback?; }, - appRunner: () => runApp(const MyApp()), + appRunner: () { + // Pass all uncaught errors from the framework to Crashlytics. + FlutterError.onError = + FirebaseCrashlytics.instance.recordFlutterFatalError; + + runApp(const MyApp()); + }, ); } diff --git a/pubspec.yaml b/pubspec.yaml index 8c64f7c5..c62ecfb2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -74,6 +74,8 @@ dependencies: wakelock: ^0.6.2 sentry_dio: ^6.12.2 envied: ^0.2.3 + firebase_core: ^1.24.0 + firebase_crashlytics: ^2.9.0 dev_dependencies: json_serializable: ^6.3.1