Reputation: 107
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!
Upvotes: 0
Views: 762
Reputation: 211
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.
Upvotes: 1