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

Implement the OAuth flow for the Setup CTA Banner #8132

Open
3 tasks
techanvil opened this issue Jan 24, 2024 · 11 comments
Open
3 tasks

Implement the OAuth flow for the Setup CTA Banner #8132

techanvil opened this issue Jan 24, 2024 · 11 comments
Labels
Module: Analytics Google Analytics module related issues P1 Medium priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature

Comments

@techanvil
Copy link
Collaborator

techanvil commented Jan 24, 2024

Feature Description

Implement the redirection to OAuth to grant the edit scope for the Setup CTA Banner.

Note that this issue only covers the happy path, the unhappy path will be implemented separately via #8134.

See setup CTA banner > setup logic in the design doc.


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

Acceptance criteria

Implementation Brief

  • Update assets/js/modules/analytics-4/components/dashboard/AudienceSegmentation/AudienceSegmentationSetupCTAWidget.js
    • Add a callback function for Enable groups CTA:
      • Check if user does not has Analytics 4 Edit scope, to trigger the setPermissionScopeError for ANALYTICS_EDIT_SCOPE. You can see an example here
      • Append query argument notification with value, say audience_segmentation, to bypass authentication_success banner. You can see an example here
      • Set autoSubmit value on CORE_FORMS, by dispatching setValues action, and assign it to, say, AUDIENCE_SEGMENTATION_SETUP_FORM. You can see an example here
  • Update the setup component implemented in Implement the happy path for creating audiences and the custom dimension via the Setup CTA Banner #8131 to proceed with the setup step (when user has the ANALYTICS_EDIT_SCOPE) if query argument autoSubmit is true

Test Coverage

  • Update jest tests to verify this scenario of jumping to the setup step after OAuth redirection. You can see example of mocking the redirect url here

QA Brief

  1. Setup Site Kit with the audienceSegmentation feature flag enabled.
  2. Connect an Analytics property which is not in the "gathering data" state - preferably a property which already has enhanced measurement enabled, so it's not necessary to grant the edit scope during setup.
  3. If it was necessary to grant the edit scope during setup, disconnect and then reconnect Site Kit to clear the granted scope.
  4. Refresh the dashboard, as the Audience Segmentation Setup CTA won't show up on the first page load while the gathering data state is being resolved.
  5. Click on the Enable groups button - this should navigate to the OAuth flow. Proceed through the OAuth flow and grant the requested permissions, upon which the browser should navigate back to the Site Kit dashboard. The CTA should now be in its loading state with the text "Enabling groups" and a spinner showing in the button.
  6. Once the operation is completed, the CTA banner will disappear and a success notice will be displayed with the heading:
Success! Visitor groups added to your dashboard

Changelog entry

  • Navigate to the OAuth flow as needed when setting up Audience Segmentation from the Setup CTA Banner.
@techanvil techanvil added Module: Analytics Google Analytics module related issues P1 Medium priority Type: Enhancement Improvement of an existing feature labels Jan 24, 2024
@jimmymadon jimmymadon assigned jimmymadon and unassigned jimmymadon Jan 29, 2024
@tofumatt tofumatt self-assigned this Jan 31, 2024
@tofumatt
Copy link
Collaborator

ACs sound good 👍🏻

@tofumatt tofumatt removed their assignment Jan 31, 2024
@zutigrm zutigrm assigned zutigrm and unassigned zutigrm Feb 2, 2024
@techanvil techanvil self-assigned this Feb 15, 2024
@techanvil
Copy link
Collaborator Author

Hi @zutigrm, the IB is looking good, however I am not sure we should use the notification query param as the condition for reshowing the banner and continuing to the next step.

It's not an approach we have taken to date, rather we have a pattern of setting an autoSubmit form value, which is persisted via the store snapshot mechanism and restored on the next page load. For example:

setValues( FORM_ACCOUNT_CREATE, { autoSubmit: true } );
setPermissionScopeError( {
code: ERROR_CODE_MISSING_REQUIRED_SCOPE,
message: __(
'Additional permissions are required to create a new Analytics account.',
'google-site-kit'
),
data: {
status: 403,
scopes,
skipModal: true,
},
} );

