Skip to content

Commit

Permalink
fix: adding dedicated mappingJson for setOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Nov 17, 2023
1 parent 6ea3d1e commit 91beb1e
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 60 deletions.
3 changes: 3 additions & 0 deletions src/v0/destinations/mp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const ConfigCategory = {
IDENTIFY: {
name: 'MPIdentifyConfig',
},
SET_ONCE: {
name: 'MPSetOnceConfig',
},
PROFILE_ANDROID: {
name: 'MPProfilePropertiesAndroid',
},
Expand Down
84 changes: 25 additions & 59 deletions src/v0/destinations/mp/data/MPIdentifyConfig.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,53 @@
[
{
"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",
"sourceKeys": [
"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
},
{
Expand All @@ -79,9 +57,7 @@
"context.traits.address.country",
"traits.country",
"context.traits.country",
"context.location.country",
"country",
"address.country"
"context.location.country"
],
"required": false
},
Expand All @@ -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
},
Expand All @@ -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
},
{
Expand Down Expand Up @@ -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
},
{
Expand Down
62 changes: 62 additions & 0 deletions src/v0/destinations/mp/data/MPSetOnceConfig.json
Original file line number Diff line number Diff line change
@@ -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
}
]
3 changes: 2 additions & 1 deletion src/v0/destinations/mp/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 91beb1e

Please sign in to comment.