From 4dbcbd354e3f48e77bbdd5b84b6fe797c34ea66e Mon Sep 17 00:00:00 2001 From: Gauravudia Date: Mon, 20 Nov 2023 18:45:15 +0530 Subject: [PATCH] fix: add event name check in sfmc --- src/v0/destinations/sfmc/transform.js | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/v0/destinations/sfmc/transform.js b/src/v0/destinations/sfmc/transform.js index 879ca1989a..3f5c2a9f17 100644 --- a/src/v0/destinations/sfmc/transform.js +++ b/src/v0/destinations/sfmc/transform.js @@ -224,17 +224,23 @@ const responseBuilderSimple = async (message, category, destination) => { throw new ConfigurationError('Creating or updating contacts is disabled'); } - if (category.type === 'track' && hashMapExternalKey[message.event.toLowerCase()]) { - return responseBuilderForInsertData( - message, - hashMapExternalKey[message.event.toLowerCase()], - subDomain, - category, - authToken, - 'track', - hashMapPrimaryKey[message.event.toLowerCase()] || CONTACT_KEY_KEY, - hashMapUUID[message.event.toLowerCase()], - ); + if (category.type === 'track') { + if (!message.event) { + throw new InstrumentationError('Event name is required'); + } + + if (hashMapExternalKey[message.event.toLowerCase()]) { + return responseBuilderForInsertData( + message, + hashMapExternalKey[message.event.toLowerCase()], + subDomain, + category, + authToken, + 'track', + hashMapPrimaryKey[message.event.toLowerCase()] || CONTACT_KEY_KEY, + hashMapUUID[message.event.toLowerCase()], + ); + } } throw new ConfigurationError('Event not mapped for this track call');