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

Worked on fixing braze_id default mappings of Braze Actions. #2666

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -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
Loading