Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kochis
Copy link
Collaborator

@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
@@ -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.');
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
Collaborator 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
Collaborator 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.

2 participants