site-kit-wp: An error occurred while running 'mapSelect': Cannot read properties of null (reading 'isGA4DashboardView')
Bug Description
A couple of users in the support forum reported the following error :
An error occurred while running 'mapSelect': Cannot read properties of null (reading 'isGA4DashboardView')
We don’t have the Site Health information from either user at this point, troubleshooting ongoing. One user did state the error no longer occurred after refreshing the page. Based on the full errors (below) this seems to occur on the main WordPress dashboard:
Stack trace and error - user one
An error occurred while running 'mapSelect': Cannot read properties of null (reading 'isGA4DashboardView')
The error may be correlated with this previous error:
TypeError: Cannot read properties of null (reading 'isGA4DashboardView')
at Object.current (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-wp-dashboard-a39ff88870d0d0a0e5e9.js:58:2269)
at e (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:412134)
at https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:412241
at Ii (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:735601)
at Ji (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:735704)
at Sj (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:753648)
at t.unstable_runWithPriority (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:772969)
at Hr (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:697428)
at Jj (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:750120)
at wa (https://XXXXXXXX.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-134c6e6e324fdd7d5926.js:7:746274)
Original stack trace:
in WPDashboardWidgets
in div
in WPDashboardApp
in RestoreSnapshots
in ErrorHandler
in ThemeProvider
in StrictMode
in Root
o
Stack trace and error - user two
An error occurred while running 'mapSelect': Cannot read properties of null (reading 'isGA4DashboardView')
The error may be correlated with this previous error:
TypeError: Cannot read properties of null (reading 'isGA4DashboardView')
at Object.current (https://digitalworldcity.in/wp-content/litespeed/js/0a30a8a69a126443599f621174c2bcc9.js?ver=2bcc9:1:89872)
at e (https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:542145)
at https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:542252
at Ii (https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:865612)
at Ji (https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:865715)
at Sj (https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:883663)
at t.unstable_runWithPriority (https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:902986)
at Hr (https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:827439)
at Jj (https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:880133)
at wa (https://digitalworldcity.in/wp-content/litespeed/js/226248304ba392d529bfef0bb0a1ab57.js?ver=1ab57:1:876285)
Original stack trace:
in AdminBarWidgets
in div
in Cell
in div
in Row
in div
in Grid
in AdminBarApp
in RestoreSnapshots
in ErrorHandler
in ThemeProvider
in StrictMode
in Root
- https://wordpress.org/support/topic/an-error-occurred-while-running-mapselect-15 | Open | No SH info
- https://wordpress.org/support/topic/an-error-occurred-while-running-mapselect-14 | Open | No SH info
Steps to reproduce
Unreproducible so far at support level
Screenshots
No screenshots thus far
Additional Context
- On the one site where we have the site URL, they’re using SK 1.99.0. The GA output shows both a UA and a GA4 snippet, without a Google tag ID.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The WP dashboard widgets app should not crash if Analytics is not available, nor should errors be shown in the widget
- In this case, only Search Console widgets should be visible
Implementation Brief
- The issue happens when javascript on the frontend is additionally minified via plugin, causing this line to throw weird error https://github.com/google/site-kit-wp/blob/f5b7620c5a71997deae3639ca1523dc425c5e5fb/assets/js/components/SourceLink.js#L49 Which keeps
analytics
storeundefined
even modules is detected as active and available, which results inisGA4DashboardView
selector throwing the error. - Since
GA4
view will be the only available one, after feature flag removal in #6856, remove this selector entirely https://github.com/google/site-kit-wp/blob/b80ce4ea163e041e4ae54c2b1d20bb07e369e10e/assets/js/modules/analytics/datastore/settings.js#L294 - Remove it’s usage, and where it is used to conditionally render components/markup, return only the ones that would be used if
isGA4DashboardView
is true. At the time of writing, it is used in:assets/js/modules/analytics/datastore/base.js
assets/js/components/adminbar/AdminBarWidgets.js
assets/js/components/notifications/SwitchedToGA4Banner.js
assets/js/components/notifications/ZeroDataStateNotifications/GatheringDataNotification.js
assets/js/components/notifications/ZeroDataStateNotifications/index.js
assets/js/components/wp-dashboard/WPDashboardWidgets.js
assets/js/googlesitekit/datastore/user/permissions.js
assets/js/googlesitekit/modules/datastore/modules.js
assets/js/modules/adsense/index.js
assets/js/modules/analytics/index.js
assets/js/modules/analytics/components/module/ModulePopularPagesWidget/Footer.js
assets/js/modules/analytics/datastore/notifications.js
assets/js/modules/search-console/index.js
assets/js/modules/search-console/components/common/AnalyticsStats.js
assets/js/modules/search-console/components/dashboard/SearchFunnelWidget/Footer.js
- Remove
isGA4DashboardView
if found anywhere else
Test Coverage
- No changes needed
QA Brief
This fix will prevent current error when js is minified with plugins (not guaranteed for all plugins and they can break different things when doing minifications). Solution is tested with plugin that one of the users mentioned in the support forums. Usage with js compiled for production build (dev bundle includes additional webpack references which will break the minifications), will properly portray the fix.
As a solution, applied fix is removing one of the function related to checking between GA4 and UA view, and which was connected to the minified issue. So besides the checks for described bug, be on a lookup for any regression, especially when it comes to Analytics 4 modules and widgets.
- Setup Site Kit
- Install
Speed Optimizer - The All-In-One WordPress Performance-Boosting Plugin
- Enable javascript minify option from
Site Optimizer -> Frontend -> Javascript
- On homepage for example, hover over
Sitekit
top bar menu - Verify there is no error showing in the dropdown
- Go through Site Kit dashboard and check for any issue, ensure that all widgets are working properly
- Go through WordPress dashboard and ensure Site kit widgets are working properly
- Check general connect/disconnect/reset of Analytics module
Changelog entry
- Remove non-GA4 dashboard view.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 17
@aaemnnosttv
Ahh got it, sorry about that.
Updated IB to remove the selector entirely, and incremented the estimate, to reflect on the new changes.
I found this can happen if the Analytics module’s JS is blocked or unable to load for whatever reason. One example in a linked support topic is manipulation/combination by a caching plugin.
This could also happen if Analytics isn’t available as a registered module although support for this has always been a bit incomplete. Will move this forward 👍