question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected behavior when canceling permission scope popup for a UA-only account

See original GitHub issue

Feature 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:

  1. Reset the plugin and connect it again to make sure you start from scratch.
  2. Connect the Analytics module.
  3. At the setup form, select an account that has UA property(ies) only.
  4. Submit the setup form.
  5. After some time the form will display the permissions error dialog, click “Cancel” link.
  6. The form stops doing anything although it has already saved UA property settings.
  7. 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 the assets/js/modules/analytics/components/setup/SetupForm.js file. It should work similarly to the handleSubmit callback in the common/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 or profileID is either property_create or profile_create
    • GA4 propertyID or webDataStreamID is either property_create or webdatastream_create
  • 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 the AccountCreate 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:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
felixarntzcommented, Sep 8, 2021

@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.

0reactions
wpdarrencommented, Sep 29, 2021

QA Update: ✅

Followed the steps in the QAB and confirm that:

  • When you select a UA property you see an option to create a new GA4 property. - Screenshot
  • When submitting the form, you see the permissions dialog and if you cancel the dialog and go to the settings form, you see that the Analytics module is not connected yet. - Screenshot
  • When you go to the setup form again and repeat steps but don’t cancel the permissions dialog, when you go to the Analytics settings again you see the Analytics module settings that contain a new GA4 property. - Screenshot
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found