-
Notifications
You must be signed in to change notification settings - Fork 293
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 Audience Creation Notice OAuth flow #8165
Comments
Hey @benbowler, thanks for drafting this IB. A few points:
It's also worth highlighting that the "Got it" button should implement the recently added callout button style as seen here in Figma, with an example here of how to implement it (but using different colours, the example is the "success" variant). Note that we have a couple of issues (#9063, #9064) to provide reusable components for these buttons, so this may be an interim implementation although #9063 has already landed in the EB.
I'm not sure if this simply a mistake with the lines selected for the code snippet, but the standard pattern for redirecting to the OAuth flow is to dispatch the We should reuse this pattern here, certainly the use of For reference here are the relevant lines in site-kit-wp/assets/js/components/KeyMetrics/MetricsSelectionPanel/Footer.js Lines 153 to 179 in 3cce2fa
And here's the entry point where it's handled upon return from OAuth. Note this uses a separate hook that's invoked in site-kit-wp/assets/js/modules/analytics-4/hooks/useCreateCustomDimensionsEffect.js Lines 45 to 84 in 3cce2fa
This doesn't handle the auto-continuation of the audience creation, it's only specced to open the selection panel. We'll need to explicitly continue creating the audience as well. |
Thanks @benbowler, this IB is most of the way there. A few last points:
A minor point, but I would suggest renaming this constant to, say,
This would come out in the wash during implementation, but we might as well be clear that the condition should be
This needs a little more thought as |
Thanks for updating the IB @benbowler. Looks good; I've made a small tweak to align the constant names with my previous comment, and also changed the name The IB LGTM ✅ |
…ion-oauth-flow Enhancement/#8165 - Implement the Audience Creation Notice OAuth flow
QA Update ✅The following were verified good. Moving ticket to approval.
Create.new.audience.with.new.auth.flow.mov2nd.audience.created.successfully.mov |
Feature Description
Implement the redirection to OAuth to grant the edit scope for creating an audience via the Audience Creation Notice. This should only include the happy path, the unhappy path will be implemented separately via #8166.
See audience creation in the design doc.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
analytics.edit
OAuth scope granted:Implementation Brief
assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceSelectionPanel/constants.js
, add two new constants:AUDIENCE_CREATION_EDIT_SCOPE_NOTICE_SLUG
with the valueaudience-creation-edit-scope-notice
.AUDIENCE_CREATION_FORM
with the valueaudience-creation-form
.Notice and Send to OAuth Flow
assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceSelectionPanel/AudienceCreationNotice.js
:AUDIENCE_CREATION_EDIT_SCOPE_NOTICE_SLUG
, using theisItemDismissed
selector.hasScope
selector to check if the user has access to theEDIT_SCOPE
:site-kit-wp/assets/js/components/DashboardMainApp.js
Lines 99 to 101 in ef83c39
InfoNotice
component matching the FIGMA designs.onDismiss
, function should dismiss theAUDIENCE_CREATION_EDIT_SCOPE_NOTICE_SLUG
item usingdismissItem
action.assets/sass/components/analytics-4/audience-segmentation/_googlesitekit-audience-selection-panel.scss
adding CSS to color the info notice to match the FIGMA designs, the "Got it" button should implement the recently added callout button style (see comment below).handleCreateAudience
function of the Create buttons to redirect to the OAuth URL to add the new edit scope, only if the user does not already have this scope, (using this method).CORE_FORMS
store settingautoSubmit
totrue
andaudienceToCreate
to the value ofaudienceSlug
, for the keyAUDIENCE_CREATION_FORM
, to handle the OAuth response.setPermissionScopeError
withskipModal: true
.handleCreateAudience
function, moving it (and any required state) to the parent componentAudienceSelectionPanel/index.js
so that it can be called by theuseEffect
on returning from the OAuth flow.Return from OAuth Flow
assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceSelectionPanel/index.js
, add auseEffect
, check for theautoSubmit
value in theCORE_FORMS
store with the keyAUDIENCE_CREATION_FORM
, (modelled on this method). If this is true, and the edit scope is now present:setValue( AUDIENCE_SELECTION_PANEL_OPENED_KEY, true );
.handleCreateAudience
with the value ofaudienceToCreate
in the store.autoSubmit
andaudienceToCreate
in this store.Test Coverage
assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceSelectionPanel/index.test.js
to test that the new notice displays correctly if the edit scope is missing, and does not show if the edit scope is granted.assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceSelectionPanel/index.stories.js
.QA Brief
Prerequisites
wp_googlesitekit_additional_auth_scopes
entry from thewp_usermeta
table if it exists. This entry contains thehttps://www.googleapis.com/auth/analytics.edit
scope.OAuth Flow
Dismissal
Got it
button and verify that the Missing Scope notice is dismissed.Changelog entry
The text was updated successfully, but these errors were encountered: