-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prevent /config call on multiple initializations #188
base: master
Are you sure you want to change the base?
Conversation
@@ -58,6 +58,10 @@ class Radar { | |||
throw new RadarPublishableKeyError('Secret keys are not allowed. Please use your Radar publishable key.'); | |||
} | |||
|
|||
if (Config.isInitialized()) { | |||
Logger.error('Radar.initialize() called more than once.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we're handling this, should we Logger.warn
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's a "warn" and not an error, but I also sort of want this to fire on a production site. Maybe I will just change to console.warn
instead of using the Logger class.
// without having to mock the ConfigAPI.getConfig call | ||
if (!(window as any)?.RADAR_TEST_ENV) { | ||
ConfigAPI.getConfig(); | ||
if (!Config.isInitialized()) { // only call getConfig on first initialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to || keyChanged
to handle cases where someone would change the key (can't come up with anything off the top of my head where that would matter here, but we do allow the key to change in Waypoint for instance)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the one scenario I was sort of thinking of.
Maybe it's worth just checking if the config options have changed or not.
/config
Before
After