Bugsnag-js: Don't always require apiKey

Created on 19 Mar 2018  路  1Comment  路  Source: bugsnag/bugsnag-js

This library seems to assume that I always set my apiKey, perhaps check it into revision control. I'd like to leave this configuration detail out of my source code. Even when releaseStage is not present in notifyReleaseStages, my app doesn't start when there is no apiKey.

My request would be to only require an apiKey when it is actually needed, not when Bugsnag reporting is disabled (like because of releaseStage).

Most helpful comment

Hi @wvengen. I see your problem, however validating a missing apiKey is an important feature of the library. Making it not required is a no-go, and the alternative would be passing the entire configuration object into the individual property validators which introduces a lot of complexity.

My suggestion for your case is to always set your apiKey to something. When you know you won't be sending error reports you can just set it to something "invalid". How are you passing through your api key at the moment?

If for example, it's an environment variable and you're using webpack/browserify to bundle your javascript, you could set:

bugsnag({
  apiKey: process.env.BUGSNAG_API_KEY
})

Setting BUGSNAG_API_KEY="DO_NOT_SEND" (any string, not necessarily a proper api key) when you know you won't be sending any reports due to releaseStage.

If you can provide more info about how you conditionally apply releaseStage etc. and how your api key is injected into your JS I can help provide a more appropriate example.

Thanks!

>All comments

Hi @wvengen. I see your problem, however validating a missing apiKey is an important feature of the library. Making it not required is a no-go, and the alternative would be passing the entire configuration object into the individual property validators which introduces a lot of complexity.

My suggestion for your case is to always set your apiKey to something. When you know you won't be sending error reports you can just set it to something "invalid". How are you passing through your api key at the moment?

If for example, it's an environment variable and you're using webpack/browserify to bundle your javascript, you could set:

bugsnag({
  apiKey: process.env.BUGSNAG_API_KEY
})

Setting BUGSNAG_API_KEY="DO_NOT_SEND" (any string, not necessarily a proper api key) when you know you won't be sending any reports due to releaseStage.

If you can provide more info about how you conditionally apply releaseStage etc. and how your api key is injected into your JS I can help provide a more appropriate example.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

foxyblocks picture foxyblocks  路  5Comments

v3solutions picture v3solutions  路  6Comments

bathos picture bathos  路  6Comments

nathanwelch picture nathanwelch  路  6Comments

vikrantnegi picture vikrantnegi  路  5Comments