JulianMar / nuxt-bugsnag

Bugsnag module for nuxt.js
MIT License
49 stars 18 forks source link

App fails if no `apiKey` set #57

Closed TiborPL closed 1 year ago

TiborPL commented 1 year ago

I was suprised to see the the whole nuxt application fail if apiKey is empty. Normally libraries (sentry) are not loaded/started if there is no key provided.

What's the proper way to handle this?

JulianMar commented 1 year ago

Hey, you can disable the module by setting the disable: true option in the bugsnag configuration. I will change the behaviour of the application so it's a bit more expected.

TiborPL commented 1 year ago

@JulianMar thank you for the swift reply, it did help. :) Don't know about others, but it might help to include disabled module config property into the docs too.

Also, it's interesting that bugsnag dies with fatal error if there's no APIKey. Normally libraries just don't start and give a warning in console, like Sentry. Maybe you can add this graceful failing to the module something like this:

if (!options.config.apiKey) {
  console.warn('[bugsnag] apiKey not defined. Plugin is not loaded.')
  return
}
JulianMar commented 1 year ago

Hey, there were some other issues. If you use the module, you will have alot of bugsnag calls littered all over your code. To prevent breaking, if bugsnag cannot be initialized, it now will be mocked and just be sent to console.log.

v7.0.0 Includes this fix. If you find more bugs, pls reopen or create a new issue :)