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

Key Metrics “Connect GA” CTA #7255

Merged
merged 29 commits into from
Jul 7, 2023

Conversation

nfmohit
Copy link
Collaborator

@nfmohit nfmohit commented Jul 4, 2023

Summary

Addresses issue:

Relevant technical choices

This PR implements the Key Metrics “Connect GA” CTA.

Difference from the IB

If you take a look at the Figma designs, it can be noticed that the Key Metrics Setup CTA widget and the Connect GA4 CTA widget have a lot in common when it comes to the layout.

As a result, instead of following the IB in this regard, I have used the layout elements implemented in the Key Metrics Setup CTA widget as a part of #6210 and extracted them into common layout components to re-use them in both CTA widgets.

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 Jul 4, 2023

Size Change: +1.52 kB (0%)

Total Size: 1.39 MB

Filename Size Change
./dist/assets/css/googlesitekit-admin-css-********************.min.css 50.4 kB +35 B (0%)
./dist/assets/js/33-********************.js 930 B +1 B (0%)
./dist/assets/js/35-********************.js 3.12 kB +1 B (0%)
./dist/assets/js/googlesitekit-activation-********************.js 24.1 kB +6 B (0%)
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 52 kB -41 B (0%)
./dist/assets/js/googlesitekit-adminbar-********************.js 33 kB -3 B (0%)
./dist/assets/js/googlesitekit-api-********************.js 9.88 kB -1 B (0%)
./dist/assets/js/googlesitekit-components-gm2-********************.js 5.29 kB -2 B (0%)
./dist/assets/js/googlesitekit-components-gm3-********************.js 9.96 kB -1 B (0%)
./dist/assets/js/googlesitekit-data-********************.js 2.18 kB +7 B (0%)
./dist/assets/js/googlesitekit-datastore-location-********************.js 2.09 kB +1 B (0%)
./dist/assets/js/googlesitekit-datastore-site-********************.js 16.5 kB +4 B (0%)
./dist/assets/js/googlesitekit-datastore-ui-********************.js 9.4 kB +1 B (0%)
./dist/assets/js/googlesitekit-datastore-user-********************.js 23.3 kB +25 B (0%)
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 66.3 kB +18 B (0%)
./dist/assets/js/googlesitekit-main-dashboard-********************.js 80.1 kB +20 B (0%)
./dist/assets/js/googlesitekit-modules-********************.js 21.6 kB -26 B (0%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 105 kB -6 B (0%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 58.4 kB +1.22 kB (+2%)
./dist/assets/js/googlesitekit-modules-analytics-********************.js 88.2 kB -17 B (0%)
./dist/assets/js/googlesitekit-modules-optimize-********************.js 20.6 kB -3 B (0%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 21.4 kB -6 B (0%)
./dist/assets/js/googlesitekit-modules-search-console-********************.js 53.5 kB +275 B (+1%)
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 32.4 kB -9 B (0%)
./dist/assets/js/googlesitekit-settings-********************.js 49.5 kB -39 B (0%)
./dist/assets/js/googlesitekit-splash-********************.js 67.1 kB -35 B (0%)
./dist/assets/js/googlesitekit-user-input-********************.js 42 kB -15 B (0%)
./dist/assets/js/googlesitekit-vendor-********************.js 311 kB -11 B (0%)
./dist/assets/js/googlesitekit-widgets-********************.js 20.2 kB +151 B (+1%)
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 62.9 kB -25 B (0%)
./dist/assets/js/runtime-********************.js 1.3 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.2 kB
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 7.55 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/34-********************.js 888 B
./dist/assets/js/analytics-advanced-tracking-********************.js 769 B
./dist/assets/js/googlesitekit-datastore-forms-********************.js 9.3 kB
./dist/assets/js/googlesitekit-i18n-********************.js 3.92 kB
./dist/assets/js/googlesitekit-polyfills-********************.js 379 B

compressed-size-action

@github-actions
Copy link

github-actions bot commented Jul 4, 2023

Build files for 4952559 have been deleted.

Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Thanks @nfmohit – this is off to a great start. A few things to address and suggestions for you to consider.

Also, VRT is currently failing a few scenarios.

assets/js/googlesitekit/widgets/register-defaults.js Outdated Show resolved Hide resolved
assets/js/components/KeyMetrics/ConnectGA4CTAWidget.js Outdated Show resolved Hide resolved
assets/js/components/KeyMetrics/ConnectGA4CTAWidget.js Outdated Show resolved Hide resolved
@nfmohit nfmohit self-assigned this Jul 6, 2023
@nfmohit nfmohit removed their assignment Jul 6, 2023
@nfmohit
Copy link
Collaborator Author

nfmohit commented Jul 6, 2023

Thanks @nfmohit – this is off to a great start. A few things to address and suggestions for you to consider.

Also, VRT is currently failing a few scenarios.

Addressed all of them, and updated VRT scenarios. Back to you for another pass, thank you @aaemnnosttv!

@nfmohit nfmohit requested a review from aaemnnosttv July 6, 2023 12:17
Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Thanks @nfmohit – I think we're almost there! Just a few things left for you.

Comment on lines 435 to 441
export const provideWidgetRegistrations = (
registry,
areaSlug,
areaTitle,
contextSlugs = null,
widgets
) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit different than the convention shared by the other provide* utilities which all allow for easily providing something with sensible defaults that can be merged/overridden with customizations, but the utility itself should be useful without any (e.g. provideWidgetRegistrations( registry )).

This is a bit tricky for widgets since we don't support removing them (similar to modules). For a general widget utility like this, I'd imagine it would work very similar to the utility for module registrations (provideModuleRegistrations) which essentially iterates over all the core module JS-modules, and calls its registerModule export if it has one. This requires kind of decorating the module registration API call to allow for merging the extra data but the same should be possible here. We have the same kind of API for modules that have widgets as well via the registerWidgets export.

The difference with widgets is the hierarchical relationships between contexts, areas, and widgets which makes things a bit more complicated but still doable, however this is complicated and it seems out of scope to try and squeeze this much in at this point.

That said, let's move this function to be more of a local utility function with a note to refactor it in the future and open a new issue for the generic utility as described above. As a local helper, it's okay for the function to be more specific to what it's doing now so long as its clear what it's doing (particularly if it's shared across multiple files).


Finally, just a note about the function signature that was chosen here – we generally avoid functions with more than two positional arguments because it makes it difficult to reason about what each argument is when there are many. For this reason, you'll see the fn( a, args ) or fn( a, options ) as conventions we use quite a bit with the difference being whether or not the second argument is required or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the kind explanation and observation.

I absolutely agree. I have created #7264, and made the current utility specific to key metrics widgets with appropriate notes. Let me know if they look good, thanks!

Finally, just a note about the function signature that was chosen here – we generally avoid functions with more than two positional arguments because it makes it difficult to reason about what each argument is when there are many. For this reason, you'll see the fn( a, args ) or fn( a, options ) as conventions we use quite a bit with the difference being whether or not the second argument is required or not.

Duly noted, understood, and agreed, thank you!

Comment on lines 244 to 252
if ( isFeatureEnabled( 'userInput' ) ) {
widgetsAPI.registerWidget(
'keyMetricsConnectGA4CTA',
{
Component: ConnectGA4CTAWidget,
width: [ widgetsAPI.WIDGET_WIDTHS.FULL ],
priority: 1,
wrapWidget: false,
modules: [ 'analytics-4' ],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's move this widget registration to the GA4 module since it's essentially an activation CTA (all widgets are registered regardless of activation/connection). This module-specific widget shouldn't be registered from a core store. Alternatively, if GA was not available as a module at all, this CTA wouldn't be registered and shouldn't be shown.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call! I've moved this inside the GA4 module. Thank you!

Commit: 5cee01e

assets/js/googlesitekit/datastore/user/constants.js Outdated Show resolved Hide resolved
assets/js/components/KeyMetrics/ConnectGA4CTAWidget.js Outdated Show resolved Hide resolved
assets/js/components/KeyMetrics/ConnectGA4CTAWidget.js Outdated Show resolved Hide resolved
assets/js/components/KeyMetrics/ConnectGA4CTAWidget.js Outdated Show resolved Hide resolved
@nfmohit nfmohit requested a review from aaemnnosttv July 6, 2023 20:46
Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Thanks @nfmohit ! So close 😄

@nfmohit nfmohit requested a review from aaemnnosttv July 7, 2023 17:25
@nfmohit
Copy link
Collaborator Author

nfmohit commented Jul 7, 2023

Thanks @nfmohit ! So close 😄

Back to you for another pass, thank you @aaemnnosttv!

Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Great, thanks for your patience on this @nfmohit !

@aaemnnosttv aaemnnosttv merged commit 05739ba into develop Jul 7, 2023
@aaemnnosttv aaemnnosttv deleted the enhancement/#6265-connect-ga4-cta branch July 7, 2023 18:43
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