klaviyo / magento2-klaviyo

38 stars 51 forks source link

Error - is not a function: require(['domReady!'], function() #238

Open jesperbrejning opened 1 year ago

jesperbrejning commented 1 year ago

Environment details

PHP version: 8.1 Magento version: 2.4.6 Klaviyo extension version: 4.0.10 Anything else that would help a developer reproduce the bug?

Steps to reproduce

After upgrade to Magento version 2.4.6 an error on this function :

require(['domReady!'], function()

Expected result

No errors in Google console

Actual result

Error in Google Console: require(['domReady!'], function()

Additional information

No response

jorgb90 commented 1 year ago

Same here. Updated to Magento 2.4.6 and Klaviyo integration stopped working. Reauthorize is working, but still reporting error after it.

Don't know if the issues are related. @jesperbrejning I think this isn't API related or is it?

Update

I found my problem which can be checked here https://github.com/magento/magento2/issues/37278

jesperbrejning commented 1 year ago

I don't think it's the same error I see, because we don't have special characters in the sku. But we do have special characters in ex. the "Name". Could that cause the error?

script text="text/javascript"> require(['domReady!'], function () { var _learnq = window._learnq || []; _learnq.push(['track', 'Viewed Product', {"ProductID":"97679","Name":"Tryk mig p\u00e5 maven - Dyr p\u00e5 g\u00e5rden fra Boldens Forlag","SKU":"9788772053554","URL":"https:\/\/www.babygear.dk\/tryk-mig-pa-maven-dyr-pa-garden-fra-boldens-forlag.html","Price":"59.00","FinalPrice":"59.00","Categories":["Billedb\u00f8ger","Bestsellers"],"ImageURL":"https:\/\/www.babygear.dk\/media\/catalog\/product\/cache\/44d872830c388882e3e32a2a33f56854\/9\/7\/9788772053554.jpg"}]); _learnq.push(['trackViewedItem', {"Title":"Tryk mig p\u00e5 maven - Dyr p\u00e5 g\u00e5rden fra Boldens Forlag","ItemId":"97679","Url":"https:\/\/www.babygear.dk\/tryk-mig-pa-maven-dyr-pa-garden-fra-boldens-forlag.html","Categories":["Billedb\u00f8ger","Bestsellers"],"Metadata":{"Price":"59.00"},"ImageURL":"https:\/\/www.babygear.dk\/media\/catalog\/product\/cache\/44d872830c388882e3e32a2a33f56854\/9\/7\/9788772053554.jpg"}]); });

cykolln commented 1 year ago

@jesperbrejning Can you please specify the error you are seeing on the console? Special characters should not cause issues in onsite tracking.

jesperbrejning commented 1 year ago

We are seeing this error on all product view pages.

The error in console is the following:

Uncaught ReferenceError: require is not defined at pixi-serie-bondegardens-dyr-med-sebastian-klein.html:8466:3 (anonym) @ pixi-serie-bondegardens-dyr-med-sebastian-klein.html:8466

With reference to this function in the code:

neha023 commented 2 months ago

@jesperbrejning I am facing the same issue whenever I put my website in production mode it is showing different errors in console like -

http://127.0.0.1/magento24/static/frontend/MageTheme/child/en_US/domReady.js 404 (Not Found)
Refused to execute script from 'http://127.0.0.1/magento24/static/frontend/MageTheme/child/en_US/domReady.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Refused to execute script from 'http://127.0.0.1/magento24/static/frontend/MageTheme/child/en_US/jquery-ui-modules/widget.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

 Refused to execute script from 'http://127.0.0.1/magento24/static/frontend/MageTheme/child/en_US/jquery-ui-modules/core.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Refused to execute script from 'http://127.0.0.1/magento24/static/frontend/MageTheme/child/en_US/mageTranslationDictionary.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

require.js:168 Uncaught Error: Script error for "domReady", needed by: domReady!_unnormalized2, domReady!_unnormalized3
https://requirejs.org/docs/errors.html#scripterror
    at makeError (require.js:168:17)
    at HTMLScriptElement.onScriptError (require.js:1738:36)

We have custom theme them and more than 70 extensions, unable to find the cause what happened, the site was initially in 2.4.5-p2 and we upgraded it to 2.4.6-p3 and these issue we are facing from long time