Skip to content
This repository was archived by the owner on Mar 5, 2026. It is now read-only.
This repository was archived by the owner on Mar 5, 2026. It is now read-only.

enabled flag not working #127

@majelbstoat

Description

@majelbstoat

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.

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: clouderrorreportingIssues related to the googleapis/nodejs-error-reporting API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions