如果使用remove-console,如何在哨兵上记录错误?

发布于 2025-01-25 15:51:33 字数 432 浏览 1 评论 0 原文

构建生产版本时,我在Web应用程序中删除了所有 console.log 。但是,如果发生错误,我想将一些日志发送给我的哨兵。

由于设置在 babel-config.js 中删除控制台,因此我的哨兵无法获取日志。

const removeConsolePlugin = []
if (process.env.NODE_ENV === 'production') {
  removeConsolePlugin.push('transform-remove-console')
}

module.exports = {
  presets: [
    '@vue/app'
  ],
  plugins: removeConsolePlugin
}

如果在生产中需要删除孔,则如何将登录发送到哨兵?

谢谢!

I removed all console.log in my web application when building production version. But, I would like to send some logs to my sentry if errors occur.

Since setting remove console in babel-config.js, my sentry can not get logs.

const removeConsolePlugin = []
if (process.env.NODE_ENV === 'production') {
  removeConsolePlugin.push('transform-remove-console')
}

module.exports = {
  presets: [
    '@vue/app'
  ],
  plugins: removeConsolePlugin
}

How do I send log to sentry if remove-console is necessary on production?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷港 2025-02-01 15:51:33

您可以使用面包屑添加到哨兵报告中。
这也可以让您在报告中添加更丰富的数据。

请参阅Sentry的BreadCrumb功能。请注意对 Data 字段的支持,该字段可以将您要添加到报告中的任何数据。

除此之外,您正在使用的预告片转换也有一些可能对您有所帮助的选择。 Console.Error 和 console.warn ,这些然后仍将在Sentry报告中。

You can add onto sentry reports by using breadcrumbs.
That will let you add much richer data to the reports as well.

See Sentry's breadcrumb function. Note the support for the data field, which can hold any data you'd like to add onto the report.

Beyond that, the babel transform you are using also has some options that may help you. See their README.md, you can keep console.error and console.warn, those will then still end up in Sentry reports.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文