Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Object {
"eventProperties": Object {
"testType": "aeKHha#$d",
},
"testType": "aeKHha#$d",
"userId": "aeKHha#$d",
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Object {
"eventProperties": Object {
"testType": "gJCx1dPfi6rH2R",
},
"testType": "gJCx1dPfi6rH2R",
"userId": "gJCx1dPfi6rH2R",
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ describe('Loops.sendEvent', () => {
await testDestination.testAction('sendEvent', {
settings: { apiKey: LOOPS_API_KEY }
})
} catch (err) {
expect(err.message).toContain("missing the required field 'userId'.")
expect(err.message).toContain("missing the required field 'eventName'.")
} catch (err: unknown) {
if (err instanceof Error) {
expect(err.message).toContain("missing the required field 'userId'.")
expect(err.message).toContain("missing the required field 'eventName'.")
}
}
})

Expand Down Expand Up @@ -77,4 +79,42 @@ describe('Loops.sendEvent', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
})

it('should work with contact properties', async () => {
const testPayload = {
userId: 'some-id-1',
eventName: 'signup',
eventProperties: {
someField: true, // boolean
someField1: 'hello', // string
someField2: '2024-04-01T10:09:65Z' // date
},
contactProperties: {
firstName: 'Bob',
anIntegerProperty: 1
}
}
const testPayloadOut = {
userId: 'some-id-1',
eventName: 'signup',
eventProperties: {
someField: true,
someField1: 'hello',
someField2: '2024-04-01T10:09:65Z'
},
firstName: 'Bob',
anIntegerProperty: 1
}
nock('https://app.loops.so/api/v1').post('/events/send', testPayloadOut).reply(200, {
success: true
})

const responses = await testDestination.testAction('sendEvent', {
mapping: testPayload,
settings: { apiKey: LOOPS_API_KEY }
})

expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
})
})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ const action: ActionDefinition<Settings, Payload> = {
'@path': '$.userId'
}
},
contactProperties: {
label: 'Contact Properties',
description: "Optional properties that will be updated on the event's contact.",
type: 'object',
required: false
},
eventProperties: {
label: 'Event Properties',
description: 'Event-specific properties that can be included in emails triggered by this event.',
Expand All @@ -54,7 +60,8 @@ const action: ActionDefinition<Settings, Payload> = {
email: payload.email,
eventName: payload.eventName,
userId: payload.userId,
eventProperties: payload.eventProperties
eventProperties: payload.eventProperties,
...(typeof payload.contactProperties === 'object' && payload.contactProperties)
}
})
}
Expand Down
Loading