diff --git a/src/v0/destinations/mp/config.js b/src/v0/destinations/mp/config.js index 41a801e9da..35b40294f5 100644 --- a/src/v0/destinations/mp/config.js +++ b/src/v0/destinations/mp/config.js @@ -11,6 +11,9 @@ const ConfigCategory = { IDENTIFY: { name: 'MPIdentifyConfig', }, + SET_ONCE: { + name: 'MPSetOnceConfig', + }, PROFILE_ANDROID: { name: 'MPProfilePropertiesAndroid', }, diff --git a/src/v0/destinations/mp/data/MPIdentifyConfig.json b/src/v0/destinations/mp/data/MPIdentifyConfig.json index 6934735f67..679ce66d7f 100644 --- a/src/v0/destinations/mp/data/MPIdentifyConfig.json +++ b/src/v0/destinations/mp/data/MPIdentifyConfig.json @@ -1,54 +1,33 @@ [ { "destKey": "$created", - "sourceKeys": ["traits.createdAt", "context.traits.createdAt", "createdAt"], - "required": false + "sourceKeys": "createdAtOnly", + "required": false, + "sourceFromGenericMap": true }, { "destKey": "$email", - "sourceKeys": [ - "traits.email", - "context.traits.email", - "properties.email", - "context.externalId.0.id", - "email" - ], - "required": false + "sourceKeys": "email", + "required": false, + "sourceFromGenericMap": true }, { "destKey": "$first_name", - "sourceKeys": [ - "traits.firstName", - "traits.firstname", - "traits.first_name", - "context.traits.firstName", - "context.traits.firstname", - "context.traits.first_name", - "firstName", - "firstname", - "first_name" - ], - "required": false + "sourceKeys": "firstName", + "required": false, + "sourceFromGenericMap": true }, { "destKey": "$last_name", - "sourceKeys": [ - "traits.lastName", - "traits.lastname", - "traits.last_name", - "context.traits.lastName", - "context.traits.lastname", - "context.traits.last_name", - "lastName", - "lastname", - "last_name" - ], - "required": false + "sourceKeys": "lastName", + "required": false, + "sourceFromGenericMap": true }, { "destKey": "$name", - "sourceKeys": ["traits.name", "context.traits.name", "name"], - "required": false + "sourceKeys": "name", + "required": false, + "sourceFromGenericMap": true }, { "destKey": "$username", @@ -56,20 +35,19 @@ "traits.username", "context.traits.username", "traits.userName", - "context.traits.userName", - "username", - "userName" + "context.traits.userName" ], "required": false }, { "destKey": "$phone", - "sourceKeys": ["traits.phone", "context.traits.phone", "phone"], - "required": false + "sourceKeys": "phone", + "required": false, + "sourceFromGenericMap": true }, { "destKey": "$avatar", - "sourceKeys": ["traits.avatar", "context.traits.avatar", "avatar"], + "sourceKeys": ["traits.avatar", "context.traits.avatar"], "required": false }, { @@ -79,9 +57,7 @@ "context.traits.address.country", "traits.country", "context.traits.country", - "context.location.country", - "country", - "address.country" + "context.location.country" ], "required": false }, @@ -92,9 +68,7 @@ "context.traits.city", "traits.address.city", "context.traits.address.city", - "context.location.city", - "city", - "address.city" + "context.location.city" ], "required": false }, @@ -105,16 +79,13 @@ "context.traits.state", "traits.address.state", "context.traits.address.state", - "context.location.region", - "state", - "address.state", - "location.region" + "context.location.region" ], "required": false }, { "destKey": "$geo_source", - "sourceKeys": ["location.geoSource", "context.location.geoSource"], + "sourceKeys": "context.location.geoSource", "required": false }, { @@ -164,12 +135,7 @@ }, { "destKey": "$unsubscribed", - "sourceKeys": [ - "traits.unsubscribed", - "context.traits.unsubscribed", - "properties.unsubscribed", - "unsubscribed" - ], + "sourceKeys": ["traits.unsubscribed", "context.traits.unsubscribed", "properties.unsubscribed"], "required": false }, { diff --git a/src/v0/destinations/mp/data/MPSetOnceConfig.json b/src/v0/destinations/mp/data/MPSetOnceConfig.json new file mode 100644 index 0000000000..4371827c6c --- /dev/null +++ b/src/v0/destinations/mp/data/MPSetOnceConfig.json @@ -0,0 +1,62 @@ +[ + { + "destKey": "$created", + "sourceKeys": "createdAt", + "required": false + }, + { + "destKey": "$email", + "sourceKeys": "email", + "required": false + }, + { + "destKey": "$first_name", + "sourceKeys": ["firstName", "firstname", "first_name"], + "required": false + }, + { + "destKey": "$last_name", + "sourceKeys": ["lastName", "lastname", "last_name"], + "required": false + }, + { + "destKey": "$name", + "sourceKeys": "name", + "required": false + }, + { + "destKey": "$username", + "sourceKeys": ["username", "userName"], + "required": false + }, + { + "destKey": "$phone", + "sourceKeys": "phone", + "required": false + }, + { + "destKey": "$avatar", + "sourceKeys": "avatar", + "required": false + }, + { + "destKey": "$country_code", + "sourceKeys": ["country", "address.country"], + "required": false + }, + { + "destKey": "$city", + "sourceKeys": ["city", "address.city"], + "required": false + }, + { + "destKey": "$region", + "sourceKeys": ["state", "address.state", "location.region"], + "required": false + }, + { + "destKey": "$unsubscribed", + "sourceKeys": ["unsubscribed"], + "required": false + } +] diff --git a/src/v0/destinations/mp/util.js b/src/v0/destinations/mp/util.js index a2dc2f2563..dd1a719389 100644 --- a/src/v0/destinations/mp/util.js +++ b/src/v0/destinations/mp/util.js @@ -28,6 +28,7 @@ const { CommonUtils } = require('../../../util/common'); const mPIdentifyConfigJson = mappingConfig[ConfigCategory.IDENTIFY.name]; const mPProfileAndroidConfigJson = mappingConfig[ConfigCategory.PROFILE_ANDROID.name]; const mPProfileIosConfigJson = mappingConfig[ConfigCategory.PROFILE_IOS.name]; +const mPSetOnceConfigJson = mappingConfig[ConfigCategory.SET_ONCE.name]; /** * this function has been used to create @@ -380,7 +381,7 @@ function trimTraits(traits, contextTraits, setOnceProperties) { if (setOnceEligible && Object.keys(setOnceEligible).length > 0) { // Step 2: transform properties eligible as per rudderstack declared identify event mapping // setOnce should have all traits from message.traits and message.context.traits by now - sentOnceTransform = constructPayload(setOnceEligible, mPIdentifyConfigJson); + sentOnceTransform = constructPayload(setOnceEligible, mPSetOnceConfigJson); // Step 3: combine the transformed and custom setOnce traits sentOnceTransform = extractCustomFields(