From fdb7a8b12ffb4494cc3ddd4d104ad69db4605813 Mon Sep 17 00:00:00 2001 From: Yashasvi Bajpai <33063622+yashasvibajpai@users.noreply.github.com> Date: Wed, 21 Feb 2024 00:36:51 +0530 Subject: [PATCH] chore: refactorx1 --- src/v0/destinations/sfmc/transform.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/v0/destinations/sfmc/transform.js b/src/v0/destinations/sfmc/transform.js index 8d7fa2433e..6f88b76ab4 100644 --- a/src/v0/destinations/sfmc/transform.js +++ b/src/v0/destinations/sfmc/transform.js @@ -209,7 +209,7 @@ const responseBuilderSimple = async (message, category, destination) => { eventToExternalKey, eventToPrimaryKey, eventToUUID, - eventToDefinitionMapping + eventToDefinitionMapping, } = destination.Config; // map from an event name to an external key of a data extension. const hashMapExternalKey = getHashFromArray(eventToExternalKey, 'from', 'to'); @@ -220,7 +220,7 @@ const responseBuilderSimple = async (message, category, destination) => { // token needed for authorization for subsequent calls const authToken = await getToken(clientId, clientSecret, subDomain); // map from an event name to an event definition key. - const hashMapEventDefinition = getHashFromArray(eventToDefinitionMapping, 'from', 'to') + const hashMapEventDefinition = getHashFromArray(eventToDefinitionMapping, 'from', 'to'); // if createOrUpdateContacts is true identify calls for create and update of contacts will not occur. if (category.type === 'identify' && !createOrUpdateContacts) { // first call to identify the contact @@ -254,12 +254,12 @@ const responseBuilderSimple = async (message, category, destination) => { if (typeof message.event !== 'string') { throw new ConfigurationError('Event name must be a string'); } - if (!isDefinedAndNotNull(hashMapExternalKey[message.event.toLowerCase()])) { - throw new ConfigurationError('Event not mapped for this track call'); - } if (hashMapEventDefinition[message.event.toLowerCase()]) { return responseBuilderForMessageEvent(message, subDomain, authToken, hashMapEventDefinition); } + if (!isDefinedAndNotNull(hashMapExternalKey[message.event.toLowerCase()])) { + throw new ConfigurationError('Event not mapped for this track call'); + } return responseBuilderForInsertData( message, hashMapExternalKey[message.event.toLowerCase()],