Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred while running ‘mapSelect’: Cannot read properties of undefined (reading ‘forEach’) #10187

Open
jamesozzie opened this issue Feb 6, 2025 · 3 comments
Assignees
Labels
Module: Analytics Google Analytics module related issues P0 High priority Team S Issues for Squad 1 Type: Bug Something isn't working Type: Support Support request

Comments

@jamesozzie
Copy link
Collaborator

jamesozzie commented Feb 6, 2025

Bug Description

A couple of support topics were opened - although likely from admins of the same site, whereby the following dashboard error appears:
An error occurred while running ‘mapSelect’: Cannot read properties of undefined (reading ‘forEach’)

They mentioned that this occurred only after updating to the latest version of Site Kit (1.145.0).

Full error as reported in the forums:

An error occurred while running ‘mapSelect’: Cannot read properties of undefined (reading ‘forEach’)
The error may be correlated with this previous error:
TypeError: Cannot read properties of undefined (reading ‘forEach’)
at https://trinityua.com/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-modules-analytics-4-e7215bb257eaff98a241.js:130:106266
at Array.forEach ()

This specific error was also raised by @wpdarren in Slack (link)

Within that discussion on this error, a recording with details was included.

Additional Context

cc. @aaemnnosttv

@wpdarren observed this independently in his own testing but was unable to reproduce
An error occurred while running 'mapSelect': Cannot read properties of undefined (reading 'forEach')
The error may be correlated with this previous error:
TypeError: Cannot read properties of undefined (reading 'forEach')
    at https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-modules-analytics-4-481b89c2cd44559a7bb4.js:132:106952
    at Array.forEach (<anonymous>)
    at qn.getAnalyticsConfigByMeasurementIDs (https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-modules-analytics-4-481b89c2cd44559a7bb4.js:132:106899)
    at t (https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-55f6d4109c59b75ef2bd.js:7:30983)
    at https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-55f6d4109c59b75ef2bd.js:7:486663
    at Object.n [as getAnalyticsConfigByMeasurementIDs] (https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-55f6d4109c59b75ef2bd.js:7:486228)
    at Object.current (https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-main-dashboard-a4bcd8e2d49c8c193c4e.js:94:8505)
    at e (https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-55f6d4109c59b75ef2bd.js:7:197958)
    at https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-55f6d4109c59b75ef2bd.js:7:198121
    at https://site-kit-146.instawp.xyz/wp-content/plugins/google-site-kit/dist/assets/js/googlesitekit-vendor-55f6d4109c59b75ef2bd.js:7:491524
Original stack trace:
    in GoogleTagIDMismatchNotification
    in BannerNotifications
    in div
    in Header
    in DashboardMainApp
    in DashboardEntryPoint
    in RestoreSnapshots
    in ErrorHandler
    in ThemeProvider
    in StrictMode
    in Root

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

Acceptance criteria

  • Audit the analytics-4 code base, particularly the datastore + getAnalyticsConfigByMeasurementIDs selector for instances of forEach on values which may not be defined
    • For each, reproduce the error with a test and fix

Implementation Brief

  • Update getAnalyticsConfigByMeasurementIDs to handle cases where an account summary may not have any propertySummaries as these are not set if the account has none
  • Finish and merge Fix/10187-forEach-error #10192

Test Coverage

  • Update coverage for areas identified above

QA Brief

  1. Setup Site Kit with Analytics.
  2. Go to Site Kit settings for Analytics and edit, then create a new Analytics account.
  3. Enter a account, property and web data stream name.
  4. Disable the Enhanced Measurement toggle. (I will see if the same happens with this enabled)
  5. You’ll go through the steps to create a new Analytics account. Click the button to go back to the dashboard.
  6. Wait for 10 seconds and ensure no fatal errors appear.

Changelog entry

  • Fix error that could occur on the dashboard when connecting a new Analytics account after connecting a previously-connected account.
@jamesozzie jamesozzie added Module: Analytics Google Analytics module related issues Type: Bug Something isn't working Type: Support Support request labels Feb 6, 2025
@aaemnnosttv aaemnnosttv self-assigned this Feb 6, 2025
@aaemnnosttv aaemnnosttv removed their assignment Feb 6, 2025
@aaemnnosttv
Copy link
Collaborator

Sending to IBR as I'm not sure there are any other instances where this could be raised, and I was able to reproduce the same error in a test. The reported error is wrapped in "mapSelect" which just means the underlying error was raised within.

Image

@aaemnnosttv aaemnnosttv added the P0 High priority label Feb 6, 2025
@mohitwp
Copy link
Collaborator

mohitwp commented Feb 7, 2025

I'm able simulate this on one older site. The only difference I’ve noticed is that on the site where this error is appearing, I created multiple analytics accounts yesterday as part of the process to recreate this issue.

Image

@aaemnnosttv aaemnnosttv mentioned this issue Feb 7, 2025
19 tasks
@aaemnnosttv
Copy link
Collaborator

Moving to CR for potential inclusion in release

@tofumatt tofumatt added the Team S Issues for Squad 1 label Feb 10, 2025
@tofumatt tofumatt assigned tofumatt and unassigned tofumatt Feb 10, 2025
@mohitwp mohitwp self-assigned this Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Analytics Google Analytics module related issues P0 High priority Team S Issues for Squad 1 Type: Bug Something isn't working Type: Support Support request
Projects
None yet
Development

No branches or pull requests

4 participants