Skip to content

Commit

Permalink
small edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrouti Gangopadhyay authored and Shrouti Gangopadhyay committed May 5, 2024
1 parent acf6eeb commit 110aff2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/cdk/v2/destinations/emarsys/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ steps:
template: |
const properties = ^.message.properties;
const integrationObject = $.getIntegrationsObj(^.message, 'emarsys');
const emersysIdentifierId = integrationObject.customIdentifierId ?? ^.destination.Config.emersysCustomIdentifier ?? $.EMAIL_FIELD_ID;
const emersysIdentifierId = $.deduceCustomIdentifier(integrationObject, ^.destination.Config.emersysCustomIdentifier);
const payload = {
key_id: emersysIdentifierId,
external_id: $.deduceExternalIdValue(^.message,emersysIdentifierId,.destination.Config.fieldMapping),
trigger_id: $.integrationObject.trigger_id,
trigger_id: integrationObject.trigger_id,
data: properties.data,
attachment: Array.isArray(properties.attachment)
? properties.attachment
Expand Down
10 changes: 6 additions & 4 deletions src/cdk/v2/destinations/emarsys/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const buildHeader = (destConfig) => {
};
};

const deduceCustomIdentifier = (integrationObject, emersysCustomIdentifier) =>
integrationObject?.customIdentifierId || emersysCustomIdentifier || EMAIL_FIELD_ID;

const buildIdentifyPayload = (message, destConfig) => {
let destinationPayload;
const { fieldMapping, emersysCustomIdentifier, discardEmptyProperties, defaultContactList } =
Expand All @@ -73,8 +76,7 @@ const buildIdentifyPayload = (message, destConfig) => {
}
});
}
const emersysIdentifier =
integrationObject?.customIdentifierId || emersysCustomIdentifier || EMAIL_FIELD_ID;
const emersysIdentifier = deduceCustomIdentifier(integrationObject, emersysCustomIdentifier);
const finalPayload =
discardEmptyProperties === true
? removeUndefinedAndNullAndEmptyValues(payload) // empty property value has a significance in emersys
Expand Down Expand Up @@ -131,8 +133,7 @@ const deduceExternalIdValue = (message, emersysIdentifier, fieldMapping) => {
const buildGroupPayload = (message, destConfig) => {
const { emersysCustomIdentifier, defaultContactList, fieldMapping } = destConfig;
const integrationObject = getIntegrationsObj(message, 'emarsys');
const emersysIdentifier =
integrationObject?.customIdentifierId || emersysCustomIdentifier || EMAIL_FIELD_ID;
const emersysIdentifier = deduceCustomIdentifier(integrationObject, emersysCustomIdentifier);
const externalIdValue = deduceExternalIdValue(message, emersysIdentifier, fieldMapping);
if (!isDefinedAndNotNull(externalIdValue)) {
throw new InstrumentationError(
Expand Down Expand Up @@ -434,4 +435,5 @@ module.exports = {
buildTrackPayload,
deduceExternalIdValue,
deduceEventId,
deduceCustomIdentifier,
};

0 comments on commit 110aff2

Please sign in to comment.