javascript - 使用 Sentry 的 Raven JS 收集所有 HTTP 错误

标签 javascript logging sentry raven

我已经设置了一个 Sentry 应用程序来收集客户端可能发生的 HTTP/JS 错误。但是,似乎当我尝试发出大约 400 个 HTTP 请求时,Sentry 未能相应地捕获请求。

这是 Sentry 的默认行为,还是我的代码(如下)中缺少某些内容?

<!DOCTYPE html>
<html>
    <head>
            <title>Hi there</title>
            <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
            <script src="https://cdn.ravenjs.com/2.1.1/raven.min.js"></script>
            <script>Raven.config('http://xxx@xxx.xxxxx.com/4').install();</script>
    </head>
    <body>
        Hello the world :-)
        <script type="text/javascript">
            $.get("http://somehttp400url.com/");
        </script>
    </body>
</html>

感谢您的反馈

最佳答案

您可以使用 ajaxError 处理程序 (https://api.jquery.com/ajaxError/):

$( document ).ajaxError(function( event, request, settings ) {
  Raven.captureException(new Error(JSON.stringify(request)));
});

关于javascript - 使用 Sentry 的 Raven JS 收集所有 HTTP 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35722717/

相关文章:

javascript - 为什么我的 javascript 文件是唯一出现 404 错误的文件?

java:记录抛出的异常

c++ - 将 C++ 结构转储到文本文件

c# - 在 C# 中使用 Sentry 记录未处理的异常

python - 如何忽略 Sentry Python SDK 中的记录器

javascript - 在 React 渲染函数中使用 jQuery

javascript - 在鼠标悬停时为另一个 div 上的按钮更改图像

javascript - 如何使用多个变量来创建多个jquery选择器?

Python 在日志记录中向基于 structlog 的格式化程序添加额外的字段

django - Sentry 升级错误