-
Notifications
You must be signed in to change notification settings - Fork 62
Description
A customer was seeing an error stating Uncaught RangeError: Maximum call stack size exceeded in the JS console while matomo.js was loading. It was found that window.MatomoTagManager.dataLayer.events contained a very large number of identical entries for {event: 'mtm.CustomEvent', mtm.CustomEventMatch: 'mtm.CustomEvent'}. There was apparently a trigger which was triggering on events named mtm.CustomEvent. Searching the JSON of the container, there was no trigger checking for eventName equal to mtm.CustomEvent. However, there was a DataLayer variable for the dataLayer event property and a CustomEvent trigger was watching that.
As a workaround, the DataLayer variable can be updated to automatically convert the value if it equals mtm.CustomEvent. Here's a tested example:
Problem:
- CustomEvent triggers automatically push an event onto the dataLayer when the
eventNamematches which can cause a circular reference if the name equalsmtm.CustomEvent.
Solution:
- The CustomEvent trigger shouldn't allow the field for the name of the event to equal
mtm.CustomEvent. The UI should show a validation error. - There should also be a check in the JS to prevent events named
mtm.CustomEventfrom triggering an event and being pushing onto the dataLayer. This is necessary for existing setups and because UI validation can't prevent variables from having the value ofmtm.CustomEventat runtime.
