From 37c6850c8d10eb6adf6c8293484f0a7a9e92aa9d Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Mon, 13 Mar 2023 01:45:52 +0530 Subject: [PATCH 1/5] Added product Id in Ordered Product track event of klaviyo --- integrations/klaviyo/lib/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integrations/klaviyo/lib/index.js b/integrations/klaviyo/lib/index.js index 262dd9221..9097097cb 100644 --- a/integrations/klaviyo/lib/index.js +++ b/integrations/klaviyo/lib/index.js @@ -217,7 +217,8 @@ function formatItems(track) { ProductCategories: [product.category()], ProductURL: product.proxy('properties.productUrl'), ImageURL: product.proxy('properties.imageUrl'), - SKU: product.sku() + SKU: product.sku(), + productId: product.productId() }); // ensure unique $event_id is associated with each Ordered Product event by combining Order Completed @@ -266,7 +267,7 @@ function formatProducts(products) { var customProps = filter(product, whitelist); var item = reject({ - id: product.productId() || product.id(), + productId: product.productId() || product.id(), SKU: product.sku(), Name: product.name(), Quantity: product.quantity(), From ac69bc677987e35fff644deb4fee822ffff43685 Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Mon, 20 Mar 2023 13:05:06 +0530 Subject: [PATCH 2/5] Klaviyo unit test cases added --- integrations/klaviyo/test/index.test.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/integrations/klaviyo/test/index.test.js b/integrations/klaviyo/test/index.test.js index 72c21607a..e02a1c0a9 100644 --- a/integrations/klaviyo/test/index.test.js +++ b/integrations/klaviyo/test/index.test.js @@ -230,7 +230,7 @@ describe('Klaviyo', function() { ItemNames: ['Monopoly: 3rd Edition', 'Suh dude'], Items: [ { - id: '507f1f77bcf86cd799439011', + productId: '507f1f77bcf86cd799439011', SKU: '45790-32', Name: 'Monopoly: 3rd Edition', Quantity: 1, @@ -241,7 +241,7 @@ describe('Klaviyo', function() { Categories: ['Games'] }, { - id: '505bd76785ebb509fc183733', + productId: '505bd76785ebb509fc183733', SKU: '46493-32', Name: 'Suh dude', Quantity: 2, @@ -293,7 +293,7 @@ describe('Klaviyo', function() { ItemNames: ['Monopoly: 3rd Edition'], Items: [ { - id: '507f1f77bcf86cd799439011', + productId: '507f1f77bcf86cd799439011', SKU: '45790-32', Name: 'Monopoly: 3rd Edition', Quantity: 1, @@ -322,7 +322,8 @@ describe('Klaviyo', function() { ProductCategories: ['Games'], ProductURL: 'http://www.example.com/path/to/product', ImageURL: 'http://www.example.com/path/to/product/image.png', - SKU: '45790-32' + SKU: '45790-32', + productId: '507f1f77bcf86cd799439011' } ]); }); @@ -452,7 +453,7 @@ describe('Klaviyo', function() { ItemNames: ['Monopoly: 3rd Edition', 'Suh dude'], Items: [ { - id: '507f1f77bcf86cd799439011', + productId: '507f1f77bcf86cd799439011', SKU: '45790-32', Name: 'Monopoly: 3rd Edition', Quantity: 1, @@ -465,7 +466,7 @@ describe('Klaviyo', function() { friday: 'is here' }, { - id: '505bd76785ebb509fc183733', + productId: '505bd76785ebb509fc183733', SKU: '46493-32', Name: 'Suh dude', Quantity: 2, From 250962167562bf3f257bc0b6ac7efdcfcefdf8fd Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Wed, 22 Mar 2023 23:28:24 +0530 Subject: [PATCH 3/5] Change veriable name productId to ProductID as klaviyo description --- integrations/klaviyo/lib/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integrations/klaviyo/lib/index.js b/integrations/klaviyo/lib/index.js index 9097097cb..6bb650dfb 100644 --- a/integrations/klaviyo/lib/index.js +++ b/integrations/klaviyo/lib/index.js @@ -218,7 +218,7 @@ function formatItems(track) { ProductURL: product.proxy('properties.productUrl'), ImageURL: product.proxy('properties.imageUrl'), SKU: product.sku(), - productId: product.productId() + ProductID: product.productId() || product.id() }); // ensure unique $event_id is associated with each Ordered Product event by combining Order Completed @@ -267,7 +267,6 @@ function formatProducts(products) { var customProps = filter(product, whitelist); var item = reject({ - productId: product.productId() || product.id(), SKU: product.sku(), Name: product.name(), Quantity: product.quantity(), From 9867d67030ece14b7a1c996e260443200105f8d6 Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Wed, 22 Mar 2023 23:57:32 +0530 Subject: [PATCH 4/5] HGI-394 Test case added --- integrations/klaviyo/lib/index.js | 1 + integrations/klaviyo/test/index.test.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/integrations/klaviyo/lib/index.js b/integrations/klaviyo/lib/index.js index 6bb650dfb..33b60bb21 100644 --- a/integrations/klaviyo/lib/index.js +++ b/integrations/klaviyo/lib/index.js @@ -267,6 +267,7 @@ function formatProducts(products) { var customProps = filter(product, whitelist); var item = reject({ + id: product.productId() || product.id(), SKU: product.sku(), Name: product.name(), Quantity: product.quantity(), diff --git a/integrations/klaviyo/test/index.test.js b/integrations/klaviyo/test/index.test.js index e02a1c0a9..c51239fcc 100644 --- a/integrations/klaviyo/test/index.test.js +++ b/integrations/klaviyo/test/index.test.js @@ -230,7 +230,7 @@ describe('Klaviyo', function() { ItemNames: ['Monopoly: 3rd Edition', 'Suh dude'], Items: [ { - productId: '507f1f77bcf86cd799439011', + id: '507f1f77bcf86cd799439011', SKU: '45790-32', Name: 'Monopoly: 3rd Edition', Quantity: 1, @@ -241,7 +241,7 @@ describe('Klaviyo', function() { Categories: ['Games'] }, { - productId: '505bd76785ebb509fc183733', + id: '505bd76785ebb509fc183733', SKU: '46493-32', Name: 'Suh dude', Quantity: 2, @@ -293,7 +293,7 @@ describe('Klaviyo', function() { ItemNames: ['Monopoly: 3rd Edition'], Items: [ { - productId: '507f1f77bcf86cd799439011', + id: '507f1f77bcf86cd799439011', SKU: '45790-32', Name: 'Monopoly: 3rd Edition', Quantity: 1, @@ -323,12 +323,12 @@ describe('Klaviyo', function() { ProductURL: 'http://www.example.com/path/to/product', ImageURL: 'http://www.example.com/path/to/product/image.png', SKU: '45790-32', - productId: '507f1f77bcf86cd799439011' + ProductID: '507f1f77bcf86cd799439011' } ]); }); - it('should have the correct $event_id for Ordered Product if id passed as product_id', function() { + it('should have correct $event_id for Ordered Product if id passed as product_id', function() { analytics.track('Completed Order', { order_id: '50314b8e9bcf000000000000', total: 30, @@ -363,7 +363,8 @@ describe('Klaviyo', function() { ProductCategories: ['Games'], ProductURL: 'http://www.example.com/path/to/product', ImageURL: 'http://www.example.com/path/to/product/image.png', - SKU: '45790-32' + SKU: '45790-32', + ProductID: '507f1f77bcf86cd799439011' } ]); }); @@ -453,7 +454,7 @@ describe('Klaviyo', function() { ItemNames: ['Monopoly: 3rd Edition', 'Suh dude'], Items: [ { - productId: '507f1f77bcf86cd799439011', + id: '507f1f77bcf86cd799439011', SKU: '45790-32', Name: 'Monopoly: 3rd Edition', Quantity: 1, @@ -466,7 +467,7 @@ describe('Klaviyo', function() { friday: 'is here' }, { - productId: '505bd76785ebb509fc183733', + id: '505bd76785ebb509fc183733', SKU: '46493-32', Name: 'Suh dude', Quantity: 2, From 051e70e645eb014cd605a840eb0a75b3ef89c6ff Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Thu, 23 Mar 2023 12:39:14 +0530 Subject: [PATCH 5/5] Klaviyo version update --- integrations/klaviyo/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/klaviyo/package.json b/integrations/klaviyo/package.json index 09a3bcbcb..a086b0109 100644 --- a/integrations/klaviyo/package.json +++ b/integrations/klaviyo/package.json @@ -1,7 +1,7 @@ { "name": "@segment/analytics.js-integration-klaviyo", "description": "The Klaviyo analytics.js integration.", - "version": "2.2.4", + "version": "2.2.5", "keywords": [ "analytics.js", "analytics.js-integration",