Duplicate error-related messaging in Analytics settings when admin does not have access
See original GitHub issueBug 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
Steps to reproduce
- Set up Analytics using an account that another Google account does not have access to
- Sign in with the second admin which lacks access
- Edit settings for Analytics
- 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.jsandassets/js/modules/analytics-4/components/common/PropertySelect.js:Default thehasModuleAccessprop to true (for clarity purposes as per the comments below).- Wrap the calls to
select()thegetProperties()andgetProfiles()selectors with a check for whenhasModuleAccessis specifically false. If it is, returnnull. 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.
-
-
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:
- Created a year ago
- Comments:9
Top 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 >
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

Hi @jimmymadon , a small but important detail - looking at the components mentioned in the IB, the
hasModuleAccessprop is being explicitly checked for=== false, rather than just for being falsey, so this should also be the case for the newhasModuleAccesschecks described in the IB.Also - in each case, when
hasModuleAccessisfalse, thepropertiesorprofilesvalue 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, maybeundefinedwould be better?One final point, seeing as there are JS tests for each of the components, but presently no test for the
hasModuleAccess === falsecase, I would suggest adding tests for each component to cover this case…QA Update ✅
Verified 👍
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