Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
I've noticed that with certain scripts added to Customer Events - Custom Pixels (in my case an Amazon AWS script), the execution will fail and I will see this error in the console: "In a sandboxed environment, addEventListener may not behave as expected.". It looks like the native addEventListener function has been overridden by a custom Shopify function that displays this error message. I understand that people shouldn't be trying to add event listeners to the DOM in a sandbox environment, but sometimes addEventListener is used for XHR requests and other things related to data transmission. I'd like to request that Shopify update this so that a warning message is displayed without actually breaking the functionality of addEventListener, so that it doesn't disrupt data tracking. Thanks.
Hi SGSdev,
What exact component is the event listener being added to? If it's on a checkout that is using checkout extensibility then `addEventListener` will not work as these functions are intentionally limited to ensure the checkout remains secure.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
I am running into the same issue on mobile when doing this: `window.addEventListener("load", () => {})` in a web component injected by a theme app extension. On desktop everything seems to be working fine though.