We then use the autoSubmit value in the conditions for restoring the previous UI state and continuing.

I'd suggest we take the same approach here, in part for consistency, but also because it will be useful for the unhappy path too. We can use it for showing the error modal - the notification param may not be present in this scenario.

@techanvil techanvil assigned zutigrm and unassigned techanvil Feb 15, 2024
@zutigrm
Copy link
Collaborator

zutigrm commented Feb 16, 2024

@techanvil Thank you for the feedback, I forgot about autoSubmit 🤦 . I updated the IB

@zutigrm zutigrm assigned techanvil and unassigned zutigrm Feb 16, 2024
@techanvil
Copy link
Collaborator Author

Thanks @zutigrm! IB LGTM. ✅

@techanvil techanvil removed their assignment Feb 16, 2024
@ivonac4 ivonac4 added the Team M Issues for Squad 2 label Apr 9, 2024
@ivonac4 ivonac4 added Sp Wk 2 Issues to be completed in the second week of the assigned sprint and removed Sp Wk 2 Issues to be completed in the second week of the assigned sprint labels May 1, 2024
@ankitrox ankitrox self-assigned this May 20, 2024
@ankitrox
Copy link
Collaborator

Adding "Blocked by" #8707 because some logic inside the component AudienceSegmentationSetupCTAWidget will get changed in 8707 because of which tests for this issue needs to accommodate the change.

@ankitrox ankitrox removed their assignment Jun 5, 2024
@techanvil techanvil self-assigned this Jun 5, 2024
@techanvil
Copy link
Collaborator Author

Hey @ankitrox, I've left a few comments on the PR.

With regard to the QAB - although it could be enough to give the QA team sufficient direction, it would be useful to provide a bit more detail.

I've gone ahead and rewritten it a bit myself, please review the changes and make sure you are happy with them. Note that I've completely omitted the point about visiting https://myaccount.google.com/connections to remove permissions - we don't generally need to do that, in the scenario here simply disconnecting and reconnecting Site Kit is sufficient.

@techanvil techanvil assigned ankitrox and unassigned techanvil Jun 5, 2024
@aaemnnosttv aaemnnosttv self-assigned this Jun 10, 2024
@ankitrox
Copy link
Collaborator

Hi @techanvil ,

We can discuss about the use of mocks for the actions later when @aaemnnosttv is available. However; I have changed the tests to make use of assertions for enableAudienceGroups action so that those are more of the integration in nature as per the convention.

Please note that I have made the use of muteFetch for reports endpoint as this is not really specific to the tests being performed and to keep the tests readable.

Also, updated these tests so that this ticket can be moved ahead because there are some other tickets which are dependent on this one.

Assigning this to you for re-review.

Thank you

@ankitrox ankitrox assigned techanvil and unassigned ankitrox Jun 12, 2024
@techanvil techanvil assigned ankitrox and unassigned aaemnnosttv and techanvil Jun 12, 2024
@techanvil
Copy link
Collaborator Author

Thanks @ankitrox! As per my review comment, I am not seeing the updated version of the tests. Maybe you need to push a recent change?

@ankitrox
Copy link
Collaborator

@techanvil Sorry, that was my bad! I committed the changes, but missed to push them.

I have pushed the changes and those should be available. Please refer to this commit where I have removed mock's implementation just to stick to our convention.

@techanvil
Copy link
Collaborator Author

No worries, thanks @ankitrox! As per my latest review this needs one more pass, please take a look.

@ankitrox
Copy link
Collaborator

@techanvil Thank you.

Tests updated as per suggestions.

@ankitrox ankitrox assigned techanvil and unassigned ankitrox Jun 12, 2024
@techanvil techanvil assigned ankitrox and techanvil and unassigned techanvil and ankitrox Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Analytics Google Analytics module related issues P1 Medium priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

7 participants