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.

Duplicate error-related messaging in Analytics settings when admin does not have access

See original GitHub issue

Bug Description

In #4825, we updated the edit interface for module settings to only allow editing module settings if the current user has access to the currently configured entity the module is connected with. However, requests are still being made for properties and profiles

image image

Steps to reproduce

  1. Set up Analytics using an account that another Google account does not have access to
  2. Sign in with the second admin which lacks access
  3. Edit settings for Analytics
  4. See error message and info notices about lack of access

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

Acceptance criteria

  • When an user does not have access to the configured Analytics entity, there should not also be errors displayed about that same lack of access
    • Selectors that would be known to invoke such failing requests that will fail should be prevented from running

Implementation Brief

  • Within assets/js/modules/analytics/components/common/ProfileSelect.js, PropertySelect.js and assets/js/modules/analytics-4/components/common/PropertySelect.js:
    • Default the hasModuleAccess prop to true (for clarity purposes as per the comments below).
    • Wrap the calls to select() the getProperties() and getProfiles() selectors with a check for when hasModuleAccess is specifically false. If it is, return null. E.g.
        const profiles = useSelect( ( select ) => {
    	if ( hasModuleAccess === false ) {
    		return null;
    	}
    	return select( MODULES_ANALYTICS ).getProfiles(
    		accountID,
    		propertyID
    	);
    } );
    

Test Coverage

  • Add coverage to existing JS (RTL) tests for the above components when hasModuleAccess is false (or undefined).

QA Brief

  • Create an admin, say “Admin1” to setup SiteKit. Also setup Analytics and create a new property or use an existing one that is connected to Admin1’s account.

  • Verify that Analytics settings works as usual when user does have access:

    • As Admin1, login to the “Analytics Dashboard” (by clicking on “See full details in Analytics” within the Analytics accordion in SiteKit’s Settings). Click on the “Admin” settings cog in the left menu. Under the first “Account” column, click on “Account Access Management”. In the popup, click on the + sign to add Admin2’s Google Account to this account. Now login to SiteKit as Admin2, go to Analytics Settings and try editing them. Verify the ACs for when user has access.
    • Screenshot 2022-06-07 at 10 47 57
  • Verify that Analytics settings does not throw additional red errors when user does not have access:

    • In Admin1’s “Analytics Dashboard” mentioned above, follow the steps to go to Account Settings. In the “Account Access Management” popup, click on the 3 dots next to Admin2’s Google Account and click on remove access. Now login to SiteKit as Admin2, go to Analytics Settings and try editing them again. Verify the ACs for when user does not have access.

Changelog entry

  • Fix duplicate error-related messaging in Analytics settings when admin does not have access.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
techanvilcommented, Aug 8, 2022

Hi @jimmymadon , a small but important detail - looking at the components mentioned in the IB, the hasModuleAccess prop is being explicitly checked for === false, rather than just for being falsey, so this should also be the case for the new hasModuleAccess checks described in the IB.

Also - in each case, when hasModuleAccess is false, the properties or profiles value is disregarded, so it’s not really necessary to set to [] - I know this might be splitting hairs but I’d argue that setting to [] gives the impression it’s intended to be used, maybe undefined would be better?

One final point, seeing as there are JS tests for each of the components, but presently no test for the hasModuleAccess === false case, I would suggest adding tests for each component to cover this case…

0reactions
mohitwpcommented, Sep 6, 2022

QA Update ✅

Verified 👍

  • Followed the steps to reproduce the issue and able to reproduce issue.
  • Verified when google a/c have analytics access. User is able to edit analytics settings and no error notice is showing.
  • Verified when google a/c doesn’t have analytics access. User is not able to edit analytics settings and there are no errors displaying about that same lack of access and no requests are getting made.
  • Also, verified for the scenario if user had previously access to analytics and if owner of the analytics remove that access for the user. In this case if user already logged in Site Kit Dashboard and tried to edit settings without refreshing the page then in this case notice appear and user not able to edit settings which is expected.

After refreshing or login again

https://user-images.githubusercontent.com/94359491/188546437-a06bf040-fd6a-42f2-88c2-c2b410420818.mp4

Without Refresh

https://user-images.githubusercontent.com/94359491/188546497-5eff861c-1a84-4176-ad61-0d2d864968a9.mp4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Restrict editing module entity settings to users who have access ...
If the current user does not have access to the module, the inputs that control the module's connection (i.e. owned settings) should be...
Read more >
Create a copy of a view - Analytics Help - Google Support
How to copy a view · Sign in to Google Analytics.. · Click Admin, and navigate to the view you want to copy....
Read more >
Internal Server Error when you enable CRM Analytics
This message may be received by users that do not have the System Permission of "Manage Analytics" and the Profile permission of "Customize...
Read more >
29 Common Google Analytics Data Errors And How To Fix Them
Google Analytics data not showing all traffic or no view data? Here's why your data is wrong and how to fix the most...
Read more >
You receive one or more error messages when the system ...
To resolve this issue, contact the local system administrator to determine whether Windows Update access is disabled by Group Policy settings. For home...
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