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).
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!
Most helpful comment
Hi @wvengen. I see your problem, however validating a missing
apiKeyis 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
apiKeyto 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:
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 toreleaseStage.If you can provide more info about how you conditionally apply
releaseStageetc. and how your api key is injected into your JS I can help provide a more appropriate example.Thanks!