klaviyo / magento2-klaviyo

37 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: