Unexpected behavior when canceling permission scope popup for a UA-only account
See original GitHub issueFeature Description
When we display the permission scope popup for the GA4 module and user cancels it, we need to redirect the user to the dashboard page because the main UA property has been already saved by the time the user sees that popup.
Steps to reproduce:
- Reset the plugin and connect it again to make sure you start from scratch.
- Connect the Analytics module.
- At the setup form, select an account that has UA property(ies) only.
- Submit the setup form.
- After some time the form will display the permissions error dialog, click “Cancel” link.
- The form stops doing anything although it has already saved UA property settings.
- Now you can go to the settings page and see that UA property has been saved correctly.
See it on the following screencast:
https://user-images.githubusercontent.com/873049/131848481-b6887cdb-f8c3-48a6-9009-782b305c451d.mp4
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- In the Analytics setup flow, if GA is also supposed to be set up (i.e.
isAdminAPIWorking
) and the user cancels out of the prompt that requires granting the additional write scope, the data for the UA property should not be saved.- In other words, if you choose an existing UA property but a GA4 property has to be set up and you cancel, the UA data still shouldn’t be saved.
- Right now, the UA data is saved before the prompt shows up. Potentially the most straightforward and reliable way to solve this is to trigger any request to create a new Google entity first (because those are the write requests that may require extra scopes) and only afterwards save anything. Alternatively, the saved data could be deleted again on failure, but that wouldn’t be as reliable since in that case the user would still be able to cancel out of the OAuth flow and then see the module with UA data connected.
Implementation Brief
- Update the
submitForm
callback in theassets/js/modules/analytics/components/setup/SetupForm.js
file. It should work similarly to thehandleSubmit
callback in thecommon/AccountCreate/index.js
file in terms of detecting required scopes and showing the permission scope error before submitting changes. https://github.com/google/site-kit-wp/blob/9b6f7d745c723f35b2ff820b9539f5a71fcc50be/assets/js/modules/analytics/components/common/AccountCreate/index.js#L125-L155 - The
submitForm
callback should check whether the current user has the edit scope only for the following cases:- UA
propertyID
orprofileID
is eitherproperty_create
orprofile_create
- GA4
propertyID
orwebDataStreamID
is eitherproperty_create
orwebdatastream_create
- UA
- If the current user doesn’t have the required edit scope and wants to create a property, profile or a webdatastream, then set the permission scope error using the
setPermissionScopeError
function (see the example in theAccountCreate
component) and halt the form submission.
Test Coverage
- N/A
Visual Regression Changes
- N/A
QA Brief
- Reset the site-kit plugin and sign in again
- Activate the Analytics module
- On the setup form select an account, UA property/profile, and an option to create a new GA4 property
- When submitting the form, you should see the permissions dialog.
- If you cancel the dialog and go to the settings form, you should still see that the Analytics module is not connected yet (no settings are saved).
- Go to the setup form again and repeat steps but this time don’t cancel the permissions dialog, confirm it and grant additional scopes.
- Go to the Analytics settings again and confirm that you see the Analytics module settings that contain a new GA4 property.
Changelog entry
- Abort saving Analytics settings when required extra permissions are declined for creating a new GA4 property or measurement ID.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Solved: End Users receive pop-up asking for permission whe...
I have created a Power Apps form to submit data to a SharePoint list. This form is shared with the whole organisation providing...
Read more >Change text in the restriction pop up
Hi all Is there any possibility (JS, ScriptRunner, other ideas) to change the text in the restriction pop up? Use Case: A lot...
Read more >Handle pop-ups, permissions, and notifications
Learn how to manage pop-ups, permissions, and notifications in different browsers when running your Selenium tests on BrowserStack Automate.
Read more >NetSuite Applications Suite - SAML SSO Permission ...
Enabling Supply Allocation and the Earliest Available Popup Window ... Using the Published Scope and Published Fields for Mapping in Shopify ...
Read more >RFC 3261 SIP: Session Initiation Protocol
34 8 General User Agent Behavior . ... 174 20.28 Proxy-Authorization . ... One such format is the Session Description Protocol (SDP) (RFC...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@eugene-manuilov Thanks for clarifying the issue here. We should definitely fix this, although I think it should be required to complete the setup.
We do already require GA4 to be set up for any new setup flow, so that shouldn’t change because of a user-caused problem. Also the permissions / scope granted isn’t technically for GA4, it’s a generic GA write scope (although you’re right in that here it would only be used for GA4).
I think what we need to do here is unset/unsave the UA configuration entirely if the user cancels out. Not granting scopes here is like cancelling out the setup flow itself and it’s unexpected to see the module set up after that. The same would happen if the user cancelled the scope prompt when setting up a new UA property, so that should definitely match. I’ll add ACs.
QA Update: ✅
Followed the steps in the QAB and confirm that: