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.

Include a "request access" link to Analytics when a user encounters an "Insufficient Permissions" notice

See original GitHub issue

Bug Description

When an admin sets up Site Kit and they don’t have access to the already connected Analytics property, which was connected by another admin, they encounter an insufficient permissions notice. Consider adding a link to that specific Google Analytics property page, so users can “request access”. That way they don’t need to specifically know the administrator in question, as the username doesn’t always appear within the error.

Note that this link already exists within the Site Kit dashboard, but only under the “Top content over the last ** days” widget, see example in the video within this issue:

image

The link should look something like this, including the users email and property details: https://analytics.google.com/analytics/web/?authuser=**emailhandle**%40gmail.com#/report/content-pages/a145833174w302476565p260252701/_u.date00=20220503&_u.date01=20220530/

Steps to reproduce

  1. Set up Site Kit while also connecting Analytics
  2. Login as another wp-admin user that doesn’t have access to the connected GA property
  3. Set up Site Kit
  4. You’ll see the “Insufficient permissions” notice
  5. Only by clicking on the Analytics link in the lower Analytics widget (Top content over the last 28 days) will you be directed to a link where you can “request access”

https://user-images.githubusercontent.com/41326532/171373350-21cce51b-5895-4682-85f2-c373a1e3eaf8.mp4

Additional Context

Should this be added it would solve the problem as described in https://github.com/google/site-kit-wp/issues/5267

A possible fix to this would be to change the text to the below:

- Your Google account does not have sufficient permissions to access Analytics data, so you won’t be able to see stats from it on the Site Kit dashboard. This service was originally connected by the administrator "****" — you can contact them for more information.. 
+ Your Google account does not have sufficient permissions to access Analytics data, so you won’t be able to see stats from it on the Site Kit dashboard. This service was originally connected by the administrator "****" — you can contact them for more information, or **request access here**.

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

Acceptance criteria

  • All JS stores for modules where the Google service allows requesting access for an entity where the account does not have access currently, should receive a new selector consistently named getServiceEntityAccessURL (parameter-less). These are:
    • Analytics: Should basically return the same as getServiceReportURL selector with type set to report-home.
    • Search Console: Should return the same as getServiceURL selector with a single query argument resource_id set to the current Search Console property ID.
    • All other Google services do not have any UI that would inform about how to get access.
  • Any “insufficient permissions” error message (for any module/service) should be conditionally enhanced as follows:
    • If the module’s data store includes a getServiceEntityAccessURL selector, a primary CTA button with label “Request access” should be shown below the error message that links to the service URL (i.e. the plain service URL from the selector).
      • From there, the respective Google service will show corresponding UI for what the end user can do to get access.
    • The button should look similarly to the retry button (conditionally added to other types of errors) from #5236.
  • A Storybook story for one of these errors should be added, alongside the existing story for the retry button (see #5236).

Implementation Brief

  • Within /assets/js/modules/analytics/datastore/service.js and /assets/js/modules/search-console/datastore/service.js:
    • Create a new getServiceEntityAccessURL selector using createRegistrySelector(). Define the new selector as per the AC.
  • Within ReportError:
    • Use the getModuleStoreName selector from the CORE_MODULES store.
    • Call the new getServiceEntityAccessURL selector on the module’s store only if the function exists, e.g. typeof select( moduleStoreName ).getServiceEntityAccessURL === 'function'.
    • If the selector returns a value and if one of the errors is an “Insufficient Permissions Error” (use the selector isInsufficientPermissionsError), then return a <Button> with the label Request access similar to how the Retry button is being added currently.
  • Modify the existing “ReportError with Insufficient Permissions” story mocking the data of a module which has the getServiceEntityAccessURL selector.

Test Coverage

  • Add tests for the new selectors.

QA Brief

  • Follow the steps in the description to reproduce the issue.
  • Ensure the Request access button with the URL is rendered for Analytics and Search Console insufficient permission errors.
  • Click the Request access button from the Analytics and Search Console and ensure they navigate to the right place to request access.
  • For CR, ensure this new story is as expected.
  • For QA, ensure this new story is as expected.

Follow-up PR Update

  • Ensure the Request access button and the Get help link are aligned vertically, as pointed out in this comment.

Screenshot 2022-09-09 at 2 45 19 PM

Changelog entry

  • Add “Request access” button to permission error messages for modules where their service supports it.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
felixarntzcommented, Aug 11, 2022

@aaemnnosttv SGTM, I’ve updated the ACs accordingly. I shortened it a bit to just getServiceEntityAccessURL though. Note that this is actually only relevant for Analytics and Search Console, so with the new selector that part is also improved and we don’t unnecessarily add these buttons for services where it doesn’t make sense.

@jimmymadon @techanvil This should be ready to iterate on the IB based on the updated ACs. Of course due to the new first point, the estimate is likely to increase a little.

1reaction
wpdarrencommented, Sep 9, 2022

QA Update: ✅

Apologies, I should have picked up on this! I can confirm that the ‘Get Help’ text is aligned to the request access text.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Request access to Analytics - Google Support
If you receive a link to Analytics data, for example, to a report or dashboard, and you don't have access to the account,...
Read more >
Dashboard - Site Kit by Google
This notice is related to Google Analytics. ... Data error in Search Console: User does not have sufficient permissions for site.
Read more >
Insufficient permissions in Analytics - WordPress.org
Your Google account does not have sufficient permissions for this Analytics account, so you won't be able to see stats from it on...
Read more >
API Returned a 403 Response / Error - MonsterInsights
Step 1: Navigate to analytics.google.com and go to Admin. Then click into your Property Settings » and make a note of the Default...
Read more >
Reference-Tableau Server REST API
To get a list of data sources embedded in a workbook, use the Query Workbook ... data from a view that the user...
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