Skip to content

Commit

Permalink
Worked on Braze Actions identify mapping defaults to reference proper…
Browse files Browse the repository at this point in the history
…ties.braze_id (#2666)

Co-authored-by: Gaurav Kochar <[email protected]>
  • Loading branch information
Innovative-GauravKochar and Gaurav Kochar authored Jan 9, 2025
1 parent bb100a1 commit b0d012e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ 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', {
event,
settings,
useDefaultMappings: true
})

expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
}
}

Expand All @@ -596,6 +600,15 @@ describe('MultiStatus', () => {
email: '[email protected]'
}
}),
createTestEvent({
type: 'identify',
receivedAt,
traits: {
firstName: 'Example',
lastName: 'User',
braze_id: 'test-braze-id'
}
}),
// Event without any user identifier
createTestEvent({
type: 'identify',
Expand All @@ -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.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ const action: ActionDefinition<Settings, Payload> = {
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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { batch_size, country_code, enable_batching } from '../properties'
const action: ActionDefinition<Settings, Payload> = {
title: 'Remove Profile',
description: 'Remove profile from list',
defaultSubscription: 'event = "Identify"',
defaultSubscription: 'type = "Identify"',
fields: {
email: {
label: 'Email',
Expand Down

0 comments on commit b0d012e

Please sign in to comment.