klaviyo / magento2-klaviyo

37 stars 51 forks source link

Bug with V3 Klaviyo API updating customer #290

Closed JamesFX2 closed 3 weeks ago

JamesFX2 commented 4 months ago

Environment details

PHP version: 8.1 Magento version: 2.4.4-p6 Klaviyo extension version: 4.1.1 Anything else that would help a developer reproduce the bug?

See https://github.com/klaviyo/magento2-klaviyo/pull/289

We use the Klaviyo extension to push customer data to enrich the customer's profile in Klaviyo and help us build segments. The functions used by your extension are not formatting the data correctly so custom fields are not being updated in Klaviyo.

Steps to reproduce

We push data to the klaviyoTrackEvent function and it comes out like this.

   {"data":{"type":"event","attributes":{"properties":{"$value":null},"time":"2024-02-06T13:46:34","value":null,"metric":{"data":{"type":"metric","attributes":{"name":"Customer Sync","service":"magentotwo"}}},"profile":{"data":{"type":"profile","attributes":{"email":"bcedd554123b00cff993@redacted.com","first_name":"Leila","last_name":"Test"},"properties":{"$first_name":"Leila","$last_name":"Test","email":"bcedd554123b00cff993@redacted.com","$nhs_last_date":"2024-02-06","nhs_last_date":"2024-02-06"}}}}}}

This is incorrect, the custom properties should be within the attributes object, which is inside the data object, which is inside the profile object.

Expected result

See formatting on https://jsonformatter.org/fa628e

Actual result

See above. Contact is no longer updated.

Additional information

No response

smoucka commented 4 months ago

Thanks for submitting this issue and a PR to fix @JamesFX2 . We'll get this incorporated into the next release.

cykolln commented 3 weeks ago

This has been fixed in 4.1.4