From 0f1ebba73bbe760ae4d9d66f9f46fffb96ca27fc Mon Sep 17 00:00:00 2001 From: Sudip Paul <67197965+ItsSudip@users.noreply.github.com> Date: Fri, 30 Jun 2023 11:38:00 +0530 Subject: [PATCH] fix(iterable): update addition of default value for some fields (#2310) --- .../iterable/data/IterableIdentifyConfig.json | 17 ++++++++++++++++- .../data/IterableRegisterDeviceTokenConfig.json | 6 ++++++ src/v0/destinations/iterable/util.js | 7 ------- test/__tests__/data/iterable_input.json | 6 ++++-- test/__tests__/data/iterable_output.json | 4 ++-- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/v0/destinations/iterable/data/IterableIdentifyConfig.json b/src/v0/destinations/iterable/data/IterableIdentifyConfig.json index 2568c06ba2..d4993dc2b2 100644 --- a/src/v0/destinations/iterable/data/IterableIdentifyConfig.json +++ b/src/v0/destinations/iterable/data/IterableIdentifyConfig.json @@ -4,10 +4,25 @@ "sourceKeys": ["traits.email", "context.traits.email"], "required": false }, + { + "destKey": "preferUserId", + "sourceKeys": ["traits.preferUserId", "context.traits.preferUserId"], + "metadata": { "defaultValue": true }, + "required": false + }, + { + "destKey": "mergeNestedObjects", + "sourceKeys": ["traits.mergeNestedObjects", "context.traits.mergeNestedObjects"], + "metadata": { "defaultValue": true }, + "required": false + }, { "destKey": "dataFields", "sourceKeys": ["traits", "context.traits"], - "required": false + "required": false, + "metadata": { + "excludes": ["preferUserId", "mergeNestedObjects"] + } }, { "destKey": "userId", diff --git a/src/v0/destinations/iterable/data/IterableRegisterDeviceTokenConfig.json b/src/v0/destinations/iterable/data/IterableRegisterDeviceTokenConfig.json index 4566ba7220..16e79dfa11 100644 --- a/src/v0/destinations/iterable/data/IterableRegisterDeviceTokenConfig.json +++ b/src/v0/destinations/iterable/data/IterableRegisterDeviceTokenConfig.json @@ -15,5 +15,11 @@ "anonymousId" ], "required": false + }, + { + "destKey": "preferUserId", + "sourceKeys": ["traits.preferUserId", "context.traits.preferUserId"], + "metadata": { "defaultValue": true }, + "required": false } ] diff --git a/src/v0/destinations/iterable/util.js b/src/v0/destinations/iterable/util.js index 28e8208f81..e094dfa4f9 100644 --- a/src/v0/destinations/iterable/util.js +++ b/src/v0/destinations/iterable/util.js @@ -25,7 +25,6 @@ const identifyDeviceAction = (message) => { let rawPayload = {}; rawPayload = constructPayload(message, mappingConfig[ConfigCategory.IDENTIFY_DEVICE.name]); rawPayload.device = constructPayload(message, mappingConfig[ConfigCategory.DEVICE.name]); - rawPayload.preferUserId = true; if (isAppleFamily(message.context.device.type)) { rawPayload.device.platform = 'APNS'; } else { @@ -46,8 +45,6 @@ const identifyAction = (message, category) => { addExternalIdToTraits(message); } const rawPayload = constructPayload(message, mappingConfig[category.name]); - rawPayload.preferUserId = true; - rawPayload.mergeNestedObjects = true; validateMandatoryField(rawPayload); return rawPayload; }; @@ -135,8 +132,6 @@ const trackPurchaseAction = (message, category) => { rawPayload = constructPayload(message, mappingConfig[category.name]); rawPayload.user = constructPayload(message, mappingConfig[ConfigCategory.IDENTIFY.name]); validateMandatoryField(rawPayload.user); - rawPayload.user.preferUserId = true; - rawPayload.user.mergeNestedObjects = true; rawPayload.items = message.properties.products; if (rawPayload.items && Array.isArray(rawPayload.items)) { rawPayload.items.forEach((el) => { @@ -186,8 +181,6 @@ const updateCartAction = (message) => { const rawPayloadItemArr = []; rawPayload.user = constructPayload(message, mappingConfig[ConfigCategory.IDENTIFY.name]); validateMandatoryField(rawPayload.user); - rawPayload.user.preferUserId = true; - rawPayload.user.mergeNestedObjects = true; if (rawPayload.items && Array.isArray(rawPayload.items)) { rawPayload.items.forEach((el) => { const element = constructPayload(el, mappingConfig[ConfigCategory.PRODUCT.name]); diff --git a/test/__tests__/data/iterable_input.json b/test/__tests__/data/iterable_input.json index 084a688585..0e6d520414 100644 --- a/test/__tests__/data/iterable_input.json +++ b/test/__tests__/data/iterable_input.json @@ -47,7 +47,8 @@ "city": "Bangalore", "name": "manashi", "email": "manashi@website.com", - "country": "India" + "country": "India", + "preferUserId": false }, "library": { "name": "analytics-node", @@ -636,7 +637,8 @@ "version": "1.0.0" }, "traits": { - "email": "ruchira@rudderlabs.com" + "email": "ruchira@rudderlabs.com", + "mergeNestedObjects": false }, "library": { "name": "RudderLabs JavaScript SDK", diff --git a/test/__tests__/data/iterable_output.json b/test/__tests__/data/iterable_output.json index a861fb99f7..2ba5d5c97d 100644 --- a/test/__tests__/data/iterable_output.json +++ b/test/__tests__/data/iterable_output.json @@ -17,7 +17,7 @@ "email": "manashi@website.com", "country": "India" }, - "preferUserId": true, + "preferUserId": false, "mergeNestedObjects": true } }, @@ -336,7 +336,7 @@ }, "userId": "123456", "preferUserId": true, - "mergeNestedObjects": true + "mergeNestedObjects": false }, "XML": {}, "JSON_ARRAY": {},