The google-cloud/trace-agent has a handy feature that lets you pass enabled as a flag to the instantiation for whether tracing is enabled or not. It would be great to have a similar feature for error reporting.
I only want to run error reporting in one world - production, and not in dev. This means I currently have to do:
const exp = express()
.use()
.use()
if (!dev) {
errors = new ErrorReporting({})
exp.use(errors.express)
}
const server = exp.listen()
Not the end of the world, but it would be much cleaner to just do:
errors = new ErrorReporting({
enabled: !dev
})
const server = express()
.use()
.use()
.use(errors.express)
.listen()
Which isn't currently possible as errors is undefined in some circumstances. I could of course just unconditionally enable it, without ignoreEnv and without NODE_ENV=production, but then I get warnings in dev.
The google-cloud/trace-agent has a handy feature that lets you pass
enabledas a flag to the instantiation for whether tracing is enabled or not. It would be great to have a similar feature for error reporting.I only want to run error reporting in one world - production, and not in dev. This means I currently have to do:
Not the end of the world, but it would be much cleaner to just do:
Which isn't currently possible as
errorsis undefined in some circumstances. I could of course just unconditionally enable it, without ignoreEnv and without NODE_ENV=production, but then I get warnings in dev.