Skip to content

Event listener callback not triggering when 'eventInfo' is set on an event #93

@charltoncraig

Description

@charltoncraig

Expected Behaviour

When an event of the format {'event':eventName,'eventInfo':info} is pushed into window.adobeDataLayer, any event listener registered to handle this event being pushed should fire it's callback function

Actual Behaviour

When the 'eventInfo' key is included in the event object, the callback function does not fire

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Navigate to about:blank in a browser
Execute the following in the console

window.adobeDataLayer = window.adobeDataLayer || []
scriptElement = document.createElement('script');
scriptElement.src="https://unpkg.com/@adobe/adobe-client-data-layer@1.0.0/dist/adobe-client-data-layer.min.js";
document.body.append(scriptElement)

window.adobeDataLayer.push({'event':'newEvent','eventInfo':'test'})

var myHandler = function(event) {
    console.log(event)
}

window.adobeDataLayer.push(function(dl) {
    dl.addEventListener(
        "adobeDataLayer:event", 
        myHandler
    )
})

(Optional) Execute the following in the console to see the callback function executing correctly

window.adobeDataLayer = window.adobeDataLayer || []
scriptElement = document.createElement('script');
scriptElement.src="https://unpkg.com/@adobe/adobe-client-data-layer@1.0.0/dist/adobe-client-data-layer.min.js";
document.body.append(scriptElement)

window.adobeDataLayer.push({'event':'newEvent','notEventInfo':'test'})

var myHandler = function(event) {
    console.log(event)
}

window.adobeDataLayer.push(function(dl) {
    dl.addEventListener(
        "adobeDataLayer:event", 
        myHandler
    )
})

Platform and Version

Chrome v83.0.4103.116

Sample Code that illustrates the problem

Logs taken while reproducing problem

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions