-
Notifications
You must be signed in to change notification settings - Fork 286
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
Enhance/6079 - Google Tag container lookup and destinations list JS selectors #6367
Enhance/6079 - Google Tag container lookup and destinations list JS selectors #6367
Conversation
Refactor reducerCallback to update state correctly.
…6079-lookup-destinations-selectors.
Pass correct data params to the endpoint.
…6079-lookup-destinations-selectors.
Size Change: +422 B (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
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.
This is looking good @hussain-t, I have left a couple of suggestions, please take a look.
} | ||
); | ||
}, | ||
reducerCallback( |
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.
This looks like a good opportunity to use createReducer
to create an Immer-enabled reducer callback, in order to simplify the reducer here.
It would look something like this. Still not super elegant, but easier to make sense of:
reducerCallback: createReducer(
( state, containerDestinations, { gtmAccountID, gtmContainerID } ) => {
state.containerDestinations[ gtmAccountID ] =
state.containerDestinations[ gtmAccountID ] || {};
state.containerDestinations[ gtmAccountID ][ gtmContainerID ] =
state.containerDestinations[ gtmAccountID ][ gtmContainerID ] ||
[];
state.containerDestinations[ gtmAccountID ][ gtmContainerID ].push(
...containerDestinations
);
}
),
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.
Thanks for the great suggestion, @techanvil. I didn't think of it.
It would look something like this. Still not super elegant, but easier to make sense of:
The above code look good 👍
} | ||
); | ||
}, | ||
reducerCallback( state, container, { measurementID } ) { |
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.
We might as well use createReducer
here too, it would simplify the reducer logic to a one-liner:
reducerCallback: createReducer( ( state, container, { measurementID } ) => {
state.containers[ measurementID ] = container;
} ),
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.
Updated 👍
@@ -0,0 +1,16 @@ | |||
{ | |||
"6065482709": { |
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.
Is this real user data here? If so, I'd suggest sanitizing it...
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.
Updated.
@@ -0,0 +1,33 @@ | |||
{ | |||
"G-2C8N8YQ1L7": { |
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.
Same comment applies re. user data sanitization...
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.
Updated.
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.
Nice one @hussain-t, LGTM!
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist