Skip to content

Limit API requests when the user doesn't have access to the connected entity #7033

Open

Description

Bug Description

If a user doesn't have access to the connected Analytics account they'll encounter an error message indicating this, as expected.

image

When checking the browser console there are multiple requests made, see below.

Console errors
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/ana…5B0%5D%5Bname%5D=date&startDate=2023-08-12&endDate=2023-09-08&_locale=user 403
index.js:199 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics-4 error:"User does not have sufficient permissions for this property. To learn more about Property ID, see https://developers.google.com/analytics/devguides/reporting/data/v1/property-id."
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/ana…etricName%5D=totalUsers&orderby%5B0%5D%5Bdesc%5D=true&limit=6&_locale=user 403
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/ana…3-09-08&orderby%5B0%5D%5Bdimension%5D%5BdimensionName%5D=date&_locale=user 403
index.js:199 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics-4 error:"User does not have sufficient permissions for this property. To learn more about Property ID, see https://developers.google.com/analytics/devguides/reporting/data/v1/property-id."
index.js:199 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics-4 error:"User does not have sufficient permissions for this property. To learn more about Property ID, see https://developers.google.com/analytics/devguides/reporting/data/v1/property-id."
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/ana…3-09-08&compareStartDate=2023-07-15&compareEndDate=2023-08-11&_locale=user 403
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/analytics-4/data/conversion-events?_locale=user 403
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/ana…0Search&orderby%5B0%5D%5Bdimension%5D%5BdimensionName%5D=date&_locale=user 403
index.js:199 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics-4 error:"User does not have sufficient permissions for this property. To learn more about Property ID, see https://developers.google.com/analytics/devguides/reporting/data/v1/property-id."
index.js:199 Google Site Kit API Error method:GET datapoint:conversion-events type:modules identifier:analytics-4 error:"The caller does not have permission"
index.js:199 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics-4 error:"User does not have sufficient permissions for this property. To learn more about Property ID, see https://developers.google.com/analytics/devguides/reporting/data/v1/property-id."
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/ana…rs%5BsessionDefaultChannelGrouping%5D%5B0%5D=Organic%20Search&_locale=user 403
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/ana…0Search&orderby%5B0%5D%5Bdimension%5D%5BdimensionName%5D=date&_locale=user 403
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/analytics-4/data/property?propertyID=328495990&_locale=user 403
index.js:199 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics-4 error:"User does not have sufficient permissions for this property. To learn more about Property ID, see https://developers.google.com/analytics/devguides/reporting/data/v1/property-id."
index.js:199 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics-4 error:"User does not have sufficient permissions for this property. To learn more about Property ID, see https://developers.google.com/analytics/devguides/reporting/data/v1/property-id."
index.js:199 Google Site Kit API Error method:GET datapoint:property type:modules identifier:analytics-4 error:"The caller does not have permission"
tsp.bundle.js:1 
 GET https://tradeargument.s3-tastewp.com/wp-json/google-site-kit/v1/modules/ana…ame%5D=screenPageViews&orderby%5B0%5D%5Bdesc%5D=true&limit=10&_locale=user 403
index.js:199 Google Site Kit API Error method:GET datapoint:report type:modules identifier:analytics-4 error:"User does not have sufficient permissions for this property. To learn more about Property ID, see https://developers.google.com/analytics/devguides/reporting/data/v1/property-id."

If possible limit API requests if it's known a user doesn't have access.

image

omIxIahmxu.1.mp4

The same may apply to AdSense, or even Search Console in rate occasions where one administrator removes verification from another at Search Console level (if verification was done prior to Site Kit setup, via non Site it means, ie. HTML file upload).

Steps to reproduce

  1. Set up Site Kit on a new site (with Analytics)
  2. Create another WP Administrator account
  3. Login to that new user account from another browser session
  4. Set up Site Kit using a Google account that doesn't have access to the Analytics property connected by another administrator
  5. When landing back on the SK dashboard you'll notice permissions errors as expected
  6. Check the browser console for errors

Screenshots


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

Acceptance criteria

  • For modules that implement reporting on the dashboard for their connected entities which require access at the Google account level, if a request for a report fails with an insufficient permissions error, any subsequent report requests for that module should be skipped until access is confirmed to be re-established
    • This state should persist across page reloads but remain on the client only
  • If any module with report requests being skipped, a non-dismissible alert should be displayed at the top explaining that the dashboard is in a kind of data-interrupted state (listing all affected modules), similar to the recoverable modules alert
    • There should be a button to check access, which should make a single request per-module to test access to the respective module, and if successful, the block for report requests for that module should be cleared, allowing it to resume normal reporting functionality

Implementation Brief

Test Coverage

QA Brief

Changelog entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Module: AdSenseGoogle AdSense module related issuesModule: AnalyticsGoogle Analytics module related issuesModule: Search ConsoleSearch Console module related issuesP1Medium priorityType: EnhancementImprovement of an existing featureType: SupportSupport requestUXIssues that require UX input

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions