Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event properties support #1

Merged
merged 3 commits into from
Jun 13, 2024
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 @@ -24,6 +24,9 @@ exports[`Testing snapshot for actions-loops destination: sendEvent action - all
Object {
"email": "[email protected]",
"eventName": "aeKHha#$d",
"eventProperties": Object {
"testType": "aeKHha#$d",
},
"userId": "aeKHha#$d",
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ exports[`Testing snapshot for Loops's sendEvent destination action: all fields 1
Object {
"email": "[email protected]",
"eventName": "gJCx1dPfi6rH2R",
"eventProperties": Object {
"testType": "gJCx1dPfi6rH2R",
},
"userId": "gJCx1dPfi6rH2R",
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,27 @@ describe('Loops.sendEvent', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
})

it('should work with event properties', async () => {
const testPayload = {
userId: 'some-id-1',
eventName: 'signup',
eventProperties: {
someField: true, // boolean
someField1: 'hello', // string
someField2: '2024-04-01T10:09:65Z' // date
}
}
nock('https://app.loops.so/api/v1').post('/events/send', testPayload).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 @@ -38,6 +38,13 @@ const action: ActionDefinition<Settings, Payload> = {
default: {
'@path': '$.userId'
}
},
eventProperties: {
label: 'Event Properties',
description: 'Properties tied to this event, which can be included in emails triggered by this event.',
type: 'object',
required: false,
default: { '@path': '$.properties' }
}
},
perform: (request, { payload }) => {
Expand All @@ -46,7 +53,8 @@ const action: ActionDefinition<Settings, Payload> = {
json: {
email: payload.email,
eventName: payload.eventName,
userId: payload.userId
userId: payload.userId,
eventProperties: payload.eventProperties
}
})
}
Expand Down
Loading