javascript - React Native 中的远程错误日志记录

标签 javascript exception logging react-native

我希望能够在我的 React Native 应用程序中看到生产中发生的错误。

在我的 Cordova 应用程序中,我做了类似的事情

window.onerror = function (error, msg, line) {
    Flurry.logError(...);
}

有没有办法在 React Native 中做类似的事情?我猜我可以从 ExceptionsManager.js 开始但我想知道是否已经有一些东西了。

最佳答案

我发现 ErrorUtils 类具有 setGlobalHandler 方法。

if (__DEV__ === false) {
    var ErrorUtils = require("ErrorUtils");
    var Flurry = require("Flurry");
    ErrorUtils.setGlobalHandler((error, isFatal) => {
        Flurry.logError(error, isFatal);
    });
}

似乎工作正常,但我不确定我是否应该使用它或者它是否应该是私有(private)的。

关于javascript - React Native 中的远程错误日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33628095/

相关文章:

javascript - 什么时候使用 this.getInitialView = this.getInitialView.bind(this);

c# - 为什么这会导致 'Index out of range' 异常?

python - "Linking"或在 Python 中转发子记录器

c# - 请求失败,HTTP 状态为 417 : Expectation Failed - Using Web Services

c# - x64 的 form_load 中忽略的异常

logging - 解释 Heroku 日志的格式

authentication - 垃圾邮件查杀网站认证吗?

javascript - Jquery 更改 .text(something) 然后返回

javascript - 通过 PhoneGap 构建游戏

javascript - 防止下载 HTML5 视频(右键保存)?