Skip to content

Commit

Permalink
fix: add event name check in sfmc
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravudia committed Nov 20, 2023
1 parent e5f8714 commit 4dbcbd3
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/v0/destinations/sfmc/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 4dbcbd3

Please sign in to comment.