我使用 Crashlytics 来监视应用程序中的崩溃,包括 JavaScript 错误。但在发布中,我返回的堆栈跟踪不可用(仅有关bundle.js的信息)。
这适用于 NativeScript 应用程序。目前我捕获了 JS 错误并将其发送到 Crashlytics 中,但错误是这样的(因为我使用 --bundle --env.uglify):
at e.crash (file:///data/data/com.appwhite.android/files/app/bundle.js:1:36166)
at Object.handleEvent (file:///data/data/com.appwhite.android/files/app/bundle.js:1:39772)
at handleEvent (file:///data/data/com.appwhite.android/files/app/vendor.js:1:221997)
我想要一个可以使用原始文件读取的堆栈跟踪:
at HomeComponent.crash (file:///data/data/com.appwhite.android/files/app/app/main/home/home.component.js:99:16)
at Object.eval [as handleEvent] (ng:///AppModule/HomeComponent.ngfactory.js:13:27)
at handleEvent (file:///data/data/com.appwhite.android/files/app/tns_modules/@angular/core/bundles/core.umd.js:21694:45)
最佳答案
我建议你看看这个帖子:https://github.com/NativeScript/nativescript-dev-webpack/pull/854#issuecomment-490090453
简而言之,您可以使用 --env.hiddenSourceMap
并在 native 应用程序之外的某个位置生成外部源映射,以避免因源映射而增加应用程序大小。然后,您可以使用这些隐藏的源映射并使用 https://sourcemaps.info/ 等工具转换堆栈跟踪。
关于javascript - 是否可以使用源映射通过 NativeScript 生成可用的堆栈跟踪(例如使用 Crashlytics),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56254100/