在 Next.js 项目中集成 Sentry

Lir*_*anC 7 javascript sentry next.js

我正在将 Next.js 与 AMP 一起使用。这意味着我的代码仅在服务器上运行。没有客户端代码。

我试图整合@sentry/node 然而,当我独自加入这行来index.js/pages const Sentry = require('@sentry/node');

构建失败并出现以下错误:

[ wait ]  compiling ...
[ error ] ./node_modules/@sentry/node/esm/integrations/console.js
Module not found: Can't resolve 'console' in '/Users/lirancohen/Projects/amp-app/node_modules/@sentry/node/esm/integrations'
Run Code Online (Sandbox Code Playgroud)

我将不胜感激任何帮助理解这个问题。使用 next 9.0.1 和 sentry 5.0.5

小智 2

作为替代方案,您不需要使用@sentry/node. 您也可以使用@sentry/browser。查看此链接以查看示例实现。

或者,您可以在这里找到一个有详细记录的with-sentry选项,使用npx create-react-app.