增加sentry监控

This commit is contained in:
胡天 2023-07-26 17:17:27 +08:00
parent 743046afe2
commit ef4937ad6d
5 changed files with 43 additions and 22 deletions

View File

@ -12,12 +12,13 @@ class Global {
static Future init() async { static Future init() async {
// //
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
//
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
// UI appBar会覆盖这个设置 // UI appBar会覆盖这个设置
// setSystemUi(); // setSystemUi();
// easyLoading // easyLoading
Loading(); Loading();
await Get.putAsync<StorageService>(() => StorageService().init()); await Get.putAsync<StorageService>(() => StorageService().init());

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
@ -11,10 +10,20 @@ import 'package:news_getx/theme/app_theme.dart';
import 'package:news_getx/translations/app_translations.dart'; import 'package:news_getx/translations/app_translations.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
Future<void> main() async { Future<void> main() async {
await Global.init(); await Global.init();
runApp(const MyApp());
await SentryFlutter.init(
(options) {
options.dsn = "https://acac4fdb2abc486a9f7c64558f27d85e@o4505594886356992.ingest.sentry.io/4505594892124160";
if (ConfigService.to.isRelease) {
options.tracesSampleRate = 1.0;
}
},
appRunner: () => runApp(const MyApp()),
);
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@ -28,21 +37,19 @@ class MyApp extends StatelessWidget {
// true column就不会随着软键盘而变化 // true column就不会随着软键盘而变化
// useInheritedMediaQuery: true, // useInheritedMediaQuery: true,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
var app = GetMaterialApp( var app = GetMaterialApp(
title: 'News', title: 'News',
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: AppTheme.light.copyWith( theme: AppTheme.light.copyWith(
appBarTheme: AppBarTheme( appBarTheme: AppBarTheme(
systemOverlayStyle: SystemUiOverlayStyle( systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.transparent, statusBarColor: Colors.transparent,
statusBarBrightness: Brightness.light, statusBarBrightness: Brightness.light,
statusBarIconBrightness: Brightness.dark, statusBarIconBrightness: Brightness.dark,
systemNavigationBarDividerColor: Colors.transparent, systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarColor: Colors.white, systemNavigationBarColor: Colors.white,
systemNavigationBarIconBrightness: Brightness.dark, systemNavigationBarIconBrightness: Brightness.dark,
) )),
),
), ),
unknownRoute: AppPages.notFoundRoute, unknownRoute: AppPages.notFoundRoute,
initialRoute: AppPages.Initial, initialRoute: AppPages.Initial,
@ -70,10 +77,12 @@ class MyApp extends StatelessWidget {
footerTriggerDistance: 150, footerTriggerDistance: 150,
child: Obx(() { child: Obx(() {
// todo // todo
return ConfigService.to.isGrayFilter.isTrue ? ColorFiltered( return ConfigService.to.isGrayFilter.isTrue
colorFilter: ColorFilter.mode(Colors.grey, BlendMode.color), ? ColorFiltered(
child: app, colorFilter: ColorFilter.mode(Colors.grey, BlendMode.color),
) : app; child: app,
)
: app;
}), }),
); );
}, },

View File

@ -144,6 +144,9 @@ class AppUpdateUtil {
barrierDismissible: false, barrierDismissible: false,
); );
await downloadController.download(fileUrl, fullPath); await downloadController.download(fileUrl, fullPath);
//
downloadController.dispose();
} }
// //
await InstallPlugin.installApk(fullPath); await InstallPlugin.installApk(fullPath);

View File

@ -558,13 +558,21 @@ packages:
source: hosted source: hosted
version: "0.27.7" version: "0.27.7"
sentry: sentry:
dependency: "direct main" dependency: transitive
description: description:
name: sentry name: sentry
sha256: "377edcc3d7910745849b1621dcec7d34fc27b6c03e9e9009499dc2968ce19cd7" sha256: "8f4f1d3ef3ca1801aa3138392bbf0851b39eff703008111765b265f76c8f0190"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.1.0" version: "7.8.0"
sentry_flutter:
dependency: "direct main"
description:
name: sentry_flutter
sha256: bbc1048558cf8ae65c1e27b1249357298cfca50e5843ad0367387f5c873b8e42
url: "https://pub.flutter-io.cn"
source: hosted
version: "7.8.0"
share: share:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -88,8 +88,8 @@ dependencies:
# permission 权限 # permission 权限
permission_handler: ^10.4.3 permission_handler: ^10.4.3
# 错误收集 # sentry错误收集
sentry: ^5.0.0 sentry_flutter: ^7.8.0
# webView # webView
webview_flutter: ^4.2.2 webview_flutter: ^4.2.2