feat:添加 bugly 错误日志监控
This commit is contained in:
parent
af04296143
commit
f5b28cf6bb
@ -22,7 +22,8 @@
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
||||
<!--允许写设备缓存,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
||||
<!--允许写入扩展存储,用于写入缓存定位数据-->
|
||||
<!--允许读设备日志,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
|
||||
<!--相机-->
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
|
||||
@ -36,6 +36,7 @@ PODS:
|
||||
- Flutter
|
||||
- auto_orientation (0.0.1):
|
||||
- Flutter
|
||||
- Bugly (2.6.1)
|
||||
- camera_avfoundation (0.0.1):
|
||||
- Flutter
|
||||
- connectivity_plus (0.0.1):
|
||||
@ -81,6 +82,9 @@ PODS:
|
||||
- Flutter (1.0.0)
|
||||
- flutter_blue_plus (0.0.1):
|
||||
- Flutter
|
||||
- flutter_bugly_plugin (0.0.1):
|
||||
- Bugly
|
||||
- Flutter
|
||||
- flutter_local_notifications (0.0.1):
|
||||
- Flutter
|
||||
- flutter_native_contact_picker (0.0.1):
|
||||
@ -170,6 +174,7 @@ DEPENDENCIES:
|
||||
- file_picker (from `.symlinks/plugins/file_picker/ios`)
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_blue_plus (from `.symlinks/plugins/flutter_blue_plus/ios`)
|
||||
- flutter_bugly_plugin (from `.symlinks/plugins/flutter_bugly_plugin/ios`)
|
||||
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
|
||||
- flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`)
|
||||
- flutter_pcm_sound (from `.symlinks/plugins/flutter_pcm_sound/ios`)
|
||||
@ -205,6 +210,7 @@ SPEC REPOS:
|
||||
- AMap3DMap
|
||||
- AMapFoundation
|
||||
- AMapLocation
|
||||
- Bugly
|
||||
- DKImagePickerController
|
||||
- DKPhotoGallery
|
||||
- GoogleMaps
|
||||
@ -248,6 +254,8 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter
|
||||
flutter_blue_plus:
|
||||
:path: ".symlinks/plugins/flutter_blue_plus/ios"
|
||||
flutter_bugly_plugin:
|
||||
:path: ".symlinks/plugins/flutter_bugly_plugin/ios"
|
||||
flutter_local_notifications:
|
||||
:path: ".symlinks/plugins/flutter_local_notifications/ios"
|
||||
flutter_native_contact_picker:
|
||||
@ -309,6 +317,7 @@ SPEC CHECKSUMS:
|
||||
audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207
|
||||
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
|
||||
auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d
|
||||
Bugly: 217ac2ce5f0f2626d43dbaa4f70764c953a26a31
|
||||
camera_avfoundation: 759172d1a77ae7be0de08fc104cfb79738b8a59e
|
||||
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
|
||||
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
|
||||
@ -318,6 +327,7 @@ SPEC CHECKSUMS:
|
||||
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
|
||||
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
||||
flutter_blue_plus: 4837da7d00cf5d441fdd6635b3a57f936778ea96
|
||||
flutter_bugly_plugin: d2db6d6641938269fa538575126e8ff530ee02c7
|
||||
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
|
||||
flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907
|
||||
flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e
|
||||
|
||||
@ -23,7 +23,8 @@ class AppLog {
|
||||
// if(!_printLog)return;
|
||||
// if(_onlyError && !error) return;
|
||||
if (error) {
|
||||
msg = '----->>> $msg $stackTrace';
|
||||
final bool stackTraceIsNull = stackTrace != null;
|
||||
msg = '----->>> $msg ${stackTraceIsNull ? '\n$stackTrace' : ''}';
|
||||
}
|
||||
Get.log(msg);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class F {
|
||||
switch (appFlavor) {
|
||||
case Flavor.local:
|
||||
return 'https://ge.lock.star-lock.cn'; // 葛工
|
||||
// return 'http://192.168.1.15:8022'; // 谢工
|
||||
// return 'http://192.168.1.15:8022'; // 谢工
|
||||
case Flavor.dev:
|
||||
return 'https://dev.lock.star-lock.cn';
|
||||
case Flavor.pre:
|
||||
@ -95,7 +95,7 @@ class F {
|
||||
return 'https://lock.skychip.top';
|
||||
case Flavor.xhj:
|
||||
return 'https://lock.xhjcn.ltd';
|
||||
// return 'https://pre.lock.star-lock.cn';
|
||||
// return 'https://pre.lock.star-lock.cn';
|
||||
default:
|
||||
throw Exception('flavor[$name] apiPrefix not found');
|
||||
}
|
||||
@ -125,4 +125,19 @@ class F {
|
||||
throw Exception('flavor[$name] aMapKey not found');
|
||||
}
|
||||
}
|
||||
|
||||
// 是否是生产环境
|
||||
static bool get isProductionEnv {
|
||||
switch (appFlavor) {
|
||||
case Flavor.local:
|
||||
case Flavor.dev:
|
||||
case Flavor.pre:
|
||||
return false;
|
||||
case Flavor.sky:
|
||||
case Flavor.xhj:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/tools/bugly/bugly_tool.dart';
|
||||
import 'package:star_lock/tools/device_info_service.dart';
|
||||
import 'package:star_lock/tools/platform_info_services.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
@ -21,18 +24,9 @@ FutureOr<void> main() async {
|
||||
// 设置国际化信息
|
||||
await _initTranslation();
|
||||
|
||||
//错误日志监控
|
||||
FlutterError.onError = (FlutterErrorDetails details) async {
|
||||
AppLog.log('error:${details.exception.toString()}',
|
||||
stackTrace: details.stack, error: true);
|
||||
Zone.current.handleUncaughtError(details.exception, details.stack!);
|
||||
};
|
||||
|
||||
//错误日志监控
|
||||
runZonedGuarded<Future<void>>(() async {
|
||||
// bugly错误日志监控
|
||||
BuglyTool.init(() {
|
||||
runApp(const MyApp());
|
||||
}, (Object error, StackTrace stackTrace) async {
|
||||
AppLog.log('error:$error', stackTrace: stackTrace, error: true);
|
||||
});
|
||||
|
||||
if (AppPlatform.isAndroid) {
|
||||
|
||||
51
lib/tools/bugly/bugly_tool.dart
Normal file
51
lib/tools/bugly/bugly_tool.dart
Normal file
@ -0,0 +1,51 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
|
||||
///
|
||||
/// 错误日志监控
|
||||
///
|
||||
///
|
||||
class BuglyTool {
|
||||
static Future<void> init(Function on) async {
|
||||
if (F.isProductionEnv) {
|
||||
//生产
|
||||
await FlutterBuglyPlugin.init(
|
||||
appIdAndroid: '73c99cca00',
|
||||
appIdiOS: 'b25632a54f',
|
||||
);
|
||||
} else {
|
||||
//测试
|
||||
await FlutterBuglyPlugin.init(
|
||||
appIdAndroid: '02fb541c1c',
|
||||
appIdiOS: '618ab9feeb',
|
||||
);
|
||||
}
|
||||
|
||||
//错误日志监控
|
||||
FlutterError.onError = (FlutterErrorDetails details) async {
|
||||
AppLog.log('error:${details.exception.toString()}',
|
||||
stackTrace: details.stack, error: true);
|
||||
Zone.current.handleUncaughtError(
|
||||
details.exception, details.stack ?? StackTrace.empty);
|
||||
};
|
||||
|
||||
//错误日志监控
|
||||
PlatformDispatcher.instance.onError = (Object error, StackTrace stack) {
|
||||
FlutterBuglyPlugin.reportException(
|
||||
exceptionName: error.toString(), reason: stack.toString());
|
||||
AppLog.log('error:$error', stackTrace: stack, error: true);
|
||||
return true;
|
||||
};
|
||||
|
||||
//错误日志监控
|
||||
runZonedGuarded<Future<void>>(() async => on(),
|
||||
(Object error, StackTrace stackTrace) async {
|
||||
AppLog.log('error:$error', stackTrace: stackTrace, error: true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -191,6 +191,8 @@ dependencies:
|
||||
expandable: ^5.0.1
|
||||
colorfilter_generator: ^0.0.8
|
||||
file_picker: ^5.3.1
|
||||
# 错误日志监控
|
||||
flutter_bugly_plugin: ^0.0.9
|
||||
|
||||
|
||||
dependency_overrides:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user