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

Enhancement/8981 Refactor RRM Setup Success Notification #9367

Open
wants to merge 39 commits into
base: develop
Choose a base branch
from

Conversation

jimmymadon
Copy link
Collaborator

Summary

Addresses issue:

Relevant technical choices

  • Decided to pass the eventLabel for GA Event Tracking as a prop. This seemed to be the simplest and cleanest solution compared to using another context provider or passing an entire custom google event tracking callback.

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 7.4.
  • 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.
  • Ensure there are no unexpected significant changes to file sizes.

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.

@jimmymadon jimmymadon changed the title Enhancement/8981 refactor rrm setup success notification Enhancement/8981 Refactor RRM Setup Success Notification Sep 18, 2024
Copy link

github-actions bot commented Sep 18, 2024

Build files for e6a961b are ready:

Copy link

github-actions bot commented Sep 18, 2024

Size Change: -48.1 kB (-2.61%)

Total Size: 1.8 MB

Filename Size Change
./dist/assets/js/googlesitekit-activation-********************.js 23.9 kB -13 B (-0.05%)
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 55.5 kB -14.8 kB (-21.07%) 🎉
./dist/assets/js/googlesitekit-adminbar-********************.js 34.8 kB -110 B (-0.32%)
./dist/assets/js/googlesitekit-api-********************.js 10 kB +25 B (+0.25%)
./dist/assets/js/googlesitekit-components-gm3-********************.js 10.1 kB +4 B (+0.04%)
./dist/assets/js/googlesitekit-data-********************.js 2.37 kB -3 B (-0.13%)
./dist/assets/js/googlesitekit-datastore-forms-********************.js 8.96 kB +16 B (+0.18%)
./dist/assets/js/googlesitekit-datastore-location-********************.js 2.08 kB -2 B (-0.1%)
./dist/assets/js/googlesitekit-datastore-site-********************.js 20.4 kB +13 B (+0.06%)
./dist/assets/js/googlesitekit-datastore-ui-********************.js 9.98 kB +26 B (+0.26%)
./dist/assets/js/googlesitekit-datastore-user-********************.js 26.4 kB +86 B (+0.33%)
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 81.7 kB +54 B (+0.07%)
./dist/assets/js/googlesitekit-main-dashboard-********************.js 156 kB +808 B (+0.52%)
./dist/assets/js/googlesitekit-modules-********************.js 22.2 kB +230 B (+1.04%)
./dist/assets/js/googlesitekit-modules-ads-********************.js 32.8 kB +125 B (+0.38%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 111 kB -12.1 kB (-9.83%) 👏
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 173 kB -340 B (-0.2%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 22.7 kB +237 B (+1.05%)
./dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 40.5 kB +18.6 kB (+84.91%) 🆘
./dist/assets/js/googlesitekit-modules-search-console-********************.js 59.3 kB +141 B (+0.24%)
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 32 kB -8 B (-0.02%)
./dist/assets/js/googlesitekit-notifications-********************.js 22.4 kB +7 B (+0.03%)
./dist/assets/js/googlesitekit-settings-********************.js 117 kB -7.78 kB (-6.22%)
./dist/assets/js/googlesitekit-splash-********************.js 69.5 kB -16.8 kB (-19.49%) 👏
./dist/assets/js/googlesitekit-user-input-********************.js 44.5 kB -16.3 kB (-26.82%) 🎉
./dist/assets/js/googlesitekit-vendor-********************.js 321 kB +319 B (+0.1%)
./dist/assets/js/googlesitekit-widgets-********************.js 88.9 kB -197 B (-0.22%)
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 61.8 kB -315 B (-0.51%)
./dist/assets/js/runtime-********************.js 1.3 kB -5 B (-0.38%)
ℹ️ View Unchanged
Filename Size
./dist/assets/css/googlesitekit-admin-css-********************.min.css 58 kB
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.8 kB
./dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 846 B
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 8.2 kB
./dist/assets/js/32-********************.js 2.76 kB
./dist/assets/js/33-********************.js 2.25 kB
./dist/assets/js/34-********************.js 3.64 kB
./dist/assets/js/35-********************.js 935 B
./dist/assets/js/36-********************.js 891 B
./dist/assets/js/37-********************.js 3.12 kB
./dist/assets/js/analytics-advanced-tracking-********************.js 901 B
./dist/assets/js/googlesitekit-components-gm2-********************.js 5.96 kB
./dist/assets/js/googlesitekit-consent-mode-********************.js 25.6 kB
./dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 646 B
./dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 624 B
./dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 630 B
./dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 712 B
./dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 675 B
./dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 634 B
./dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 657 B
./dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 633 B
./dist/assets/js/googlesitekit-i18n-********************.js 3.93 kB
./dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 1.01 kB
./dist/assets/js/googlesitekit-polyfills-********************.js 377 B

compressed-size-action

Copy link
Collaborator

@nfmohit nfmohit left a comment

Choose a reason for hiding this comment

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

Brilliant work here, thank you @jimmymadon !

I've added a few comments in the PR. Some issues that I've pointed out are also causing around 9 VRT failures, and the other 5 seem to be false positives/unrelated to this PR.

Please let me know if you have any questions, thank you!

Copy link
Collaborator

Choose a reason for hiding this comment

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

This component has a few styling discrepancies when compared to its predecessor assets/js/components/notifications/SubtleNotification.js:

Item 1

The type of warning does not have the appropriate colours.

Original SubtleNotification of variant warning:

image

This SubtleNotification with type warning:

image

Item 2

In smaller viewports, the positioning of buttons does not match the designs.

Original SubtleNotification:

image

This SubtleNotification:

image


Could we update these to match? Thanks!

},
} );
} );
it( 'should persist dismissal if notification is not dismissible', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
it( 'should persist dismissal if notification is not dismissible', async () => {
it( 'should persist dismissal if notification is dismissible', async () => {

Comment on lines +42 to +56
const handleCTAClick = async ( event ) => {
if ( ! event.defaultPrevented ) {
event.preventDefault();
}

await onCTAClick?.( event );

await trackEvents.confirm( gaConfirmEventLabel );

if ( isCTALinkExternal ) {
global.open( ctaLink, '_blank' );
} else {
navigateTo( ctaLink );
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd vote to keep this natural, as handleDismiss in assets/js/googlesitekit/notifications/components/common/Dismiss.js. Using global.open in RRMSetupSuccessSubtleNotification was more of a hack to make the core/forms setValues action to work with useRefocus.

Suggested change
const handleCTAClick = async ( event ) => {
if ( ! event.defaultPrevented ) {
event.preventDefault();
}
await onCTAClick?.( event );
await trackEvents.confirm( gaConfirmEventLabel );
if ( isCTALinkExternal ) {
global.open( ctaLink, '_blank' );
} else {
navigateTo( ctaLink );
}
};
const handleCTAClick = async ( event ) => {
await onCTAClick?.( event );
await trackEvents.confirm( gaConfirmEventLabel );
};

const onCTAClick = ( event ) => {
event.preventDefault();

const onCTAClick = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As commented above:

Suggested change
const onCTAClick = () => {
const onCTAClick = ( event ) => {
event.preventDefault();

@@ -127,16 +102,6 @@ function RRMSetupSuccessSubtleNotification() {
[ SYNC_PUBLICATION ]: true,
} );
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

As commented above:

Suggested change
}
}
global.open( serviceURL, '_blank' );

@@ -71,3 +79,35 @@ export const registerModule = ( modules ) => {
},
} );
};

export const registerNotifications = ( notifications ) => {
notifications.registerNotification( 'setup-success-notification-rrm', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The notification seems to have a little delay and does not appear immediately, not at least on a first load. Is this expected?

areaSlug: NOTIFICATION_AREAS.BANNERS_BELOW_NAV,
viewContexts: [
VIEW_CONTEXT_MAIN_DASHBOARD,
VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY,
Copy link
Collaborator

Choose a reason for hiding this comment

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

While we're at it, we can prevent the notification from appearing on the view only dashboard.

Suggested change
VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY,

export default function Notification( {
id,
className,
gaViewEventLabel,
Copy link
Collaborator

Choose a reason for hiding this comment

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

One question regarding this gaViewEventLabel prop: Looking at the trackEvent function, it also supports an additional value parameter:

return async function trackEvent( category, action, label, value ) {

Instead of accepting a gaViewEventLabel prop here, what if we received an array prop, say gaEventArgs, and spread that in the function, e.g. trackEvents.view( ...gaEventArgs )?

This will ensure that this mechanism is future proof and we do not need to make any changes in case an event also requires the value parameter.

What do you think?

ctaLabel,
onCTAClick,
isCTALinkExternal = false,
gaConfirmEventLabel,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same thoughts as gaViewEventLabel above.

@@ -34,14 +39,15 @@ export default function Dismiss( {
dismissExpires = 0,
disabled,
onDismiss = () => {},
gaDismissEventLabel,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same thoughts as gaViewEventLabel above.

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