google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 291 forks source link

Dashboard Sharing errors when a user tries to change the active key metric tiles #8703

Open jamesozzie opened 5 months ago

jamesozzie commented 5 months ago

Bug Description

If key metrics are enabled, and user viewing the "View only" version of the Site Kit dashboard changes the key metric tiles that are displayed, some of these tiles when active result in errors. Such errors can include the below:

Error: An error occurred while running 'mapSelect': Maximum call stack size exceeded An error occurred while running 'mapSelect': too much recursion

These issues may occur based on custom dimensions, maybe it's not possible to create them from a view only dashboard (when a user isn't signed in to their Google account).

Testing on this ongoing, to confirm specifically what tiles result in errors. This requires resetting the plugin each time, as resetting Dashboard Sharing and enabling once more doesn't address the issue - other users see the error as soon as they login and click on the "View limited dashboard" button.

Errors that occur when changing tiles from an editor role (within Dashboard Sharing) ![image](https://github.com/google/site-kit-wp/assets/41326532/429f6359-ec02-457a-82e8-34d76e3ef768) ``` googlesitekit-main-d…c70b6953a3715.js:46 Caught an error: Error: An error occurred while running 'mapSelect': Maximum call stack size exceeded The error may be correlated with this previous error: RangeError: Maximum call stack size exceeded at Array.concat () at https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:481214 at n (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:480758) at P.getKeyMetrics (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-datastore-user-c2efb65….js:14:19606) at t (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:77012) at https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:481192 at Object.n [as getKeyMetrics] (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:480758) at P.isKeyMetricActive (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-datastore-user-c2efb65….js:14:20480) at t (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:77012) at https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:481192 Original stack trace: at y (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:181960) at DashboardNavigation (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-main-dashboard-1df411d….js:56:2765) at Fo (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:698600) at ii (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:707461) at Ti (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:746071) at Qj (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:737398) at Kj (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:737323) at wa (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:734353) at https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:685997 at t.unstable_runWithPriority (https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a09….js:7:761247) {componentStack: '\n in DashboardNavigation\n in Header\n in D… in ThemeProvider\n in StrictMode\n in Root'} componentStack : "\n in DashboardNavigation\n in Header\n in DashboardMainApp\n in DashboardEntryPoint\n in RestoreSnapshots\n in ErrorHandler\n in ThemeProvider\n in StrictMode\n in Root" [[Prototype]] : Object constructor : ƒ Object() hasOwnProperty : ƒ hasOwnProperty() isPrototypeOf : ƒ isPrototypeOf() propertyIsEnumerable : ƒ propertyIsEnumerable() toLocaleString : ƒ toLocaleString() toString : ƒ toString() valueOf : ƒ valueOf() __defineGetter__ : ƒ __defineGetter__() __defineSetter__ : ƒ __defineSetter__() __lookupGetter__ : ƒ __lookupGetter__() __lookupSetter__ : ƒ __lookupSetter__() __proto__ : (...) get __proto__ : ƒ __proto__() set __proto__ : ƒ __proto__() ```
Errors that occur from another admin role, who skipped sign in, viewing only the "View only" dashboard ![image](https://github.com/google/site-kit-wp/assets/41326532/26347b54-456a-4509-9d9b-977dd13bfb46) ``` `An error occurred while running 'mapSelect': too much recursion The error may be correlated with this previous error: n@https://wexfordfc.ie/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-2c35a0991fe2cf6f41cb.js:7:480758 761/P.getKeyMetrics

Original stack trace:

in DashboardNavigation
in Header
in DashboardMainApp
in DashboardEntryPoint
in RestoreSnapshots
in ErrorHandler
in ThemeProvider
in StrictMode
in Root`


## Steps to reproduce

<!-- Please provide detailed steps on how to reproduce the bug. -->
1. Enable key metrics on a site (must have traffic in order to enable)
2. Enable dashboard sharing, sharing only the GA module with other users
3. Create another user account (administrator or editor)
4. Login with that new user account
5. Change the tiles active in key metrics. Some tiles when activated result in errors

## Screenshots

<!-- If applicable, please add screenshots to help explain your problem. -->

## Additional Context

<!-- Please complete the following information. -->
 - PHP Version: 8.1
 - SK 1.126.0
 - Tested on 2 different sites

<!-- Please add any additional information about the bug. -->

---------------

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

## Acceptance criteria

* <!-- One or more bullet points for acceptance criteria. -->

## Implementation Brief

* [ ] <!-- One or more bullet points for how to technically resolve the issue. Make sure to include changes to Storybook and visual regression tests where relevant. -->

### Test Coverage

* <!-- One or more bullet points for how to implement automated tests to verify the issue is resolved. -->

## QA Brief

* <!-- One or more bullet points for how to test that the issue has been resolved. -->

## Changelog entry

* <!-- One sentence summarizing the PR, to be used in the changelog. -->
aaemnnosttv commented 4 days ago

This should be addressed by #9567. Once completed, we can review this issue and close it if no longer relevant.