Skip to content

Commit

Permalink
fix: conditional handling in sfmc track event when event name is not …
Browse files Browse the repository at this point in the history
…present

Signed-off-by: Sai Sankeerth <[email protected]>
  • Loading branch information
Sai Sankeerth committed Nov 22, 2023
1 parent 5c63d2c commit d11ac84
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/v0/destinations/sfmc/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,17 @@ const responseBuilderSimple = async (message, category, destination) => {
throw new ConfigurationError('Creating or updating contacts is disabled');
}

if (category.type === 'track' && hashMapExternalKey[message.event.toLowerCase()]) {
const lowerCasedEvent = message?.event?.toLowerCase();
if (category.type === 'track' && hashMapExternalKey[lowerCasedEvent]) {
return responseBuilderForInsertData(
message,
hashMapExternalKey[message.event.toLowerCase()],
hashMapExternalKey[lowerCasedEvent],
subDomain,
category,
authToken,
'track',
hashMapPrimaryKey[message.event.toLowerCase()] || CONTACT_KEY_KEY,
hashMapUUID[message.event.toLowerCase()],
hashMapPrimaryKey[lowerCasedEvent] || CONTACT_KEY_KEY,
hashMapUUID[lowerCasedEvent],
);
}

Expand Down
89 changes: 89 additions & 0 deletions test/__tests__/data/sfmc_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -993,5 +993,94 @@
"Enabled": true,
"Transformations": []
}
},
{
"message": {
"context": {
"app": {
"build": "1.0.0",
"name": "RudderLabs JavaScript SDK",
"version": "1.0.0"
},
"campaign": {
"name": "Demo Campaign",
"source": "facebook",
"medium": "online",
"term": "Demo terms",
"content": "Demo content"
},
"traits": {
"email": "[email protected]",
"name": "Tonmoy Labs"
},
"library": {
"name": "RudderLabs JavaScript SDK",
"version": "1.0.0"
},
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
"locale": "en-GB",
"ip": "0.0.0.0",
"screen": {
"density": 2,
"height": 860,
"width": 1280
}
},
"type": "track",
"messageId": "50360b9c-ea8d-409c-b672-c9230f91cce5",
"originalTimestamp": "2019-10-15T09:35:31.288Z",
"userId": "12345",
"properties": {
"Plan": "plan value",
"Price Key": 29.99,
"Contact Key": 12345,
"Guest Key": "2323-34343-3434"
},
"sentAt": "2019-10-14T09:03:22.563Z",
"integrations": {
"All": true
}
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
"Name": "SFMC",
"DestinationDefinition": {
"ID": "1pYpYSeQd8OeN6xPdw6VGDzqUd1",
"Name": "SFMC",
"DisplayName": "Salesforce Marketing Cloud",
"Config": {
"destConfig": [],
"excludeKeys": [],
"includeKeys": [],
"saveDestinationResponse": false,
"supportedSourceTypes": [],
"transformAt": "processor"
},
"ResponseRules": {}
},
"Config": {
"clientId": "vcn7AQ2W9GGIAZSsN6Mfq",
"clientSecret": "vcn7AQ2W9GGIAZSsN6Mfq",
"createOrUpdateContacts": false,
"eventDelivery": true,
"eventDeliveryTS": 1615371070621,
"eventToExternalKey": [
{
"from": "Event Name",
"to": "C500FD37-155C-49BD-A21B-AFCEF3D1A9CB"
},
{ "from": "Watch", "to": "C500FD37-155C-49BD-A21B-AFCEF3D1A9CB" }
],
"eventToPrimaryKey": [
{ "from": "userId", "to": "User Key" },
{ "from": "watch", "to": "Guest Key, Contact Key" }
],
"eventToUUID": [{ "event": "Event Name", "uuid": true }],
"externalKey": "f3ffa19b-e0b3-4967-829f-549b781080e6",
"subDomain": "vcn7AQ2W9GGIAZSsN6Mfq"
},
"Enabled": true,
"Transformations": []
}
}
]
3 changes: 3 additions & 0 deletions test/__tests__/data/sfmc_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,8 @@
},
"version": "1",
"endpoint": "https://vcn7AQ2W9GGIAZSsN6Mfq.rest.marketingcloudapis.com/hub/v1/dataevents/key:C500FD37-155C-49BD-A21B-AFCEF3D1A9CB/rows/Guest Key:2323-34343-3434,Contact Key:12345"
},
{
"error": "Event not mapped for this track call"
}
]

0 comments on commit d11ac84

Please sign in to comment.