如何从哨兵Flutter获取有用的堆栈跟踪

时间:2020-09-05 05:24:46

标签: flutter sentry

我已将哨兵添加到我的flutter应用程序中。在产品应用中,我遇到了一些异常。但是哨兵没有捕获引起问题的电话号码和代码。

示例

PlatformAssetBundle.load中的FlutterError asset_bundle.dart FlutterError:无法加载资产:文件“ asset_bundle.dart”,行 223,在PlatformAssetBundle.load文件中,“”
AssetBundle.loadString文件中的文件“ asset_bundle.dart”,第69行 “”文件“ picture_provider.dart”,第449行, AssetBundlePictureProvider._loadAsync中的文件“”文件“未分析的”文件“”
文件“未解析”

哨兵整合

    Future<Null> main() async {
      FlutterError.onError = (FlutterErrorDetails details) async {
        if (isInDebugMode) {
          // In development mode simply print to console.
          FlutterError.dumpErrorToConsole(details);
        } else {
          // In production mode report to the application zone to report to
          // Sentry.
          Zone.current.handleUncaughtError(details.exception, details.stack);
        }
      };
    
      runZonedGuarded<Future<Null>>(() async {
        runApp(new Application());
      }, (error, stackTrace) async {
        await _reportError(error, stackTrace);
      });
    }
    
    
    Future<Null> _reportError(dynamic error, dynamic stackTrace) async {

    final AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo;
       var event= Event(
          release: Constants.APP_VERSION,
          environment: 'production',
          userContext: User(id: Constants.customerMobile),
          extra: <String, dynamic>{
            'type': androidDeviceInfo.type,
            'model': androidDeviceInfo.model,
            'device': androidDeviceInfo.device,
            'id': androidDeviceInfo.id,
            'androidId': androidDeviceInfo.androidId,
            'brand': androidDeviceInfo.brand,
            'display': androidDeviceInfo.display,
            'hardware': androidDeviceInfo.hardware,
            'manufacturer': androidDeviceInfo.manufacturer,
            'product': androidDeviceInfo.product,
            'version': androidDeviceInfo.version.release,
            'supported32BitAbis': androidDeviceInfo.supported32BitAbis,
            'supported64BitAbis': androidDeviceInfo.supported64BitAbis,
            'supportedAbis': androidDeviceInfo.supportedAbis,
            'isPhysicalDevice': androidDeviceInfo.isPhysicalDevice,
          },
          exception: exception,
          stackTrace: stackTrace,
          culprit: exception is DioError ? exception.request.path : "",
        );
    
      await _sentry.capture(event: event);
}

0 个答案:

没有答案