From 110aff23277c9a3ee03e61336ce86607f3319a69 Mon Sep 17 00:00:00 2001 From: Shrouti Gangopadhyay Date: Sun, 5 May 2024 18:37:32 +0530 Subject: [PATCH] small edit --- src/cdk/v2/destinations/emarsys/procWorkflow.yaml | 4 ++-- src/cdk/v2/destinations/emarsys/utils.js | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cdk/v2/destinations/emarsys/procWorkflow.yaml b/src/cdk/v2/destinations/emarsys/procWorkflow.yaml index ee7f78b743..0d3152767e 100644 --- a/src/cdk/v2/destinations/emarsys/procWorkflow.yaml +++ b/src/cdk/v2/destinations/emarsys/procWorkflow.yaml @@ -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 diff --git a/src/cdk/v2/destinations/emarsys/utils.js b/src/cdk/v2/destinations/emarsys/utils.js index 8e82846f58..d443cc0f10 100644 --- a/src/cdk/v2/destinations/emarsys/utils.js +++ b/src/cdk/v2/destinations/emarsys/utils.js @@ -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 } = @@ -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 @@ -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( @@ -434,4 +435,5 @@ module.exports = { buildTrackPayload, deduceExternalIdValue, deduceEventId, + deduceCustomIdentifier, };