Skip to content

Commit

Permalink
fix(iterable): update addition of default value for some fields (#2310)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip authored Jun 30, 2023
1 parent c91dadc commit 0f1ebba
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
17 changes: 16 additions & 1 deletion src/v0/destinations/iterable/data/IterableIdentifyConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@
"anonymousId"
],
"required": false
},
{
"destKey": "preferUserId",
"sourceKeys": ["traits.preferUserId", "context.traits.preferUserId"],
"metadata": { "defaultValue": true },
"required": false
}
]
7 changes: 0 additions & 7 deletions src/v0/destinations/iterable/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
};
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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]);
Expand Down
6 changes: 4 additions & 2 deletions test/__tests__/data/iterable_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"city": "Bangalore",
"name": "manashi",
"email": "[email protected]",
"country": "India"
"country": "India",
"preferUserId": false
},
"library": {
"name": "analytics-node",
Expand Down Expand Up @@ -636,7 +637,8 @@
"version": "1.0.0"
},
"traits": {
"email": "[email protected]"
"email": "[email protected]",
"mergeNestedObjects": false
},
"library": {
"name": "RudderLabs JavaScript SDK",
Expand Down
4 changes: 2 additions & 2 deletions test/__tests__/data/iterable_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"email": "[email protected]",
"country": "India"
},
"preferUserId": true,
"preferUserId": false,
"mergeNestedObjects": true
}
},
Expand Down Expand Up @@ -336,7 +336,7 @@
},
"userId": "123456",
"preferUserId": true,
"mergeNestedObjects": true
"mergeNestedObjects": false
},
"XML": {},
"JSON_ARRAY": {},
Expand Down

0 comments on commit 0f1ebba

Please sign in to comment.