Skip to content

Conversation

@terryyylim
Copy link
Collaborator

What this PR does / why we need it:
A previous related PR caused a bug which crashes Routers Details view. This view uses ExperimentConfigSection component which requires configured Experiment Engine information retrieved via global variables configured on the Experiment Engine UI. This resulted in runtime configs being NOT loaded into the index.html headers and hence, not available for use.

Logs show the following information:

TypeError: Cannot read properties of undefined (reading 'experimentEngineApiUrl')
...

This PR addresses the above issue for both ExperimentConfigSection and StandardExperimentConfigGroup components which load information from the remote Experiment Engine UI.

@terryyylim terryyylim requested a review from a team June 7, 2022 10:22
@terryyylim terryyylim self-assigned this Jun 7, 2022
const [configFailed, setConfigFailed] = useState(false);

// Retrieve script from host dynamically
const { ready, failed } = useDynamicScript({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we replace this with LoadDynamicScript too instead of directly calling the hook?

Also, since we have similar logic in multiple places now, there is likely some scope for refactoring this further to reduce some code duplication by wrapping all the loading into a single component.

Copy link
Collaborator

@krithika369 krithika369 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the fix and the refactoring!

};

// Dynamic Script Loading component wrapper
export const DynamicHookComponent = ({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are great! My only comment for improvement is, DynamicHookComponent is named and placed (under ui/src/components/remote_component) as though it were a generic component. It's weird that it worries about the details of url vs config and talks about "Experiment Engine". Can we move this component to ui/src/components/experiments and rename it to ExperimentEngineLoaderComponent or something like that?

@terryyylim terryyylim merged commit a7804f0 into caraml-dev:main Jun 8, 2022
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