Skip to content

Commit c18e1ac

Browse files
authored
fix: consider email from dataSoruce as well (#5039)
🔒 Scanned for secrets using gitleaks 8.28.0 ## What are the changes introduced in this PR? We are considering email form data fields as well. ## What is the related Linear task? Resolves INT- ## Please explain the objectives of your changes below Put down any required details on the broader aspect of your changes. If there are any dependent changes, **mandatorily** mention them here ### Any changes to existing capabilities/behaviour, mention the reason & what are the changes ? N/A ### Any new dependencies introduced with this change? N/A ### Any new generic utility introduced or modified. Please explain the changes. N/A ### Any technical or performance related pointers to consider with the change? N/A @coderabbitai review <hr> ### Developer checklist - [ ] My code follows the style guidelines of this project - [ ] **No breaking changes are being introduced.** - [ ] All related docs linked with the PR? - [ ] All changes manually tested? - [ ] Any documentation changes needed with this change? - [ ] Is the PR limited to 10 file changes? - [ ] Is the PR limited to one linear task? - [ ] Are relevant unit and component test-cases added in **new readability format**? ### Reviewer checklist - [ ] Is the type of change in the PR title appropriate as per the changes? - [ ] Verified that there are no credentials or confidential data exposed with the changes.
1 parent af30c70 commit c18e1ac

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

src/sources/iterable/mapping.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
3-
"sourceKeys": "email",
3+
"sourceKeys": ["email", "dataFields.email"],
44
"destKeys": "context.traits.email"
55
},
66
{

src/sources/iterable/transform.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const isNonEmptyString = (val) => typeof val === 'string' && isDefinedAndNotNull
2020
*/
2121
function checkForRequiredFields(event) {
2222
if (
23-
(!isNonEmptyString(event.email) && !isNonEmptyString(event.userId)) ||
23+
(!isNonEmptyString(event.email) &&
24+
!isNonEmptyString(event.userId) &&
25+
!isNonEmptyString(event?.dataFields?.email)) ||
2426
!isNonEmptyString(event.eventName)
2527
) {
2628
throw new TransformationError('Unknown event type from Iterable');
@@ -55,7 +57,7 @@ function process(payload) {
5557
// Treating userId as unique identifier
5658
// If userId is not present, then generating it from email using md5 hash function
5759
if (!isDefinedAndNotNull(message.userId)) {
58-
message.userId = md5(event.email);
60+
message.userId = md5(message.context.traits.email);
5961
}
6062

6163
return message;

test/integrations/sources/iterable/data.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,32 @@ export const data = [
105105
status: 200,
106106
body: [
107107
{
108-
error: 'Unknown event type from Iterable',
109-
statTags: {
110-
destinationId: 'Non determinable',
111-
errorCategory: 'transformation',
112-
implementation: 'native',
113-
module: 'source',
114-
srcType: 'iterable',
115-
workspaceId: 'Non determinable',
108+
output: {
109+
batch: [
110+
{
111+
userId: '7c904adb430b791c0abd432442374b17',
112+
context: {
113+
integration: { name: 'Iterable', version: '1.0.0' },
114+
library: { name: 'unknown', version: 'unknown' },
115+
traits: { email: 'test@abcd.com' },
116+
},
117+
event: 'emailSubscribe',
118+
integrations: { Iterable: false },
119+
properties: {
120+
channelIds: [],
121+
createdAt: '2022-04-19 03:33:50 +00:00',
122+
emailListIds: [1589748],
123+
messageTypeIds: [],
124+
profileUpdatedAt: '2022-04-19 03:33:50 +00:00',
125+
publicIdString: 'ad474bf7-e785-480f-b9d0-861b85ab5bf5',
126+
signupSource: 'WebForm',
127+
},
128+
receivedAt: '2022-04-19T03:33:50.000Z',
129+
timestamp: '2022-04-19T03:33:50.000Z',
130+
type: 'track',
131+
},
132+
],
116133
},
117-
statusCode: 400,
118134
},
119135
],
120136
},
@@ -2421,6 +2437,7 @@ export const data = [
24212437
context: {
24222438
integration: { name: 'Iterable', version: '1.0.0' },
24232439
library: { name: 'unknown', version: 'unknown' },
2440+
traits: { email: 'docs@iterable.com' },
24242441
},
24252442
event: 'webPushSendSkip',
24262443
integrations: { Iterable: false },

0 commit comments

Comments
 (0)