Skip to content

Commit 6d93e78

Browse files
braze new action testing
1 parent a3dd73b commit 6d93e78

5 files changed

Lines changed: 234 additions & 201 deletions

File tree

packages/destination-actions/src/destinations/braze/mergeUsers/generated-types.ts

Lines changed: 28 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/destination-actions/src/destinations/braze/mergeUsers/index.ts

Lines changed: 144 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -7,127 +7,165 @@ const action: ActionDefinition<Settings, Payload> = {
77
title: 'Merge Users',
88
description:
99
'Merge one identified user into another identified user. The merge will occur asynchronously and can take between 5-10 minutes.',
10+
defaultSubscription: 'type = "alias"',
1011
fields: {
11-
identifier_to_merge: {
12-
label: 'Identifier to Merge',
12+
previousIdType: {
13+
label: 'Type of Identifier to merge',
1314
description:
14-
'User identifier for the user to be merged (the user to be deprecated). Must specify one of: External ID, User Alias, Braze ID, Email, or Phone. See [the docs](https://www.braze.com/docs/api/endpoints/user_data/post_users_merge/).',
15-
type: 'object',
15+
'The type of identifier for the user to be merged. One of: external_id, user_alias, braze_id, email, or phone.',
16+
type: 'string',
1617
required: true,
17-
defaultObjectUI: 'keyvalue',
18-
additionalProperties: false,
19-
properties: {
20-
external_id: {
21-
label: 'External ID',
22-
description: 'The external ID of the user to merge',
23-
type: 'string'
24-
},
25-
user_alias: {
26-
label: 'User Alias',
27-
description: 'The user alias object identifying the user to merge',
28-
type: 'object',
29-
properties: {
30-
alias_name: {
31-
label: 'Alias Name',
32-
type: 'string'
33-
},
34-
alias_label: {
35-
label: 'Alias Label',
36-
type: 'string'
37-
}
18+
choices: [
19+
{ label: 'External ID', value: 'external_id' },
20+
{ label: 'User Alias', value: 'user_alias' },
21+
{ label: 'Braze ID', value: 'braze_id' },
22+
{ label: 'Email', value: 'email' },
23+
{ label: 'Phone', value: 'phone' }
24+
],
25+
default: 'external_id'
26+
},
27+
previousIdValue: {
28+
label: 'ID value to merge',
29+
description: 'The value of the identifier for the user to be merged.',
30+
type: 'string',
31+
required: {
32+
match: 'all',
33+
conditions: [
34+
{
35+
fieldKey: 'previousIdType',
36+
operator: 'is_not',
37+
value: 'user_alias'
3838
}
39-
},
40-
braze_id: {
41-
label: 'Braze ID',
42-
description: 'The Braze ID of the user to merge',
43-
type: 'string'
44-
},
45-
email: {
46-
label: 'Email',
47-
description: 'The email address of the user to merge',
39+
]
40+
},
41+
depends_on: {
42+
match: 'all',
43+
conditions: [
44+
{
45+
fieldKey: 'previousIdType',
46+
operator: 'is_not',
47+
value: 'user_alias'
48+
}
49+
]
50+
},
51+
default: '$.previousId'
52+
},
53+
previousAliasIdValue: {
54+
label: 'User Alias value to merge',
55+
description: 'The value of the user alias identifier for the user to be merged. Required if the previous identifier type is user_alias.',
56+
type: 'object',
57+
required: {
58+
match: 'all',
59+
conditions: [
60+
{
61+
fieldKey: 'previousIdType',
62+
operator: 'is',
63+
value: 'user_alias'
64+
}
65+
]
66+
},
67+
depends_on: {
68+
match: 'all',
69+
conditions: [
70+
{
71+
fieldKey: 'previousIdType',
72+
operator: 'is',
73+
value: 'user_alias'
74+
}
75+
]
76+
},
77+
properties: {
78+
alias_label: {
79+
label: 'User Alias Label',
80+
description: 'The label of the user alias for the user to be merged.',
4881
type: 'string',
49-
format: 'email'
82+
required: true
5083
},
51-
phone: {
52-
label: 'Phone',
53-
description: 'The phone number of the user to merge in E.164 format (e.g., +14155552671)',
54-
type: 'string'
84+
alias_name: {
85+
label: 'User Alias Name',
86+
description: 'The name of the user alias for the user to be merged.',
87+
type: 'string',
88+
required: true
5589
}
5690
}
5791
},
58-
identifier_to_keep: {
59-
label: 'Identifier to Keep',
92+
keepIdType: {
93+
label: 'Type of Identifier to keep',
6094
description:
61-
'User identifier for the user to keep (the target user). Must specify one of: External ID, User Alias, Braze ID, Email, or Phone. See [the docs](https://www.braze.com/docs/api/endpoints/user_data/post_users_merge/).',
62-
type: 'object',
95+
'The type of identifier for the user to be kept. One of: external_id, user_alias, braze_id, email, or phone.',
96+
type: 'string',
6397
required: true,
64-
defaultObjectUI: 'keyvalue',
65-
additionalProperties: false,
66-
properties: {
67-
external_id: {
68-
label: 'External ID',
69-
description: 'The external ID of the user to keep',
70-
type: 'string',
71-
default: {
72-
'@path': '$.userId'
98+
choices: [
99+
{ label: 'External ID', value: 'external_id' },
100+
{ label: 'User Alias', value: 'user_alias' },
101+
{ label: 'Braze ID', value: 'braze_id' },
102+
{ label: 'Email', value: 'email' },
103+
{ label: 'Phone', value: 'phone' }
104+
],
105+
default: 'external_id'
106+
},
107+
keepIdValue: {
108+
label: 'ID value to keep',
109+
description: 'The value of the identifier for the user to be kept.',
110+
type: 'string',
111+
required: {
112+
match: 'all',
113+
conditions: [
114+
{
115+
fieldKey: 'keepIdType',
116+
operator: 'is_not',
117+
value: 'user_alias'
73118
}
74-
},
75-
user_alias: {
76-
label: 'User Alias',
77-
description: 'The user alias object identifying the user to keep',
78-
type: 'object',
79-
properties: {
80-
alias_name: {
81-
label: 'Alias Name',
82-
type: 'string'
83-
},
84-
alias_label: {
85-
label: 'Alias Label',
86-
type: 'string'
87-
}
119+
]
120+
},
121+
depends_on: {
122+
match: 'all',
123+
conditions: [
124+
{
125+
fieldKey: 'keepIdType',
126+
operator: 'is_not',
127+
value: 'user_alias'
88128
}
89-
},
90-
braze_id: {
91-
label: 'Braze ID',
92-
description: 'The Braze ID of the user to keep',
93-
type: 'string'
94-
},
95-
email: {
96-
label: 'Email',
97-
description: 'The email address of the user to keep',
98-
type: 'string',
99-
format: 'email'
100-
},
101-
phone: {
102-
label: 'Phone',
103-
description: 'The phone number of the user to keep in E.164 format (e.g., +14155552671)',
104-
type: 'string'
105-
}
129+
]
106130
},
107-
default: {
108-
external_id: {
109-
'@path': '$.userId'
110-
},
111-
braze_id: {
112-
'@if': {
113-
exists: { '@path': '$.context.traits.brazeId' }
114-
},
115-
then: { '@path': '$.context.traits.brazeId' },
116-
else: { '@path': '$.properties.brazeId' }
117-
},
118-
email: {
119-
'@if': {
120-
exists: { '@path': '$.context.traits.email' }
121-
},
122-
then: { '@path': '$.context.traits.email' },
123-
else: { '@path': '$.properties.email' }
131+
default: '$.userId'
132+
},
133+
keepAliasIdValue: {
134+
label: 'User Alias value to keep',
135+
description: 'The value of the user alias identifier for the user to be kept. Required if the keep identifier type is user_alias.',
136+
type: 'object',
137+
required: {
138+
match: 'all',
139+
conditions: [
140+
{
141+
fieldKey: 'keepIdType',
142+
operator: 'is',
143+
value: 'user_alias'
144+
}
145+
]
146+
},
147+
depends_on: {
148+
match: 'all',
149+
conditions: [
150+
{
151+
fieldKey: 'keepIdType',
152+
operator: 'is',
153+
value: 'user_alias'
154+
}
155+
]
156+
},
157+
properties: {
158+
alias_label: {
159+
label: 'User Alias Label',
160+
description: 'The label of the user alias for the user to be kept.',
161+
type: 'string',
162+
required: true
124163
},
125-
phone: {
126-
'@if': {
127-
exists: { '@path': '$.context.traits.phone' }
128-
},
129-
then: { '@path': '$.context.traits.phone' },
130-
else: { '@path': '$.properties.phone' }
164+
alias_name: {
165+
label: 'User Alias Name',
166+
description: 'The name of the user alias for the user to be kept.',
167+
type: 'string',
168+
required: true
131169
}
132170
}
133171
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export type MergeUsersJSON = {
2+
identifier_to_merge: {
3+
// Only one of the following
4+
external_id?: string
5+
user_alias?: {
6+
alias_label: string
7+
alias_name: string
8+
}
9+
braze_id?: string
10+
email?: string
11+
phone?: string
12+
}
13+
identifier_to_keep: {
14+
// Only one of the following
15+
external_id?: string
16+
user_alias?: {
17+
alias_label: string
18+
alias_name: string
19+
}
20+
braze_id?: string
21+
email?: string
22+
phone?: string
23+
}
24+
}
25+
26+
export type MergeIdentifierType = 'external_id' | 'user_alias' | 'braze_id' | 'email' | 'phone'

packages/destination-actions/src/destinations/braze/userAlias.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface UserAlias {
1+
export interface UserAlias {
22
alias_name: string
33
alias_label: string
44
}

0 commit comments

Comments
 (0)