From 442d910dbdcdc9d1dae519c6e44085874ddf2f76 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Mon, 14 Jun 2021 14:35:10 +0800 Subject: [PATCH] feat: crash report closes #114 --- ios/Podfile.lock | 22 ++++++++ lib/main.dart | 131 ++++++++++++++++++++++------------------------- pubspec.lock | 63 +++++++++++++++++++++++ pubspec.yaml | 1 + 4 files changed, 146 insertions(+), 71 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 44b8cd6..b06fd7f 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -4,6 +4,15 @@ PODS: - Flutter - package_info (0.0.1): - Flutter + - package_info_plus (0.4.5): + - Flutter + - Sentry (7.1.3): + - Sentry/Core (= 7.1.3) + - Sentry/Core (7.1.3) + - sentry_flutter (0.0.1): + - Flutter + - FlutterMacOS + - Sentry (~> 7.1.3) - share (0.0.1): - Flutter - shared_preferences (0.0.1): @@ -19,12 +28,18 @@ DEPENDENCIES: - Flutter (from `Flutter`) - launch_review (from `.symlinks/plugins/launch_review/ios`) - package_info (from `.symlinks/plugins/package_info/ios`) + - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) + - sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`) - share (from `.symlinks/plugins/share/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - uni_links (from `.symlinks/plugins/uni_links/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) - webview_flutter (from `.symlinks/plugins/webview_flutter/ios`) +SPEC REPOS: + trunk: + - Sentry + EXTERNAL SOURCES: Flutter: :path: Flutter @@ -32,6 +47,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/launch_review/ios" package_info: :path: ".symlinks/plugins/package_info/ios" + package_info_plus: + :path: ".symlinks/plugins/package_info_plus/ios" + sentry_flutter: + :path: ".symlinks/plugins/sentry_flutter/ios" share: :path: ".symlinks/plugins/share/ios" shared_preferences: @@ -47,6 +66,9 @@ SPEC CHECKSUMS: Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c launch_review: 75d5a956ba8eaa493e9c9d4bf4c05e505e8d5ed0 package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 + package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e + Sentry: 6d963d64804dd06d96e778be729613f481394312 + sentry_flutter: f20d4f199442900fbdab2b8496f1d2091d8b94d9 share: 0b2c3e82132f5888bccca3351c504d0003b3b410 shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d uni_links: d97da20c7701486ba192624d99bffaaffcfc298a diff --git a/lib/main.dart b/lib/main.dart index 910d728..206c66f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,80 +8,69 @@ import 'package:git_touch/router.dart'; import 'package:provider/provider.dart'; import 'package:git_touch/models/notification.dart'; import 'package:fluro/fluro.dart'; -import 'package:fimber/fimber.dart'; import 'package:flutter/services.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; void main() async { - WidgetsFlutterBinding.ensureInitialized(); - // Platform messages may fail, so we use a try/catch PlatformException. + await SentryFlutter.init( + (options) { + options.dsn = + 'https://006354525fa244289c48169790fa3757@o71119.ingest.sentry.io/5814819'; + }, + // Init your App. + appRunner: () async { + final notificationModel = NotificationModel(); + final themeModel = ThemeModel(); + final authModel = AuthModel(); + final codeModel = CodeModel(); + await Future.wait([ + themeModel.init(), + authModel.init(), + codeModel.init(), + ]); - // try { - // String initialLink = await getInitialLink(); - // Fimber.d(initialLink); - // } on PlatformException { - // Fimber.d('test'); - // } + CommonRouter.routes.forEach((screen) { + themeModel.router.define(CommonRouter.prefix + screen.path, + handler: Handler(handlerFunc: screen.handler)); + }); + GitlabRouter.routes.forEach((screen) { + themeModel.router.define(GitlabRouter.prefix + screen.path, + handler: Handler(handlerFunc: screen.handler)); + }); + GiteaRouter.routes.forEach((screen) { + themeModel.router.define(GiteaRouter.prefix + screen.path, + handler: Handler(handlerFunc: screen.handler)); + }); + BitbucketRouter.routes.forEach((screen) { + themeModel.router.define(BitbucketRouter.prefix + screen.path, + handler: Handler(handlerFunc: screen.handler)); + }); + GithubRouter.routes.forEach((screen) { + themeModel.router.define(GithubRouter.prefix + screen.path, + handler: Handler(handlerFunc: screen.handler)); + }); + GiteeRouter.routes.forEach((screen) { + themeModel.router.define(GiteeRouter.prefix + screen.path, + handler: Handler(handlerFunc: screen.handler)); + }); + GogsRouter.routes.forEach((screen) { + themeModel.router.define(GogsRouter.prefix + screen.path, + handler: Handler(handlerFunc: screen.handler)); + }); + // To match status bar color to app bar color + SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + )); - // DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); - // AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; - // Fimber.d('Running on ${androidInfo.model}'); // e.g. "Moto G (4)" - - // IosDeviceInfo iosInfo = await deviceInfo.iosInfo; - // Fimber.d('Running on ${iosInfo.utsname.machine}'); // e.g. "iPod7,1" - - // TODO: Later, should check to enable debug log in debug build only - Fimber.plantTree(DebugTree()); - - final notificationModel = NotificationModel(); - final themeModel = ThemeModel(); - final authModel = AuthModel(); - final codeModel = CodeModel(); - await Future.wait([ - themeModel.init(), - authModel.init(), - codeModel.init(), - ]); - - CommonRouter.routes.forEach((screen) { - themeModel.router.define(CommonRouter.prefix + screen.path, - handler: Handler(handlerFunc: screen.handler)); - }); - GitlabRouter.routes.forEach((screen) { - themeModel.router.define(GitlabRouter.prefix + screen.path, - handler: Handler(handlerFunc: screen.handler)); - }); - GiteaRouter.routes.forEach((screen) { - themeModel.router.define(GiteaRouter.prefix + screen.path, - handler: Handler(handlerFunc: screen.handler)); - }); - BitbucketRouter.routes.forEach((screen) { - themeModel.router.define(BitbucketRouter.prefix + screen.path, - handler: Handler(handlerFunc: screen.handler)); - }); - GithubRouter.routes.forEach((screen) { - themeModel.router.define(GithubRouter.prefix + screen.path, - handler: Handler(handlerFunc: screen.handler)); - }); - GiteeRouter.routes.forEach((screen) { - themeModel.router.define(GiteeRouter.prefix + screen.path, - handler: Handler(handlerFunc: screen.handler)); - }); - GogsRouter.routes.forEach((screen) { - themeModel.router.define(GogsRouter.prefix + screen.path, - handler: Handler(handlerFunc: screen.handler)); - }); - // To match status bar color to app bar color - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( - statusBarColor: Colors.transparent, - )); - - runApp(MultiProvider( - providers: [ - ChangeNotifierProvider(create: (context) => notificationModel), - ChangeNotifierProvider(create: (context) => themeModel), - ChangeNotifierProvider(create: (context) => authModel), - ChangeNotifierProvider(create: (context) => codeModel), - ], - child: MyApp(), - )); + runApp(MultiProvider( + providers: [ + ChangeNotifierProvider(create: (context) => notificationModel), + ChangeNotifierProvider(create: (context) => themeModel), + ChangeNotifierProvider(create: (context) => authModel), + ChangeNotifierProvider(create: (context) => codeModel), + ], + child: MyApp(), + )); + }, + ); } diff --git a/pubspec.lock b/pubspec.lock index 9ad1ba9..45f5809 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -546,6 +546,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + package_info_plus: + dependency: transitive + description: + name: package_info_plus + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_info_plus_linux: + dependency: transitive + description: + name: package_info_plus_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_info_plus_macos: + dependency: transitive + description: + name: package_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + package_info_plus_web: + dependency: transitive + description: + name: package_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_info_plus_windows: + dependency: transitive + description: + name: package_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" path: dependency: transitive description: @@ -679,6 +721,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.26.0" + sentry: + dependency: transitive + description: + name: sentry + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" + sentry_flutter: + dependency: "direct main" + description: + name: sentry_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" share: dependency: "direct main" description: @@ -908,6 +964,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + uuid: + dependency: transitive + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.4" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2a12856..cbea7be 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,6 +50,7 @@ dependencies: uri: ^1.0.0 url_launcher: ^6.0.3 webview_flutter: ^2.0.4 + sentry_flutter: ^5.1.0 dev_dependencies: flutter_test: