klaviyo / magento2-klaviyo

37 stars 51 forks source link

Module events are not being tracked on version 4.1.1 #283

Open jarcorreia opened 5 months ago

jarcorreia commented 5 months ago

Environment details

PHP version: 7.4 Magento version: 2.4.2 Klaviyo extension version: 4.1.1

Steps to reproduce

1 - Login on the storefront as a customer; 2 - Move onto any other page just for sanity's sake; 3 - Open the browser's dev console and run klaviyo.isIdentified().

Expected result

The user should be identified on step 3, with a PromiseResult of true. This allows for actions to be tracked.

Actual result

PromiseResult is always false because it never gets to run klaiviyo.identify() due to how a condition (!klaviyo.isIdentified()) is being resolved to allow that method to run. Actions are never tracked.

Additional information

I'm updating from version 4.0.11 of the module and noticed that object _learnq was no longer used. On the customer.js file of yours, it was now updated to deliver a Promise type of object via the klaviyo.isIdentified() function, which result cannot be resolved by using the operator "!" thus making it so that none of the events handled by the module were being registered and tracked.

I used a .then method to store the result and then I could assess if the user was already identified or if it needed to be identified.

cykolln commented 5 months ago

@jarcorreia Thanks for raising, the fix has been merged and will be included in the next release

jarcorreia commented 5 months ago

Great! Glad to hear. @cykolln