site-kit-wp: Prevent the success notification appearing when returning from OAuth in the GA4 Activation Banner flow

Bug Description

As described in https://github.com/google/site-kit-wp/issues/5282#issuecomment-1246528980, at present, when returning from OAuth to the GA4 Activation Banner, the Success Notification is displayed, interrupting the desired GA4 Activation Banner flow.

We need to prevent the Success Notification from being displayed in this particular case.

Steps to reproduce

Follow the steps detailed in https://github.com/google/site-kit-wp/issues/5282#issuecomment-1246528980 with more info available in the QAB for #5282.

Screenshots

Here is a screenshot of the Success Notification, shown when the URL contains the query param notification=authentication_success. image.png

See https://github.com/google/site-kit-wp/issues/5282#issuecomment-1246528980 for more screenshots.

Additional Context

  • PHP Version: any
  • OS: any
  • Browser: any
  • Plugin Version: 1.83.0
  • Device: any

Acceptance criteria

  • When returning from OAuth to the GA4 Activation Banner, the Success Notification should not be displayed, and the GA4 Activation Banner should be shown in its expected state.

Implementation Brief

  • In the assets/js/components/PermissionsModal/AuthenticatedPermissionsModal.js file:
    • Update the redirectURL property of the getConnectURL selector call to use permissionsError?.data?.redirectURL value if provided or fallback to the current location href otherwise.
  • In the assets/js/modules/analytics-4/components/dashboard/ActivationBanner/SetupBanner.js file:
    • In the handleSubmitChanges callback:
      • Create a new variable redirectURL and assign the current location href appended with notification=ga4_setup using the addQueryArg function.
      • Add a new redirectURL property to the data object of the permission scope error passed to the setPermissionScopeError action.
  • In the assets/js/components/notifications/BannerNotifications.js file:
    • Update the ActivationBanner component rendering to make sure we don’t display it in the viewOnly mode.
  • In the OAuth_Client class:
    • Update $redirect_url modifications in authorize_user and get_authentication_url methods to avoid adding the notification=authentication_success argument to the redirect URL if the redirect URL already has the notification query argument.

Test Coverage

  • Fix any failing tests.

QA Brief

  • This can be tested along with #5282. The “Congrats…” banner should no longer appear when returning from OAuth to the GA4 Activation Banner.
  • Additionally, a slightly tangential issue has been fixed at the same time: The GA4 Activation Banner will no longer appear in view-only mode. This can be tested as well, setting the scene for the activation banner to appear, then viewing in view-only mode to verify the banner does not appear.

Changelog entry

  • Ensure GA4 activation banner is displayed when returning from granting additional scopes after setting up GA4 instead of generic success banner.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17

Most upvoted comments

Thanks @eugene-manuilov. I’m happy enough to stick with ga4_setup in that case - we can always revisit it later.