Skip to content

Commit 6b92809

Browse files
monutwilionick-Ag
authored andcommitted
Stratconn 6002 braze canvas trigger (#3039)
* added trigger canvas action * added depends_on * added error reporting * added required condition on recipients * fix import * remove broadcast default * remove depends on * added tests * refactor * minor fixes
1 parent 65d2fe3 commit 6b92809

File tree

8 files changed

+1552
-1
lines changed

8 files changed

+1552
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import trackEvent2 from './trackEvent2'
1212
import trackPurchase2 from './trackPurchase2'
1313
import updateUserProfile2 from './updateUserProfile2'
1414
import triggerCampaign from './triggerCampaign'
15+
import triggerCanvas from './triggerCanvas'
1516

1617
import upsertCatalogItem from './upsertCatalogItem'
1718

@@ -89,7 +90,8 @@ const destination: DestinationDefinition<Settings> = {
8990
updateUserProfile2,
9091
createAlias2,
9192
upsertCatalogItem,
92-
triggerCampaign
93+
triggerCampaign,
94+
triggerCanvas
9395
},
9496
presets: [
9597
{
@@ -137,6 +139,13 @@ const destination: DestinationDefinition<Settings> = {
137139
type: 'specificEvent',
138140
eventSlug: 'warehouse_entity_removed_track'
139141
},
142+
{
143+
name: 'Trigger Canvas',
144+
subscribe: 'type = "track" and event = "Trigger Canvas"',
145+
partnerAction: 'triggerCanvas',
146+
mapping: defaultValues(triggerCanvas.fields),
147+
type: 'automatic'
148+
},
140149
{
141150
name: 'Entities Audience Entered',
142151
partnerAction: 'trackEvent',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Testing snapshot for Braze's triggerCanvas destination action: all fields 1`] = `
4+
Object {
5+
"canvas_entry_properties": Object {
6+
"testType": "jjoQf0&!",
7+
},
8+
"canvas_id": "jjoQf0&!",
9+
"recipients": Array [
10+
Object {
11+
"attributes": Object {
12+
"testType": "jjoQf0&!",
13+
},
14+
"canvas_entry_properties": Object {
15+
"testType": "jjoQf0&!",
16+
},
17+
"email": "[email protected]",
18+
"external_user_id": "jjoQf0&!",
19+
"prioritization": Array [
20+
"identified",
21+
"identified",
22+
],
23+
"send_to_existing_only": true,
24+
"user_alias": Object {
25+
"alias_label": "test-alias-label",
26+
"alias_name": "test-alias",
27+
},
28+
},
29+
],
30+
}
31+
`;
32+
33+
exports[`Testing snapshot for Braze's triggerCanvas destination action: all fields 2`] = `
34+
Headers {
35+
Symbol(map): Object {
36+
"authorization": Array [
37+
"Bearer jjoQf0&!",
38+
],
39+
"content-type": Array [
40+
"application/json",
41+
],
42+
"user-agent": Array [
43+
"Segment (Actions)",
44+
],
45+
},
46+
}
47+
`;
48+
49+
exports[`Testing snapshot for Braze's triggerCanvas destination action: required fields 1`] = `
50+
Object {
51+
"canvas_id": "jjoQf0&!",
52+
"recipients": Array [
53+
Object {
54+
"external_user_id": "test-user-123",
55+
"send_to_existing_only": true,
56+
},
57+
],
58+
}
59+
`;
60+
61+
exports[`Testing snapshot for Braze's triggerCanvas destination action: required fields 2`] = `
62+
Headers {
63+
Symbol(map): Object {
64+
"authorization": Array [
65+
"Bearer jjoQf0&!",
66+
],
67+
"content-type": Array [
68+
"application/json",
69+
],
70+
"user-agent": Array [
71+
"Segment (Actions)",
72+
],
73+
},
74+
}
75+
`;
76+
77+
exports[`Testing snapshot for Braze's triggerCanvas destination action: with audience object 1`] = `
78+
Object {
79+
"audience": Object {
80+
"AND": Array [
81+
Object {
82+
"custom_attribute": Object {
83+
"attribute_name": "eye_color",
84+
"comparison": "equals",
85+
"value": "blue",
86+
},
87+
},
88+
Object {
89+
"custom_attribute": Object {
90+
"attribute_name": "age",
91+
"comparison": "greater_than",
92+
"value": 30,
93+
},
94+
},
95+
],
96+
},
97+
"broadcast": true,
98+
"canvas_entry_properties": Object {
99+
"testType": "jjoQf0&!",
100+
},
101+
"canvas_id": "jjoQf0&!",
102+
"prioritization": Object {
103+
"first_priority": "identified",
104+
"second_priority": "identified",
105+
},
106+
}
107+
`;
108+
109+
exports[`Testing snapshot for Braze's triggerCanvas destination action: with audience object 2`] = `
110+
Headers {
111+
Symbol(map): Object {
112+
"authorization": Array [
113+
"Bearer jjoQf0&!",
114+
],
115+
"content-type": Array [
116+
"application/json",
117+
],
118+
"user-agent": Array [
119+
"Segment (Actions)",
120+
],
121+
},
122+
}
123+
`;
124+
125+
exports[`Testing snapshot for Braze's triggerCanvas destination action: with canvas entry properties 1`] = `
126+
Object {
127+
"canvas_entry_properties": Object {
128+
"discount_amount": 25,
129+
"product_name": "Test Product",
130+
"user_tier": "premium",
131+
},
132+
"canvas_id": "jjoQf0&!",
133+
"recipients": Array [
134+
Object {
135+
"attributes": Object {
136+
"testType": "jjoQf0&!",
137+
},
138+
"canvas_entry_properties": Object {
139+
"testType": "jjoQf0&!",
140+
},
141+
"email": "[email protected]",
142+
"external_user_id": "jjoQf0&!",
143+
"prioritization": Array [
144+
"identified",
145+
"identified",
146+
],
147+
"send_to_existing_only": true,
148+
"user_alias": Object {},
149+
},
150+
],
151+
}
152+
`;
153+
154+
exports[`Testing snapshot for Braze's triggerCanvas destination action: with canvas entry properties 2`] = `
155+
Headers {
156+
Symbol(map): Object {
157+
"authorization": Array [
158+
"Bearer jjoQf0&!",
159+
],
160+
"content-type": Array [
161+
"application/json",
162+
],
163+
"user-agent": Array [
164+
"Segment (Actions)",
165+
],
166+
},
167+
}
168+
`;
169+
170+
exports[`Testing snapshot for Braze's triggerCanvas destination action: with prioritization 1`] = `
171+
Object {
172+
"canvas_entry_properties": Object {
173+
"testType": "jjoQf0&!",
174+
},
175+
"canvas_id": "jjoQf0&!",
176+
"recipients": Array [
177+
Object {
178+
"email": "[email protected]",
179+
"external_user_id": "user-123",
180+
"prioritization": Array [
181+
"identified",
182+
"most_recently_updated",
183+
],
184+
"send_to_existing_only": true,
185+
},
186+
],
187+
}
188+
`;
189+
190+
exports[`Testing snapshot for Braze's triggerCanvas destination action: with prioritization 2`] = `
191+
Headers {
192+
Symbol(map): Object {
193+
"authorization": Array [
194+
"Bearer jjoQf0&!",
195+
],
196+
"content-type": Array [
197+
"application/json",
198+
],
199+
"user-agent": Array [
200+
"Segment (Actions)",
201+
],
202+
},
203+
}
204+
`;
205+
206+
exports[`Testing snapshot for Braze's triggerCanvas destination action: with recipients array 1`] = `
207+
Object {
208+
"canvas_entry_properties": Object {
209+
"testType": "jjoQf0&!",
210+
},
211+
"canvas_id": "jjoQf0&!",
212+
"recipients": Array [
213+
Object {
214+
"canvas_entry_properties": Object {
215+
"customData": "test",
216+
"name": "John Doe",
217+
},
218+
"email": "[email protected]",
219+
"external_user_id": "user-123",
220+
"prioritization": Array [
221+
"identified",
222+
"identified",
223+
],
224+
"send_to_existing_only": true,
225+
},
226+
Object {
227+
"email": "[email protected]",
228+
"external_user_id": "user-456",
229+
"prioritization": Array [
230+
"identified",
231+
"identified",
232+
],
233+
"send_to_existing_only": true,
234+
},
235+
],
236+
}
237+
`;
238+
239+
exports[`Testing snapshot for Braze's triggerCanvas destination action: with recipients array 2`] = `
240+
Headers {
241+
Symbol(map): Object {
242+
"authorization": Array [
243+
"Bearer jjoQf0&!",
244+
],
245+
"content-type": Array [
246+
"application/json",
247+
],
248+
"user-agent": Array [
249+
"Segment (Actions)",
250+
],
251+
},
252+
}
253+
`;

0 commit comments

Comments
 (0)