Data requests fail on shared dashboard for connected but non-shared modules
See original GitHub issueBug Description
Bug bash issue: https://app.asana.com/0/1202258919887896/1202410303658780 please refer to Asana issue for background
The main admin has connected all modules, but has not given access to all of them for administrators. When the second admin logs in and goes to the shared dashboard, all of the widgets load as expected, but errors appear in the console:
Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics error:"Site Kit can’t access the relevant data from Analytics because you haven’t granted all permissions requested during setup."
The message appears for each module that they do not have permission to view.
No errors appear within the dashboard itself.
Steps to Reproduce
- Enable Dashboard Sharing
- Using the “main admin”, connect all modules, but do no grant access for all modules to others administrators. (Eg. Give all admins access to a single module like Search Console, but not Analytics or other modules)
- Sign in as a second admin and visit the shared dashboard
- All of the widgets load as expected, but errors appear in the browser console:

Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Browser/console errors should not appear in the console when viewing the shared dashboard as a second admin that doesn’t have access to every module on the dashboard.
- The cause of this is requests being sent to our REST API (Analytics endpoint) when Analytics is not shared with this user, so requests should not be made for modules the user doesn’t have access to on the shared dashboard.
Implementation Brief
Preventing Analytics getReport API requests if the Analytics module is not shared to view
-
To check the user has access to view Analytics, using the
canViewSharedModule( 'analytics' )selector, conditionally call thegetReport,getGoals,isGatheringData, andhasZeroDataselectors along with the existing conditions if there are any in the following files:assets/js/modules/search-console/components/dashboard/SearchFunnelWidget/index.jsassets/js/modules/search-console/components/dashboard/SearchFunnelWidget/Overview.jsassets/js/modules/analytics/components/dashboard/DashboardAllTrafficWidget/index.jsassets/js/components/notifications/ZeroDataStateNotifications/index.js- See: https://github.com/google/site-kit-wp/blob/develop/assets/js/modules/search-console/components/dashboard/SearchFunnelWidget/index.js#L79-L85
-
Note: Currently, if the user doesn’t have access to Analytics, it still shows
Analytics gathering Data. Applying the changes above in theZeroDataStateNotificationswill fix the problem. Refer to the following screenshot:

-
Note: There is a request failure for Search Console settings; however, this is being implemented in #5310
-
Refer to the WIP draft PR.
Test Coverage
- No new tests are to be added.
QA Brief
- Follow the steps to reproduce the issue.
- Verify there are no
AnalyticsAPI request failures/errors on the console and the network tab if the user has view-only access. - Note: There is a request failure for Search Console settings; however, this is being implemented in #5310
Changelog entry
- Prevent data requests on shared dashboard for connected but non-shared modules.
Issue Analytics
- State:
- Created a year ago
- Comments:5

Top Related StackOverflow Question
Noting this issue is similar to https://github.com/google/site-kit-wp/issues/5310 but addresses a different cause.
This issue is caused by components which conditionally select data based on a module’s connected state, however in a view-only context this isn’t sufficient to know if that data can actually be requested or not.
e.g.
ZeroDataStateNotificationsThis is also not specific to the user’s role, but generally for non-authenticated users.
QA Update: ✅
Verified: