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

Enhance/6079 - Google Tag container lookup and destinations list JS selectors #6367

Merged
merged 21 commits into from
Jan 4, 2023

Conversation

hussain-t
Copy link
Collaborator

@hussain-t hussain-t commented Jan 4, 2023

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 5.6.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@github-actions
Copy link

github-actions bot commented Jan 4, 2023

Size Change: +422 B (0%)

Total Size: 1.2 MB

Filename Size Change
./dist/assets/js/googlesitekit-activation-********************.js 26.8 kB -2 B (0%)
./dist/assets/js/googlesitekit-components-gm3-********************.js 422 B +1 B (0%)
./dist/assets/js/googlesitekit-data-********************.js 2.15 kB +1 B (0%)
./dist/assets/js/googlesitekit-datastore-site-********************.js 15.3 kB -4 B (0%)
./dist/assets/js/googlesitekit-datastore-user-********************.js 21.7 kB -8 B (0%)
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 63.6 kB +9 B (0%)
./dist/assets/js/googlesitekit-main-dashboard-********************.js 69.1 kB +7 B (0%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 69.5 kB +1 B (0%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 19.8 kB +388 B (+2%)
./dist/assets/js/googlesitekit-modules-analytics-********************.js 70.6 kB -18 B (0%)
./dist/assets/js/googlesitekit-modules-********************.js 20.1 kB -4 B (0%)
./dist/assets/js/googlesitekit-modules-optimize-********************.js 18.8 kB -2 B (0%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 21.2 kB +3 B (0%)
./dist/assets/js/googlesitekit-modules-search-console-********************.js 38.4 kB -12 B (0%)
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 31.9 kB +18 B (0%)
./dist/assets/js/googlesitekit-settings-********************.js 50.1 kB -7 B (0%)
./dist/assets/js/googlesitekit-splash-********************.js 68.6 kB -5 B (0%)
./dist/assets/js/googlesitekit-user-input-********************.js 43.2 kB -3 B (0%)
./dist/assets/js/googlesitekit-vendor-********************.js 325 kB +58 B (0%)
./dist/assets/js/googlesitekit-widgets-********************.js 15.6 kB -3 B (0%)
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 56.8 kB +4 B (0%)
ℹ️ View Unchanged
Filename Size
./dist/assets/css/googlesitekit-admin-css-********************.min.css 47.4 kB
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11 kB
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 7.14 kB
./dist/assets/js/30-********************.js 2.8 kB
./dist/assets/js/31-********************.js 2.28 kB
./dist/assets/js/32-********************.js 3.72 kB
./dist/assets/js/33-********************.js 3.12 kB
./dist/assets/js/analytics-advanced-tracking-********************.js 769 B
./dist/assets/js/googlesitekit-adminbar-********************.js 35.4 kB
./dist/assets/js/googlesitekit-api-********************.js 9.45 kB
./dist/assets/js/googlesitekit-base-********************.js 1.13 kB
./dist/assets/js/googlesitekit-components-gm2-********************.js 5.82 kB
./dist/assets/js/googlesitekit-datastore-forms-********************.js 9.13 kB
./dist/assets/js/googlesitekit-datastore-location-********************.js 2.09 kB
./dist/assets/js/googlesitekit-datastore-ui-********************.js 9.25 kB
./dist/assets/js/googlesitekit-i18n-********************.js 3.92 kB
./dist/assets/js/googlesitekit-polyfills-********************.js 379 B
./dist/assets/js/runtime-********************.js 1.26 kB

compressed-size-action

Copy link
Collaborator

@techanvil techanvil left a 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(
Copy link
Collaborator

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
			);
		}
	),

Copy link
Collaborator Author

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 } ) {
Copy link
Collaborator

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;
	} ),

Copy link
Collaborator Author

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": {
Copy link
Collaborator

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...

Copy link
Collaborator Author

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": {
Copy link
Collaborator

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...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Collaborator

@techanvil techanvil left a 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!

@techanvil techanvil merged commit 96d14d6 into develop Jan 4, 2023
@techanvil techanvil deleted the enhance/6079-lookup-destinations-selectors branch January 4, 2023 13:58
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