From 7976da439f8727cc77e551ed19c5c1dbfdc38f09 Mon Sep 17 00:00:00 2001 From: misakajimmy Date: Fri, 17 Feb 2023 20:40:43 +0800 Subject: [PATCH] DEV UPDATE:Add sentry --- lib/main.dart | 14 +++++++++-- linux/flutter/generated_plugin_registrant.cc | 4 ++++ linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ pubspec.lock | 24 +++++++++++++++++++ pubspec.yaml | 3 ++- .../flutter/generated_plugin_registrant.cc | 3 +++ windows/flutter/generated_plugins.cmake | 1 + 8 files changed, 49 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 925480c..6c1862e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,10 +9,11 @@ import 'package:flutter/material.dart'; import 'package:eoe_fans/states/ProfileChangeNotifier.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; import 'common/Global.dart'; -void main() { +Future main() async { WidgetsFlutterBinding.ensureInitialized(); if (Platform.isAndroid) { // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。 @@ -20,7 +21,16 @@ void main() { SystemUiOverlayStyle(statusBarColor: Colors.transparent); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); } - Global.init().then((e) => runApp(MyApp())); + await SentryFlutter.init( + (options) { + options.dsn = + 'https://af432d5302db4e71801cf78e91fd5b78@sentry.vtb.link/4'; + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1.0; + }, + appRunner: () => Global.init().then((e) => runApp(MyApp())), + ); } class MyApp extends StatelessWidget { diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index f6f23bf..25e690a 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,9 +6,13 @@ #include "generated_plugin_registrant.h" +#include #include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) sentry_flutter_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin"); + sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index f16b4c3..2f5154f 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + sentry_flutter url_launcher_linux ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index fb60284..3b68459 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,6 +7,7 @@ import Foundation import package_info_plus import path_provider_foundation +import sentry_flutter import shared_preferences_foundation import sqflite import url_launcher_macos @@ -14,6 +15,7 @@ import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) diff --git a/pubspec.lock b/pubspec.lock index c2670b6..315be3a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -440,6 +440,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.7.1" + intl: + dependency: transitive + description: + name: intl + sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.18.0" io: dependency: transitive description: @@ -728,6 +736,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.27.7" + sentry: + dependency: transitive + description: + name: sentry + sha256: "81c1f32496ff04476d6ddfe5894215b1034d185301d2e3dffd272853392c5ea7" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.20.1" + sentry_flutter: + dependency: "direct main" + description: + name: sentry_flutter + sha256: "5ca2c8d86c220f7ad3109bedceb2c51b0e90bac5218e732be98ea2cba8006461" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.20.1" settings_ui: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 23742ca..697f2ff 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.6.2+1 +version: 1.6.3+1 environment: sdk: '>=2.18.6 <3.0.0' @@ -53,6 +53,7 @@ dependencies: image_gallery_saver: ^1.7.1 fluttertoast: ^8.1.3 modal_bottom_sheet: ^2.1.2 + sentry_flutter: ^6.20.1 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 4f78848..2272406 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,9 +6,12 @@ #include "generated_plugin_registrant.h" +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { + SentryFlutterPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SentryFlutterPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 88b22e5..33f774d 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + sentry_flutter url_launcher_windows )