diff --git a/packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap b/packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap index 27df5a17ad..819cf04fcc 100644 --- a/packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap +++ b/packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap @@ -24,6 +24,9 @@ exports[`Testing snapshot for actions-loops destination: sendEvent action - all Object { "email": "ep@tuhi.co", "eventName": "aeKHha#$d", + "eventProperties": Object { + "testType": "aeKHha#$d", + }, "userId": "aeKHha#$d", } `; diff --git a/packages/destination-actions/src/destinations/loops/sendEvent/__tests__/__snapshots__/snapshot.test.ts.snap b/packages/destination-actions/src/destinations/loops/sendEvent/__tests__/__snapshots__/snapshot.test.ts.snap index 06fba6cb29..a887c49c3a 100644 --- a/packages/destination-actions/src/destinations/loops/sendEvent/__tests__/__snapshots__/snapshot.test.ts.snap +++ b/packages/destination-actions/src/destinations/loops/sendEvent/__tests__/__snapshots__/snapshot.test.ts.snap @@ -4,6 +4,9 @@ exports[`Testing snapshot for Loops's sendEvent destination action: all fields 1 Object { "email": "ojzec@futtuda.pa", "eventName": "gJCx1dPfi6rH2R", + "eventProperties": Object { + "testType": "gJCx1dPfi6rH2R", + }, "userId": "gJCx1dPfi6rH2R", } `; diff --git a/packages/destination-actions/src/destinations/loops/sendEvent/__tests__/index.test.ts b/packages/destination-actions/src/destinations/loops/sendEvent/__tests__/index.test.ts index 314d4a3649..dde4409b92 100644 --- a/packages/destination-actions/src/destinations/loops/sendEvent/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/loops/sendEvent/__tests__/index.test.ts @@ -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) + }) }) diff --git a/packages/destination-actions/src/destinations/loops/sendEvent/generated-types.ts b/packages/destination-actions/src/destinations/loops/sendEvent/generated-types.ts index 44e24ab37a..601056b5fb 100644 --- a/packages/destination-actions/src/destinations/loops/sendEvent/generated-types.ts +++ b/packages/destination-actions/src/destinations/loops/sendEvent/generated-types.ts @@ -13,4 +13,10 @@ export interface Payload { * User ID for the contact. */ userId: string + /** + * Properties tied to this event, which can be included in emails triggered by this event. + */ + eventProperties?: { + [k: string]: unknown + } } diff --git a/packages/destination-actions/src/destinations/loops/sendEvent/index.ts b/packages/destination-actions/src/destinations/loops/sendEvent/index.ts index 4c9d121664..83b8e0460a 100644 --- a/packages/destination-actions/src/destinations/loops/sendEvent/index.ts +++ b/packages/destination-actions/src/destinations/loops/sendEvent/index.ts @@ -38,6 +38,13 @@ const action: ActionDefinition = { 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 }) => { @@ -46,7 +53,8 @@ const action: ActionDefinition = { json: { email: payload.email, eventName: payload.eventName, - userId: payload.userId + userId: payload.userId, + eventProperties: payload.eventProperties } }) }