Skip to content

Conversation

@kochis
Copy link
Contributor

@kochis kochis commented Nov 4, 2024

  • Warn on multiple initializations and prevent multiple calls to /config

Before

image

After

image

@kochis kochis requested a review from jaspk06 November 4, 2024 16:05
}

if (Config.isInitialized()) {
Logger.error('Radar.initialize() called more than once.');
Copy link

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?

Copy link
Contributor Author

@kochis kochis Nov 4, 2024

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
Copy link

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)

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants