From e75636d4755a081d106ac689d781e791ff7208dc Mon Sep 17 00:00:00 2001 From: Gaurav Kochar Date: Thu, 2 Jan 2025 15:57:35 +0530 Subject: [PATCH] Worked on Braze Actions identify mapping defaults to reference properties.braze_id --- .../__snapshots__/braze.test.ts.snap | 2 +- .../braze/__tests__/braze.test.ts | 8 ++++-- .../braze/__tests__/multistatus.test.ts | 27 ++++++++++++++++--- .../braze/updateUserProfile/index.ts | 6 ++++- .../klaviyo/removeProfile/index.ts | 2 +- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/packages/destination-actions/src/destinations/braze/__tests__/__snapshots__/braze.test.ts.snap b/packages/destination-actions/src/destinations/braze/__tests__/__snapshots__/braze.test.ts.snap index 1bbf5ac0e8..38cf1eac78 100644 --- a/packages/destination-actions/src/destinations/braze/__tests__/__snapshots__/braze.test.ts.snap +++ b/packages/destination-actions/src/destinations/braze/__tests__/__snapshots__/braze.test.ts.snap @@ -110,7 +110,7 @@ Object { "attributes": Array [ Object { "_update_existing_only": false, - "braze_id": undefined, + "braze_id": "test_braze_123", "country": "United States", "current_location": Object { "latitude": 40.2964197, diff --git a/packages/destination-actions/src/destinations/braze/__tests__/braze.test.ts b/packages/destination-actions/src/destinations/braze/__tests__/braze.test.ts index 2a6210c188..f08d8677c3 100644 --- a/packages/destination-actions/src/destinations/braze/__tests__/braze.test.ts +++ b/packages/destination-actions/src/destinations/braze/__tests__/braze.test.ts @@ -19,7 +19,12 @@ describe('Braze Cloud Mode (Actions)', () => { const event = createTestEvent({ type: 'identify', - receivedAt + receivedAt, + integrations: { + ['Braze Cloud Mode (Actions)']: { + braze_id: 'test_braze_123' + } as any + } }) const responses = await testDestination.testAction('updateUserProfile', { @@ -27,7 +32,6 @@ describe('Braze Cloud Mode (Actions)', () => { settings, useDefaultMappings: true }) - expect(responses.length).toBe(1) expect(responses[0].status).toBe(200) expect(responses[0].data).toMatchObject({}) diff --git a/packages/destination-actions/src/destinations/braze/__tests__/multistatus.test.ts b/packages/destination-actions/src/destinations/braze/__tests__/multistatus.test.ts index 9ae45d53f1..40f5ed91d2 100644 --- a/packages/destination-actions/src/destinations/braze/__tests__/multistatus.test.ts +++ b/packages/destination-actions/src/destinations/braze/__tests__/multistatus.test.ts @@ -569,7 +569,11 @@ describe('MultiStatus', () => { '@path': '$.traits.externalId' }, braze_id: { - '@path': '$.traits.brazeId' + '@if': { + exists: { '@path': '$.integrations.Braze Cloud Mode (Actions).braze_id' }, + then: { '@path': '$.integrations.Braze Cloud Mode (Actions).braze_id' }, + else: { '@path': '$.traits.braze_id' } + } } } @@ -596,6 +600,15 @@ describe('MultiStatus', () => { email: 'user@example.com' } }), + createTestEvent({ + type: 'identify', + receivedAt, + traits: { + firstName: 'Example', + lastName: 'User', + braze_id: 'test-braze-id' + } + }), // Event without any user identifier createTestEvent({ type: 'identify', @@ -618,15 +631,23 @@ describe('MultiStatus', () => { status: 200, body: 'success' }) - // The second event doesn't fail as there is no error reported by Braze API expect(response[1]).toMatchObject({ status: 200, body: 'success' }) - // The third event fails as pre-request validation fails for not having a valid user identifier + // The Third event doesn't fail as there is no error reported by Braze API expect(response[2]).toMatchObject({ + status: 200, + body: 'success', + sent: expect.objectContaining({ + braze_id: 'test-braze-id' + }) + }) + + // The Fourth event fails as pre-request validation fails for not having a valid user identifier + expect(response[3]).toMatchObject({ status: 400, errortype: 'PAYLOAD_VALIDATION_FAILED', errormessage: 'One of "external_id" or "user_alias" or "braze_id" or "email" is required.', diff --git a/packages/destination-actions/src/destinations/braze/updateUserProfile/index.ts b/packages/destination-actions/src/destinations/braze/updateUserProfile/index.ts index 4ee5612638..f06815b110 100644 --- a/packages/destination-actions/src/destinations/braze/updateUserProfile/index.ts +++ b/packages/destination-actions/src/destinations/braze/updateUserProfile/index.ts @@ -38,7 +38,11 @@ const action: ActionDefinition = { type: 'string', allowNull: true, default: { - '@path': '$.properties.braze_id' + '@if': { + exists: { '@path': '$.integrations.Braze Cloud Mode (Actions).braze_id' }, + then: { '@path': '$.integrations.Braze Cloud Mode (Actions).braze_id' }, + else: { '@path': '$.traits.braze_id' } + } } }, country: { diff --git a/packages/destination-actions/src/destinations/klaviyo/removeProfile/index.ts b/packages/destination-actions/src/destinations/klaviyo/removeProfile/index.ts index 675694c50a..7410fdb661 100644 --- a/packages/destination-actions/src/destinations/klaviyo/removeProfile/index.ts +++ b/packages/destination-actions/src/destinations/klaviyo/removeProfile/index.ts @@ -14,7 +14,7 @@ import { batch_size, country_code, enable_batching } from '../properties' const action: ActionDefinition = { title: 'Remove Profile', description: 'Remove profile from list', - defaultSubscription: 'event = "Identify"', + defaultSubscription: 'type = "Identify"', fields: { email: { label: 'Email',