diff --git a/src/v0/destinations/awin/utils.js b/src/v0/destinations/awin/utils.js index a6acc11863..715fb5818d 100644 --- a/src/v0/destinations/awin/utils.js +++ b/src/v0/destinations/awin/utils.js @@ -81,11 +81,15 @@ const trackProduct = (properties, advertiserId, commissionParts) => { // ref: https://wiki.awin.com/index.php/Advertiser_Tracking_Guide/Product_Level_Tracking#PLT_Via_Conversion_Pixel const populateCustomTransactionProperties = (properties, customFieldMap) => { const customObject = {}; + const customPropertyPattern = '^\\s*p\\d+\\s*$'; + const regex = new RegExp(customPropertyPattern, 'i'); const propertyMap = getHashFromArray(customFieldMap, 'from', 'to', false); Object.entries(propertyMap).forEach(([rudderProperty, awinProperty]) => { - const fieldValue = properties[rudderProperty]; - if (fieldValue) { - customObject[awinProperty] = fieldValue; + if (regex.test(awinProperty)) { + const fieldValue = properties[rudderProperty]; + if (fieldValue) { + customObject[awinProperty] = fieldValue; + } } }); return customObject; diff --git a/src/v0/destinations/awin/utils.test.js b/src/v0/destinations/awin/utils.test.js index 3802612e9a..ca7d079b1b 100644 --- a/src/v0/destinations/awin/utils.test.js +++ b/src/v0/destinations/awin/utils.test.js @@ -175,14 +175,16 @@ describe('populateCustomTransactionProperties', () => { rudderProperty1: 'value1', rudderProperty2: 123, rudderProperty3: 'value3', + rudderProperty4: 234, }; const customFieldMap = [ - { from: 'rudderProperty1', to: 'awinProperty1' }, - { from: 'rudderProperty2', to: 'awinProperty2' }, + { from: 'rudderProperty1', to: 'p1' }, + { from: 'rudderProperty2', to: 'p2' }, + { from: 'rudderProperty4', to: 'anotherp2' }, ]; const expectedOutput = { - awinProperty1: 'value1', - awinProperty2: 123, + p1: 'value1', + p2: 123, }; const result = populateCustomTransactionProperties(properties, customFieldMap);