Problem/Motivation

Uncaught TypeError: drupalSettings.matomo is undefined

In matomo.module in function:

function matomo_page_attachments(array &$page) {

we have:
if ((_matomo_visibility_pages() || in_array($status, $trackable_status_codes)) && _matomo_visibility_user($account)) {
in that if: "trackMailto" is set.

Thus when javascript tries to check for drupalSettings.matomo.trackMailto inside of matomo.js this error gets triggered?

Steps to reproduce

Drupal 10 + Js aggregation.
When editing a block on a layout builder page > this error is triggered.

Proposed resolution

Check if the variable exists (or set it by default?)

Remaining tasks

Review

Issue fork matomo-3436780

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Mschudders created an issue. See original summary.

mschudders’s picture

merge request provided

grimreaper’s picture

Version: 8.x-1.23 » 8.x-1.x-dev
Assigned: Unassigned » grimreaper
grimreaper’s picture

Strange because the only time the "matomo/matomo" library is added on the page, it is in this if statement too.

So the drupalSettings should be also. present.

I will try another approach with putting default settings into the library.yml.

  • grimreaper committed 20b36471 on 8.x-1.x authored by mschudders
    fix: #3436780 Uncaught TypeError: drupalSettings.matomo is undefined
    
    By...

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.