Skip to content

Commit

Permalink
fix: removed unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Nov 14, 2023
1 parent ea60161 commit 1dafad7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
18 changes: 8 additions & 10 deletions src/v0/destinations/mp/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ const responseBuilderSimple = (payload, message, eventType, destConfig) => {
strict: credentials.params.strict,
};
break;
// case 'setOnce':
// response.endpoint = dataResidency === 'eu' ? `${BASE_ENDPOINT_EU}/engage#profile-set-once` : `${BASE_ENDPOINT}/engage#profile-set-once`;
// response.headers = {
// 'Content-Type': 'application/json',
// 'accept': 'text/plain',
// };
// break;
default:
response.endpoint =
dataResidency === 'eu' ? `${BASE_ENDPOINT_EU}/engage/` : `${BASE_ENDPOINT}/engage/`;
Expand Down Expand Up @@ -256,7 +249,7 @@ function trimTraits(traits, contextTraits, setOnceProperties) {
lodash.unset(traitsCopy, propertyPath);
}
if (Object.keys(contextTraits).length > 0 && get(contextTraitsCopy, propertyPath)) {
if(!setOnceEligible.hasOwnProperty(propName)) {
if (!setOnceEligible.hasOwnProperty(propName)) {
setOnceEligible[propName] = get(contextTraitsCopy, propertyPath);
}
lodash.unset(contextTraitsCopy, propertyPath);
Expand All @@ -268,7 +261,12 @@ function trimTraits(traits, contextTraits, setOnceProperties) {

// Step 3: combine the transformed and custom setOnce traits

sentOnceTransform = extractCustomFields(setOnceEligible, sentOnceTransform, 'root', MP_IDENTIFY_EXCLUSION_LIST);
sentOnceTransform = extractCustomFields(
setOnceEligible,
sentOnceTransform,
'root',
MP_IDENTIFY_EXCLUSION_LIST,
);

return {
traits: traitsCopy,
Expand Down Expand Up @@ -312,7 +310,7 @@ const processIdentifyEvents = async (message, type, destination) => {

// Creating the user profile
// https://developer.mixpanel.com/reference/profile-set
returnValue.push(createIdentifyResponse(messageClone, type, destination, responseBuilderSimple, setOnceProperties));
returnValue.push(createIdentifyResponse(messageClone, type, destination, responseBuilderSimple));

if (
destination.Config?.identityMergeApi !== 'simplified' &&
Expand Down
13 changes: 4 additions & 9 deletions src/v0/destinations/mp/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const mPProfileIosConfigJson = mappingConfig[ConfigCategory.PROFILE_IOS.name];
* @param {*} useNewMapping a variable to support backward compatibility
* @returns
*/
const getTransformedJSON = (message, mappingJson, useNewMapping, setOnceProperties) => {
const getTransformedJSON = (message, mappingJson, useNewMapping) => {
let rawPayload = constructPayload(message, mappingJson);
if (
isDefined(rawPayload.$geo_source) &&
Expand All @@ -47,16 +47,11 @@ const getTransformedJSON = (message, mappingJson, useNewMapping, setOnceProperti
set(rawPayload, '$name', getFullName(message));
}

let newExclusionList = [...MP_IDENTIFY_EXCLUSION_LIST];
if (setOnceProperties.length > 0) {
newExclusionList = [...newExclusionList, ...setOnceProperties];
}

rawPayload = extractCustomFields(
message,
rawPayload,
['traits', 'context.traits'],
newExclusionList,
MP_IDENTIFY_EXCLUSION_LIST,
);

/*
Expand Down Expand Up @@ -104,11 +99,11 @@ const getTransformedJSON = (message, mappingJson, useNewMapping, setOnceProperti
* @param {*} responseBuilderSimple function to generate response
* @returns
*/
const createIdentifyResponse = (message, type, destination, responseBuilderSimple, setOnceProperties) => {
const createIdentifyResponse = (message, type, destination, responseBuilderSimple) => {
// this variable is used for supporting backward compatibility
const { useNewMapping, token } = destination.Config;
// user payload created
const properties = getTransformedJSON(message, mPIdentifyConfigJson, useNewMapping, setOnceProperties);
const properties = getTransformedJSON(message, mPIdentifyConfigJson, useNewMapping);

const payload = {
$set: properties,
Expand Down

0 comments on commit 1dafad7

Please sign in to comment.