diff --git a/src/cdk/v2/destinations/the_trade_desk/utils.js b/src/cdk/v2/destinations/the_trade_desk/utils.js index 64c5f2b78a..f51d8dc3ff 100644 --- a/src/cdk/v2/destinations/the_trade_desk/utils.js +++ b/src/cdk/v2/destinations/the_trade_desk/utils.js @@ -115,8 +115,10 @@ const prepareItemsPayload = (message) => { let items; const eventMapInfo = ECOMM_EVENT_MAP[event.toLowerCase()]; if (eventMapInfo?.itemsArray) { + // if event is one of the supported ecommerce events and products array is present items = prepareItemsFromProducts(message); } else if (eventMapInfo) { + // if event is one of the supported ecommerce events and products array is not present items = prepareItemsFromProperties(message); } return items; @@ -304,14 +306,17 @@ const enrichTrackPayload = (message, payload) => { if (eventsMapInfo && !eventsMapInfo.itemsArray) { const itemExclusionList = generateExclusionList(ITEM_CONFIGS); rawPayload = extractCustomFields(message, rawPayload, ['properties'], itemExclusionList); - } else { - // for custom events + } else if (eventsMapInfo) { + // for ecomm events with products array supports. e.g Order Completed event rawPayload = extractCustomFields( message, rawPayload, ['properties'], ['products', 'revenue', 'value'], ); + } else { + // for custom events + rawPayload = extractCustomFields(message, rawPayload, ['properties'], ['value']); } return rawPayload; }; diff --git a/src/cdk/v2/destinations/the_trade_desk/utils.test.js b/src/cdk/v2/destinations/the_trade_desk/utils.test.js index b489309956..029c3004ae 100644 --- a/src/cdk/v2/destinations/the_trade_desk/utils.test.js +++ b/src/cdk/v2/destinations/the_trade_desk/utils.test.js @@ -635,25 +635,35 @@ describe('enrichTrackPayload', () => { order_id: 'ord123', property1: 'value1', property2: 'value2', + revenue: 10, + value: 11, + products: [ + { + product_id: 'prd123', + test: 'test', + }, + ], }, }; const payload = { order_id: 'ord123', + value: 11, }; - let expectedPayload = { + const expectedPayload = { order_id: 'ord123', property1: 'value1', property2: 'value2', + revenue: 10, + value: 11, + products: [ + { + product_id: 'prd123', + test: 'test', + }, + ], }; - let result = enrichTrackPayload(message, payload); + const result = enrichTrackPayload(message, payload); expect(result).toEqual(expectedPayload); - - expectedPayload = { - order_id: 'ord123', - property1: 'value1', - property2: 'value2', - }; - expect(enrichTrackPayload(message, {})).toEqual(expectedPayload); }); }); diff --git a/test/integrations/destinations/the_trade_desk/router/data.ts b/test/integrations/destinations/the_trade_desk/router/data.ts index 6f379195fa..691ec703b9 100644 --- a/test/integrations/destinations/the_trade_desk/router/data.ts +++ b/test/integrations/destinations/the_trade_desk/router/data.ts @@ -1681,9 +1681,16 @@ export const data = [ properties: { key1: 'value1', value: 25, + revenue: 10, product_id: 'prd123', key2: true, test: 'test123', + products: [ + { + product_id: 'prd123', + test: 'test', + }, + ], }, }, destination: sampleDestination, @@ -1779,6 +1786,13 @@ export const data = [ test: 'test123', key1: 'value1', key2: true, + revenue: 10, + products: [ + { + product_id: 'prd123', + test: 'test', + }, + ], }, ], },