如果使用remove-console,如何在哨兵上记录错误?
构建生产版本时,我在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
}
如果在生产中需要删除孔,则如何将登录发送到哨兵?
谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用面包屑添加到哨兵报告中。
这也可以让您在报告中添加更丰富的数据。
请参阅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
andconsole.warn
, those will then still end up in Sentry reports.