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

GJSS TEST ISSUE #1 #143

Open
github-jira-sync-bot opened this issue Sep 8, 2022 · 1 comment
Open

GJSS TEST ISSUE #1 #143

github-jira-sync-bot opened this issue Sep 8, 2022 · 1 comment
Labels

Comments

@github-jira-sync-bot
Copy link
Collaborator

Is seems that the ACDL script is adding events to the adobeDataLayer array only after the callbacks of the events have completed. This leads to an odd ordering of the event entries in the adobeDataLayer array.

Consider the following script:
``{{html
<!doctype html>

<script src="https://unpkg.com/@adobe/[email protected]/dist/adobe-client-data-layer.min.js" async defer></script> <script> window.adobeDataLayer = window.adobeDataLayer || <];
        window.adobeDataLayer.push(function (dl) {
            dl.addEventListener("one", function () {
                logItemEvent("2: ", 0);
                logItemEvent("2: ", 1);

                dl.push({ event: "two" });

                logItemEvent("3: ", 0);
                logItemEvent("3: ", 1);
            });

            logItemEvent("1: ", 0);
            logItemEvent("1: ", 1);

            dl.push({ event: "one" });

            logItemEvent("4: ", 0);
            logItemEvent("4: ", 1);
                
            function logItemEvent(prependText, item) {
                if (dl[item> && dl<item>.event) {
                    return console.log(prependText<ins>"adobeDataLayer<"</ins>item<ins>">.event = "</ins>dl<item>.event);
                }
                return console.log(prependText<ins>"adobeDataLayer<"</ins>item<ins>"> = "</ins>dl<item>);
            }
        });
    </script>
</head>
<body></body>
}}``

The resulting log output is:

1: adobeDataLayer<0> = undefined
1: adobeDataLayer<1> = undefined
2: adobeDataLayer<0> = undefined
2: adobeDataLayer<1> = undefined
3: adobeDataLayer<0>.event = two
3: adobeDataLayer<1> = undefined
4: adobeDataLayer<0>.event = two
4: adobeDataLayer<1>.event = one

But the expected output would have been:

1: adobeDataLayer<0> = undefined
1: adobeDataLayer<1> = undefined
2: adobeDataLayer<0> = one
2: adobeDataLayer<1> = undefined
3: adobeDataLayer<0>.event = one
3: adobeDataLayer<1> = two
3: adobeDataLayer<0>.event = one
3: adobeDataLayer<1> = two

It would be expected that the ACDL appends the event object to the adobeDataLayer array prior to calling the callbacks that have been registered to that event, and not after. Because otherwise, notice how the events one and two end up in the reverse order.

@github-jira-sync-bot
Copy link
Collaborator Author

The issue was exported from the internal Jira. The original Jira issue: SITES-7945.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant