diff --git a/src/v1/sources/shopify/pixelTransform.js b/src/v1/sources/shopify/pixelTransform.js index 0ca64b4123..a19d431757 100644 --- a/src/v1/sources/shopify/pixelTransform.js +++ b/src/v1/sources/shopify/pixelTransform.js @@ -23,7 +23,11 @@ const NO_OPERATION_SUCCESS = { function processPixelEvent(inputEvent) { // eslint-disable-next-line @typescript-eslint/naming-convention - const { name, query_parameters, clientId, data } = inputEvent; + const { name, query_parameters, clientId, data, id } = inputEvent; + const shopifyDetails = { ...inputEvent }; + delete shopifyDetails.context; + delete shopifyDetails.query_parameters; + delete shopifyDetails.pixelEventLabel; const { checkout } = data ?? {}; const { order } = checkout ?? {}; const { customer } = order ?? {}; @@ -77,6 +81,8 @@ function processPixelEvent(inputEvent) { version: '2.0.0', }); message.setProperty('context.topic', name); + message.setProperty('context.shopifyDetails', shopifyDetails); + message.messageId = id; message = removeUndefinedAndNullValues(message); return message; } diff --git a/src/v1/sources/shopify/pixelUtils.js b/src/v1/sources/shopify/pixelUtils.js index 92197a558b..4c39e80549 100644 --- a/src/v1/sources/shopify/pixelUtils.js +++ b/src/v1/sources/shopify/pixelUtils.js @@ -138,7 +138,7 @@ const checkoutEventBuilder = (inputEvent) => { const properties = { products, - order_id: inputEvent.id, + order_id: inputEvent.data?.checkout?.order?.id, checkout_id: inputEvent?.data?.checkout?.token, total: inputEvent?.data?.checkout?.totalPrice?.amount, currency: inputEvent?.data?.checkout?.currencyCode, diff --git a/src/v1/sources/shopify/pixelUtils.test.js b/src/v1/sources/shopify/pixelUtils.test.js index cd544568cd..ed64862228 100644 --- a/src/v1/sources/shopify/pixelUtils.test.js +++ b/src/v1/sources/shopify/pixelUtils.test.js @@ -171,6 +171,9 @@ describe('utilV2.js', () => { { id: 'product123', name: 'Product 123' }, { id: 'product456', name: 'Product 456' }, ], + order: { + id: 'order123', + }, token: 'checkout123', totalPrice: { amount: 200 }, currencyCode: 'USD', diff --git a/test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts b/test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts index 1009fa2d04..3381223317 100644 --- a/test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts +++ b/test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts @@ -207,6 +207,132 @@ export const pixelCheckoutEventsTestScenarios = [ version: '2.0.0', }, topic: 'checkout_started', + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + checkout: { + attributes: [], + billingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + buyerAcceptsEmailMarketing: false, + buyerAcceptsSmsMarketing: false, + currencyCode: 'USD', + delivery: { + selectedDeliveryOptions: [], + }, + discountApplications: [], + discountsAmount: { + amount: 0, + currencyCode: 'USD', + }, + email: '', + lineItems: [ + { + discountAllocations: [], + finalLinePrice: { + amount: 1499.9, + currencyCode: 'USD', + }, + id: '41327143321713', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Collection Snowboard: Liquid', + variant: { + id: '41327143321713', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6_64x64.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid', + vendor: 'Hydrogen Vendor', + }, + sku: null, + title: null, + untranslatedTitle: null, + }, + }, + ], + localization: { + country: { + isoCode: 'US', + }, + language: { + isoCode: 'en-US', + }, + market: { + handle: 'us', + id: 'gid://shopify/Market/23505895537', + }, + }, + order: { + customer: { + id: null, + isFirstOrder: null, + }, + id: null, + }, + phone: '', + shippingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + shippingLine: { + price: { + amount: 0, + currencyCode: 'USD', + }, + }, + smsMarketingPhone: null, + subtotalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + token: '5f7028e0bd5225c17b24bdaa0c09f914', + totalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + totalTax: { + amount: 0, + currencyCode: 'USD', + }, + transactions: [], + }, + }, + id: 'sh-f77a78f1-C1D8-4ED4-9C9B-0D352CF6F3BF', + name: 'checkout_started', + timestamp: '2024-09-15T20:57:59.674Z', + type: 'standard', + }, }, integrations: { SHOPIFY: true, @@ -238,7 +364,7 @@ export const pixelCheckoutEventsTestScenarios = [ brand: 'Hydrogen Vendor', }, ], - order_id: 'sh-f77a78f1-C1D8-4ED4-9C9B-0D352CF6F3BF', + order_id: null, checkout_id: '5f7028e0bd5225c17b24bdaa0c09f914', total: 2759.8, currency: 'USD', @@ -249,6 +375,7 @@ export const pixelCheckoutEventsTestScenarios = [ tax: 0, }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f77a78f1-C1D8-4ED4-9C9B-0D352CF6F3BF', }, ], }, @@ -495,6 +622,165 @@ export const pixelCheckoutEventsTestScenarios = [ version: '2.0.0', }, topic: 'checkout_completed', + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + checkout: { + attributes: [], + billingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + buyerAcceptsEmailMarketing: false, + buyerAcceptsSmsMarketing: false, + currencyCode: 'USD', + delivery: { + selectedDeliveryOptions: [], + }, + discountApplications: [], + discountsAmount: { + amount: 0, + currencyCode: 'USD', + }, + email: '', + lineItems: [ + { + discountAllocations: [], + finalLinePrice: { + amount: 1499.9, + currencyCode: 'USD', + }, + id: '41327143321713', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Collection Snowboard: Liquid', + variant: { + id: '41327143321713', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6_64x64.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid', + vendor: 'Hydrogen Vendor', + }, + sku: null, + title: null, + untranslatedTitle: null, + }, + }, + { + discountAllocations: [], + finalLinePrice: { + amount: 1259.9, + currencyCode: 'USD', + }, + id: '41327143157873', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Multi-managed Snowboard', + variant: { + id: '41327143157873', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_9129b69a-0c7b-4f66-b6cf-c4222f18028a_64x64.jpg?v=1724736597', + }, + price: { + amount: 629.95, + currencyCode: 'USD', + }, + product: { + id: '7234590736497', + title: 'The Multi-managed Snowboard', + type: 'snowboard', + untranslatedTitle: 'The Multi-managed Snowboard', + url: '/products/the-multi-managed-snowboard', + vendor: 'Multi-managed Vendor', + }, + sku: 'sku-managed-1', + title: null, + untranslatedTitle: null, + }, + }, + ], + localization: { + country: { + isoCode: 'US', + }, + language: { + isoCode: 'en-US', + }, + market: { + handle: 'us', + id: 'gid://shopify/Market/23505895537', + }, + }, + order: { + customer: { + id: null, + isFirstOrder: null, + }, + id: null, + }, + phone: '', + shippingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + shippingLine: { + price: { + amount: 0, + currencyCode: 'USD', + }, + }, + smsMarketingPhone: null, + subtotalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + token: '5f7028e0bd5225c17b24bdaa0c09f914', + totalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + totalTax: { + amount: 0, + currencyCode: 'USD', + }, + transactions: [], + }, + }, + id: 'sh-f77a78f1-C1D8-4ED4-9C9B-0D352CF6F3BF', + name: 'checkout_completed', + timestamp: '2024-09-15T20:57:59.674Z', + type: 'standard', + }, }, integrations: { SHOPIFY: true, @@ -548,7 +834,7 @@ export const pixelCheckoutEventsTestScenarios = [ brand: 'Multi-managed Vendor', }, ], - order_id: 'sh-f77a78f1-C1D8-4ED4-9C9B-0D352CF6F3BF', + order_id: null, checkout_id: '5f7028e0bd5225c17b24bdaa0c09f914', total: 2759.8, currency: 'USD', @@ -559,6 +845,7 @@ export const pixelCheckoutEventsTestScenarios = [ tax: 0, }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f77a78f1-C1D8-4ED4-9C9B-0D352CF6F3BF', }, ], }, diff --git a/test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts b/test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts index 9d845c1dde..38f682ac6d 100644 --- a/test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts +++ b/test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts @@ -206,7 +206,185 @@ export const pixelCheckoutStepsScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'checkout_address_info_submitted' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + checkout: { + attributes: [], + billingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + buyerAcceptsEmailMarketing: false, + buyerAcceptsSmsMarketing: false, + currencyCode: 'USD', + delivery: { + selectedDeliveryOptions: [ + { + cost: { + amount: 0, + currencyCode: 'USD', + }, + costAfterDiscounts: { + amount: 0, + currencyCode: 'USD', + }, + description: null, + handle: + '5f7028e0bd5225c17b24bdaa0c09f914-8388085074acab7e91de633521be86f0', + title: 'Economy', + type: 'shipping', + }, + ], + }, + discountApplications: [], + discountsAmount: { + amount: 0, + currencyCode: 'USD', + }, + email: 'test-user@sampleemail.com', + lineItems: [ + { + discountAllocations: [], + finalLinePrice: { + amount: 1499.9, + currencyCode: 'USD', + }, + id: '41327143321713', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Collection Snowboard: Liquid', + variant: { + id: '41327143321713', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6_64x64.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid', + vendor: 'Hydrogen Vendor', + }, + sku: null, + title: null, + untranslatedTitle: null, + }, + }, + { + discountAllocations: [], + finalLinePrice: { + amount: 1259.9, + currencyCode: 'USD', + }, + id: '41327143157873', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Multi-managed Snowboard', + variant: { + id: '41327143157873', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_9129b69a-0c7b-4f66-b6cf-c4222f18028a_64x64.jpg?v=1724736597', + }, + price: { + amount: 629.95, + currencyCode: 'USD', + }, + product: { + id: '7234590736497', + title: 'The Multi-managed Snowboard', + type: 'snowboard', + untranslatedTitle: 'The Multi-managed Snowboard', + url: '/products/the-multi-managed-snowboard', + vendor: 'Multi-managed Vendor', + }, + sku: 'sku-managed-1', + title: null, + untranslatedTitle: null, + }, + }, + ], + localization: { + country: { + isoCode: 'US', + }, + language: { + isoCode: 'en-US', + }, + market: { + handle: 'us', + id: 'gid://shopify/Market/23505895537', + }, + }, + order: { + customer: { + id: null, + isFirstOrder: null, + }, + id: null, + }, + phone: '', + shippingAddress: { + address1: 'Queens Center', + address2: null, + city: 'Elmhurst', + country: 'US', + countryCode: 'US', + firstName: 'test', + lastName: 'user', + phone: null, + province: 'NY', + provinceCode: 'NY', + zip: '11373', + }, + shippingLine: { + price: { + amount: 0, + currencyCode: 'USD', + }, + }, + smsMarketingPhone: null, + subtotalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + token: '5f7028e0bd5225c17b24bdaa0c09f914', + totalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + totalTax: { + amount: 0, + currencyCode: 'USD', + }, + transactions: [], + }, + }, + id: 'sh-f7d2154d-7525-47A4-87FA-E54D2322E129', + name: 'checkout_address_info_submitted', + timestamp: '2024-09-15T21:45:50.523Z', + type: 'standard', + }, + topic: 'checkout_address_info_submitted', + }, integrations: { SHOPIFY: true, }, @@ -379,6 +557,7 @@ export const pixelCheckoutStepsScenarios = [ transactions: [], }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f7d2154d-7525-47A4-87FA-E54D2322E129', }, ], }, @@ -577,7 +756,169 @@ export const pixelCheckoutStepsScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'checkout_contact_info_submitted' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + checkout: { + attributes: [], + billingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + buyerAcceptsEmailMarketing: false, + buyerAcceptsSmsMarketing: false, + currencyCode: 'USD', + delivery: { + selectedDeliveryOptions: [], + }, + discountApplications: [], + discountsAmount: { + amount: 0, + currencyCode: 'USD', + }, + email: 'test-user@sampleemail.com', + lineItems: [ + { + discountAllocations: [], + finalLinePrice: { + amount: 1499.9, + currencyCode: 'USD', + }, + id: '41327143321713', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Collection Snowboard: Liquid', + variant: { + id: '41327143321713', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6_64x64.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid', + vendor: 'Hydrogen Vendor', + }, + sku: null, + title: null, + untranslatedTitle: null, + }, + }, + { + discountAllocations: [], + finalLinePrice: { + amount: 1259.9, + currencyCode: 'USD', + }, + id: '41327143157873', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Multi-managed Snowboard', + variant: { + id: '41327143157873', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_9129b69a-0c7b-4f66-b6cf-c4222f18028a_64x64.jpg?v=1724736597', + }, + price: { + amount: 629.95, + currencyCode: 'USD', + }, + product: { + id: '7234590736497', + title: 'The Multi-managed Snowboard', + type: 'snowboard', + untranslatedTitle: 'The Multi-managed Snowboard', + url: '/products/the-multi-managed-snowboard', + vendor: 'Multi-managed Vendor', + }, + sku: 'sku-managed-1', + title: null, + untranslatedTitle: null, + }, + }, + ], + localization: { + country: { + isoCode: 'US', + }, + language: { + isoCode: 'en-US', + }, + market: { + handle: 'us', + id: 'gid://shopify/Market/23505895537', + }, + }, + order: { + customer: { + id: null, + isFirstOrder: null, + }, + id: null, + }, + phone: '', + shippingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + shippingLine: { + price: { + amount: 0, + currencyCode: 'USD', + }, + }, + smsMarketingPhone: null, + subtotalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + token: '5f7028e0bd5225c17b24bdaa0c09f914', + totalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + totalTax: { + amount: 0, + currencyCode: 'USD', + }, + transactions: [], + }, + }, + id: 'sh-f7c8416f-1D35-4304-EF29-78666678C4E9', + name: 'checkout_contact_info_submitted', + timestamp: '2024-09-15T21:40:28.498Z', + type: 'standard', + }, + topic: 'checkout_contact_info_submitted', + }, integrations: { SHOPIFY: true, }, @@ -734,6 +1075,7 @@ export const pixelCheckoutStepsScenarios = [ transactions: [], }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f7c8416f-1D35-4304-EF29-78666678C4E9', }, ], }, @@ -947,7 +1289,185 @@ export const pixelCheckoutStepsScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'checkout_shipping_info_submitted' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + checkout: { + attributes: [], + billingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + buyerAcceptsEmailMarketing: false, + buyerAcceptsSmsMarketing: false, + currencyCode: 'USD', + delivery: { + selectedDeliveryOptions: [ + { + cost: { + amount: 0, + currencyCode: 'USD', + }, + costAfterDiscounts: { + amount: 0, + currencyCode: 'USD', + }, + description: null, + handle: + '5f7028e0bd5225c17b24bdaa0c09f914-8388085074acab7e91de633521be86f0', + title: 'Economy', + type: 'shipping', + }, + ], + }, + discountApplications: [], + discountsAmount: { + amount: 0, + currencyCode: 'USD', + }, + email: 'test-user@sampleemail.com', + lineItems: [ + { + discountAllocations: [], + finalLinePrice: { + amount: 1499.9, + currencyCode: 'USD', + }, + id: '41327143321713', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Collection Snowboard: Liquid', + variant: { + id: '41327143321713', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6_64x64.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid', + vendor: 'Hydrogen Vendor', + }, + sku: null, + title: null, + untranslatedTitle: null, + }, + }, + { + discountAllocations: [], + finalLinePrice: { + amount: 1259.9, + currencyCode: 'USD', + }, + id: '41327143157873', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Multi-managed Snowboard', + variant: { + id: '41327143157873', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_9129b69a-0c7b-4f66-b6cf-c4222f18028a_64x64.jpg?v=1724736597', + }, + price: { + amount: 629.95, + currencyCode: 'USD', + }, + product: { + id: '7234590736497', + title: 'The Multi-managed Snowboard', + type: 'snowboard', + untranslatedTitle: 'The Multi-managed Snowboard', + url: '/products/the-multi-managed-snowboard', + vendor: 'Multi-managed Vendor', + }, + sku: 'sku-managed-1', + title: null, + untranslatedTitle: null, + }, + }, + ], + localization: { + country: { + isoCode: 'US', + }, + language: { + isoCode: 'en-US', + }, + market: { + handle: 'us', + id: 'gid://shopify/Market/23505895537', + }, + }, + order: { + customer: { + id: null, + isFirstOrder: null, + }, + id: null, + }, + phone: '', + shippingAddress: { + address1: 'Queens Center', + address2: null, + city: 'Elmhurst', + country: 'US', + countryCode: 'US', + firstName: 'test', + lastName: 'user', + phone: null, + province: 'NY', + provinceCode: 'NY', + zip: '11373', + }, + shippingLine: { + price: { + amount: 0, + currencyCode: 'USD', + }, + }, + smsMarketingPhone: null, + subtotalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + token: '5f7028e0bd5225c17b24bdaa0c09f914', + totalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + totalTax: { + amount: 0, + currencyCode: 'USD', + }, + transactions: [], + }, + }, + id: 'sh-f7d5618e-404A-4E6D-4662-599A4BCC9E7C', + name: 'checkout_shipping_info_submitted', + timestamp: '2024-09-15T21:47:38.576Z', + type: 'standard', + }, + topic: 'checkout_shipping_info_submitted', + }, integrations: { SHOPIFY: true, }, @@ -1120,6 +1640,7 @@ export const pixelCheckoutStepsScenarios = [ transactions: [], }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f7d5618e-404A-4E6D-4662-599A4BCC9E7C', }, ], }, @@ -1333,7 +1854,185 @@ export const pixelCheckoutStepsScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'payment_info_submitted' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + checkout: { + attributes: [], + billingAddress: { + address1: null, + address2: null, + city: null, + country: 'US', + countryCode: 'US', + firstName: null, + lastName: null, + phone: null, + province: null, + provinceCode: null, + zip: null, + }, + buyerAcceptsEmailMarketing: false, + buyerAcceptsSmsMarketing: false, + currencyCode: 'USD', + delivery: { + selectedDeliveryOptions: [ + { + cost: { + amount: 0, + currencyCode: 'USD', + }, + costAfterDiscounts: { + amount: 0, + currencyCode: 'USD', + }, + description: null, + handle: + '5f7028e0bd5225c17b24bdaa0c09f914-8388085074acab7e91de633521be86f0', + title: 'Economy', + type: 'shipping', + }, + ], + }, + discountApplications: [], + discountsAmount: { + amount: 0, + currencyCode: 'USD', + }, + email: 'test-user@sampleemail.com', + lineItems: [ + { + discountAllocations: [], + finalLinePrice: { + amount: 1499.9, + currencyCode: 'USD', + }, + id: '41327143321713', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Collection Snowboard: Liquid', + variant: { + id: '41327143321713', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6_64x64.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid', + vendor: 'Hydrogen Vendor', + }, + sku: null, + title: null, + untranslatedTitle: null, + }, + }, + { + discountAllocations: [], + finalLinePrice: { + amount: 1259.9, + currencyCode: 'USD', + }, + id: '41327143157873', + properties: [], + quantity: 2, + sellingPlanAllocation: null, + title: 'The Multi-managed Snowboard', + variant: { + id: '41327143157873', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_9129b69a-0c7b-4f66-b6cf-c4222f18028a_64x64.jpg?v=1724736597', + }, + price: { + amount: 629.95, + currencyCode: 'USD', + }, + product: { + id: '7234590736497', + title: 'The Multi-managed Snowboard', + type: 'snowboard', + untranslatedTitle: 'The Multi-managed Snowboard', + url: '/products/the-multi-managed-snowboard', + vendor: 'Multi-managed Vendor', + }, + sku: 'sku-managed-1', + title: null, + untranslatedTitle: null, + }, + }, + ], + localization: { + country: { + isoCode: 'US', + }, + language: { + isoCode: 'en-US', + }, + market: { + handle: 'us', + id: 'gid://shopify/Market/23505895537', + }, + }, + order: { + customer: { + id: null, + isFirstOrder: null, + }, + id: null, + }, + phone: '', + shippingAddress: { + address1: 'Queens Center', + address2: null, + city: 'Elmhurst', + country: 'US', + countryCode: 'US', + firstName: 'test', + lastName: 'user', + phone: null, + province: 'NY', + provinceCode: 'NY', + zip: '11373', + }, + shippingLine: { + price: { + amount: 0, + currencyCode: 'USD', + }, + }, + smsMarketingPhone: null, + subtotalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + token: '5f7028e0bd5225c17b24bdaa0c09f914', + totalPrice: { + amount: 2759.8, + currencyCode: 'USD', + }, + totalTax: { + amount: 0, + currencyCode: 'USD', + }, + transactions: [], + }, + }, + id: 'sh-f7d843ea-ED11-4A12-F32F-C5A45BED0413', + name: 'payment_info_submitted', + timestamp: '2024-09-15T21:49:13.092Z', + type: 'standard', + }, + topic: 'payment_info_submitted', + }, integrations: { SHOPIFY: true, }, @@ -1506,6 +2205,7 @@ export const pixelCheckoutStepsScenarios = [ transactions: [], }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f7d843ea-ED11-4A12-F32F-C5A45BED0413', }, ], }, diff --git a/test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts b/test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts index 0b8f8c3c1a..b293bd46f9 100644 --- a/test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts +++ b/test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts @@ -41,7 +41,18 @@ export const pixelEventsTestScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'page_viewed' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: {}, + id: 'sh-f6b6f548-5FEF-4DAE-9CAB-39EE6F94E09B', + name: 'page_viewed', + timestamp: '2024-09-15T17:24:30.373Z', + type: 'standard', + }, + topic: 'page_viewed', + }, integrations: { SHOPIFY: true, }, @@ -49,6 +60,7 @@ export const pixelEventsTestScenarios = [ type: 'page', properties: {}, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f6b6f548-5FEF-4DAE-9CAB-39EE6F94E09B', }, ], }, @@ -118,7 +130,40 @@ export const pixelEventsTestScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'product_viewed' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + productVariant: { + id: '41327143321713', + image: { + src: '//store.myshopify.com/cdn/shop/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid', + vendor: 'Hydrogen Vendor', + }, + sku: '', + title: 'Default Title', + untranslatedTitle: 'Default Title', + }, + }, + id: 'sh-f6c07b5a-D20A-4E5F-812E-337299B56C34', + name: 'product_viewed', + timestamp: '2024-09-15T17:34:54.889Z', + type: 'standard', + }, + topic: 'product_viewed', + }, integrations: { SHOPIFY: true, }, @@ -156,6 +201,7 @@ export const pixelEventsTestScenarios = [ name: 'The Collection Snowboard: Liquid', }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f6c07b5a-D20A-4E5F-812E-337299B56C34', }, ], }, @@ -247,7 +293,62 @@ export const pixelEventsTestScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'cart_viewed' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + cart: { + attributes: [], + cost: { + totalAmount: { + amount: 1259.9, + currencyCode: 'USD', + }, + }, + id: 'Z2NwLXVzLWVhc3QxOjAxSjY5OVpIRURQNERFMDBKUTVaRkI4UzdU', + lines: [ + { + cost: { + totalAmount: { + amount: 1259.9, + currencyCode: 'USD', + }, + }, + merchandise: { + id: '41327143157873', + image: { + src: '//store.myshopify.com/cdn/shop/files/Main_9129b69a-0c7b-4f66-b6cf-c4222f18028a.jpg?v=1724736597', + }, + price: { + amount: 629.95, + currencyCode: 'USD', + }, + product: { + id: '7234590736497', + title: 'The Multi-managed Snowboard', + type: 'snowboard', + untranslatedTitle: 'The Multi-managed Snowboard', + url: '/products/the-multi-managed-snowboard', + vendor: 'Multi-managed Vendor', + }, + sku: 'sku-managed-1', + title: 'Default Title', + untranslatedTitle: 'Default Title', + }, + quantity: 2, + }, + ], + totalQuantity: 2, + }, + }, + id: 'shu-f6eecef1-4132-459F-CDB5-681DA3DD61CD', + name: 'cart_viewed', + timestamp: '2024-09-15T18:25:30.125Z', + type: 'standard', + }, + topic: 'cart_viewed', + }, integrations: { SHOPIFY: true, }, @@ -300,6 +401,7 @@ export const pixelEventsTestScenarios = [ total: 1259.9, }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'shu-f6eecef1-4132-459F-CDB5-681DA3DD61CD', }, ], }, @@ -417,7 +519,88 @@ export const pixelEventsTestScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'collection_viewed' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + collection: { + id: '', + productVariants: [ + { + id: '41327142895729', + image: { + src: '//store.myshopify.com/cdn/shop/files/gift_card.png?v=1724736596', + }, + price: { + amount: 10, + currencyCode: 'USD', + }, + product: { + id: '7234590605425', + title: 'Gift Card', + type: 'giftcard', + untranslatedTitle: 'Gift Card', + url: '/products/gift-card', + vendor: 'Snowboard Vendor', + }, + sku: '', + title: '$10', + untranslatedTitle: '$10', + }, + { + id: '41327143223409', + image: { + src: '//store.myshopify.com/cdn/shop/files/snowboard_wax.png?v=1724736599', + }, + price: { + amount: 24.95, + currencyCode: 'USD', + }, + product: { + id: '7234590802033', + title: 'Selling Plans Ski Wax', + type: 'accessories', + untranslatedTitle: 'Selling Plans Ski Wax', + url: '/products/selling-plans-ski-wax', + vendor: 'pixel-testing-rs', + }, + sku: '', + title: 'Selling Plans Ski Wax', + untranslatedTitle: 'Selling Plans Ski Wax', + }, + { + id: '41327143125105', + image: { + src: '//store.myshopify.com/cdn/shop/files/Main_b9e0da7f-db89-4d41-83f0-7f417b02831d.jpg?v=1724736597', + }, + price: { + amount: 2629.95, + currencyCode: 'USD', + }, + product: { + id: '7234590703729', + title: 'The 3p Fulfilled Snowboard', + type: 'snowboard', + untranslatedTitle: 'The 3p Fulfilled Snowboard', + url: '/products/the-3p-fulfilled-snowboard', + vendor: 'pixel-testing-rs', + }, + sku: 'sku-hosted-1', + title: 'Default Title', + untranslatedTitle: 'Default Title', + }, + ], + title: 'Products', + }, + }, + id: 'sh-f6f0c6be-43F8-47D2-5F94-C22AD5ED3E79', + name: 'collection_viewed', + timestamp: '2024-09-15T18:27:39.197Z', + type: 'standard', + }, + topic: 'collection_viewed', + }, integrations: { SHOPIFY: true, }, @@ -508,6 +691,7 @@ export const pixelEventsTestScenarios = [ ], }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f6f0c6be-43F8-47D2-5F94-C22AD5ED3E79', }, ], }, @@ -586,7 +770,49 @@ export const pixelEventsTestScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'product_added_to_cart' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + cartLine: { + cost: { + totalAmount: { + amount: 749.95, + currencyCode: 'USD', + }, + }, + merchandise: { + id: '41327143321713', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid?variant=41327143321713', + vendor: 'Hydrogen Vendor', + }, + sku: '', + title: null, + untranslatedTitle: null, + }, + quantity: 1, + }, + }, + id: 'sh-f6f828db-F77B-43E8-96C4-1D51DACD52A3', + name: 'product_added_to_cart', + timestamp: '2024-09-15T18:34:42.625Z', + type: 'standard', + }, + topic: 'product_added_to_cart', + }, integrations: { SHOPIFY: true, }, @@ -636,6 +862,7 @@ export const pixelEventsTestScenarios = [ quantity: 1, }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f6f828db-F77B-43E8-96C4-1D51DACD52A3', }, ], }, @@ -714,7 +941,49 @@ export const pixelEventsTestScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'product_removed_from_cart' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + cartLine: { + cost: { + totalAmount: { + amount: 749.95, + currencyCode: 'USD', + }, + }, + merchandise: { + id: '41327143321713', + image: { + src: 'https://cdn.shopify.com/s/files/1/0590/2696/4593/files/Main_b13ad453-477c-4ed1-9b43-81f3345adfd6.jpg?v=1724736600', + }, + price: { + amount: 749.95, + currencyCode: 'USD', + }, + product: { + id: '7234590834801', + title: 'The Collection Snowboard: Liquid', + type: 'snowboard', + untranslatedTitle: 'The Collection Snowboard: Liquid', + url: '/products/the-collection-snowboard-liquid?variant=41327143321713', + vendor: 'Hydrogen Vendor', + }, + sku: '', + title: null, + untranslatedTitle: null, + }, + quantity: 1, + }, + }, + id: 'shu-f778d1eb-9B83-4832-9DC0-5C3B33A809F0', + name: 'product_removed_from_cart', + timestamp: '2024-09-15T20:56:00.125Z', + type: 'standard', + }, + topic: 'product_removed_from_cart', + }, integrations: { SHOPIFY: true, }, @@ -764,6 +1033,7 @@ export const pixelEventsTestScenarios = [ quantity: 1, }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'shu-f778d1eb-9B83-4832-9DC0-5C3B33A809F0', }, ], }, @@ -816,7 +1086,23 @@ export const pixelEventsTestScenarios = [ output: { batch: [ { - context: { ...responseDummyContext, topic: 'search_submitted' }, + context: { + ...responseDummyContext, + shopifyDetails: { + clientId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + data: { + searchResult: { + productVariants: [], + query: 'skate', + }, + }, + id: 'sh-f7d599b4-D80F-4D05-C4CE-B980D5444596', + name: 'search_submitted', + timestamp: '2024-09-15T22:37:35.869Z', + type: 'standard', + }, + topic: 'search_submitted', + }, integrations: { SHOPIFY: true, }, @@ -826,6 +1112,7 @@ export const pixelEventsTestScenarios = [ query: 'skate', }, anonymousId: 'c7b3f99b-4d34-463b-835f-c879482a7750', + messageId: 'sh-f7d599b4-D80F-4D05-C4CE-B980D5444596', }, ], },