网络相关问题没有被记录在哨兵平台上



我已经将Sentry集成到我的Next.JS应用程序之一中,并且我也能够在Sentry平台上看到JavaScript相关的错误,如引用或语法错误。

虽然哨兵在他们的平台上没有记录任何与网络相关的错误。在我的网络呼叫中得到403禁止,404未找到和500内部服务器错误,但哨兵没有报告任何这些。

我使用了以下步骤进行设置:

  1. 使用此命令安装SDKnpm install --save @sentry/nextjs
  2. 使用向导使用以下命令自动执行初始步骤npx @sentry/wizard -i nextjs
  3. 将next.config.js中的所有配置添加到next.config.wizardcopy.js
  4. 删除next.config.wizardcopy.js,并将next.config.wizardcopy.js重命名为next.config.js

我已经在我的客户端和服务器文件中初始化了Sentry,像这样

Sentry.init({
dsn: '***',
integrations: [
new CaptureConsole()
],
tracesSampleRate: 1.0
});

我已经使用了CaptureConsole方法来捕获控制台的所有错误,并在哨兵文档和不同的在线可用资源上检查网络相关错误,但没有得到帮助。

有没有人可以帮助我在相同的,我可以更多地使用得到网络相关的错误。如果不行的话,也请告诉我。

在我的情况下,我使用的是reactjs,我也添加了new BrowserTracing()。你可以试试这个

import * as Sentry from "@sentry/react";
import { CaptureConsole } from "@sentry/integrations";
import { BrowserTracing } from "@sentry/tracing";
Sentry.init({
dsn: "https://e44884be8781480fa50344a421e5aaba@o4504315282653184.ingest.sentry.io/4504315339210752",
integrations: [
new CaptureConsole(),
new BrowserTracing()
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});

问题是我在处理xhr请求时使用了try catch语句,而sentry不记录已经处理的错误(使用try catch语句),在这种情况下,必须使用captureException方法手动记录sentry上的错误

最新更新