Skip to content

Commit 32c0de3

Browse files
author
Dr.J
committed
Align Customer.io preset subscriptions with reserved events
1 parent 42598d2 commit 32c0de3

4 files changed

Lines changed: 105 additions & 3 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import destination from '../index'
2+
3+
describe('customerio presets', () => {
4+
it('includes the generic automatic lifecycle presets', () => {
5+
const automaticPresetNames = destination.presets
6+
?.filter((preset) => preset.type === 'automatic')
7+
.map((preset) => preset.name)
8+
9+
expect(automaticPresetNames).toEqual(
10+
expect.arrayContaining([
11+
'Delete Device',
12+
'Delete Relationship',
13+
'Delete Person',
14+
'Delete Object',
15+
'Merge People',
16+
'Suppress Person',
17+
'Unsuppress Person'
18+
])
19+
)
20+
})
21+
22+
it('includes Device Created or Updated in the create/update device subscriptions', () => {
23+
const preset = destination.presets?.find((candidate) => candidate.name === 'Create or Update Device')
24+
25+
expect(preset?.subscribe).toContain('Device Created or Updated')
26+
expect(destination.actions.createUpdateDevice.defaultSubscription).toContain('Device Created or Updated')
27+
})
28+
29+
it('excludes reserved device and object events from the generic track event surface', () => {
30+
const preset = destination.presets?.find((candidate) => candidate.name === 'Track Event')
31+
32+
expect(preset?.subscribe).toContain('event != "Device Created or Updated"')
33+
expect(preset?.subscribe).toContain('event != "Device Deleted"')
34+
expect(destination.actions.trackEvent.defaultSubscription).toContain('event != "Device Created or Updated"')
35+
expect(destination.actions.trackEvent.defaultSubscription).toContain('event != "Device Deleted"')
36+
expect(destination.actions.trackEvent.defaultSubscription).toContain('event != "Object Deleted"')
37+
})
38+
})

packages/destination-actions/src/destinations/customerio/createUpdateDevice/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { eventProperties } from '../customerio-properties'
77
const action: ActionDefinition<Settings, Payload> = {
88
title: 'Create or Update Device',
99
description: `Create or update a person's device.`,
10-
defaultSubscription: 'type = "track" and event = "Application Installed"',
10+
defaultSubscription:
11+
'event = "Application Installed" or event = "Application Opened" or event = "Device Created or Updated"',
1112
fields: {
1213
person_id: {
1314
label: 'Person ID',

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

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,52 @@ const destination: DestinationDefinition<Settings> = {
8888
},
8989
{
9090
name: 'Create or Update Device',
91-
subscribe: 'event = "Application Installed" or event = "Application Opened"',
91+
subscribe: `
92+
event = "Application Installed"
93+
or event = "Application Opened"
94+
or event = "Device Created or Updated"
95+
`,
9296
partnerAction: 'createUpdateDevice',
9397
mapping: defaultValues(createUpdateDevice.fields),
9498
type: 'automatic'
9599
},
100+
{
101+
name: 'Delete Device',
102+
subscribe: 'event = "Application Uninstalled" or event = "Device Deleted"',
103+
partnerAction: 'deleteDevice',
104+
mapping: defaultValues(deleteDevice.fields),
105+
type: 'automatic'
106+
},
107+
{
108+
name: 'Delete Relationship',
109+
subscribe: 'event = "Relationship Deleted"',
110+
partnerAction: 'deleteRelationship',
111+
mapping: defaultValues(deleteRelationship.fields),
112+
type: 'automatic'
113+
},
114+
{
115+
name: 'Delete Person',
116+
subscribe: 'event = "User Deleted"',
117+
partnerAction: 'deletePerson',
118+
mapping: defaultValues(deletePerson.fields),
119+
type: 'automatic'
120+
},
121+
{
122+
name: 'Delete Object',
123+
subscribe: 'event = "Object Deleted"',
124+
partnerAction: 'deleteObject',
125+
mapping: defaultValues(deleteObject.fields),
126+
type: 'automatic'
127+
},
96128
{
97129
name: 'Track Event',
98130
subscribe: `
99131
type = "track"
132+
and event != "Application Installed"
133+
and event != "Application Opened"
134+
and event != "Application Uninstalled"
135+
and event != "Device Created or Updated"
136+
and event != "Device Deleted"
100137
and event != "Relationship Deleted"
101138
and event != "User Deleted"
102139
and event != "User Suppressed"
@@ -130,6 +167,27 @@ const destination: DestinationDefinition<Settings> = {
130167
mapping: defaultValues(createUpdateObject.fields),
131168
type: 'automatic'
132169
},
170+
{
171+
name: 'Merge People',
172+
subscribe: 'type = "alias"',
173+
partnerAction: 'mergePeople',
174+
mapping: defaultValues(mergePeople.fields),
175+
type: 'automatic'
176+
},
177+
{
178+
name: 'Suppress Person',
179+
subscribe: 'event = "User Suppressed"',
180+
partnerAction: 'suppressPerson',
181+
mapping: defaultValues(suppressPerson.fields),
182+
type: 'automatic'
183+
},
184+
{
185+
name: 'Unsuppress Person',
186+
subscribe: 'event = "User Unsuppressed"',
187+
partnerAction: 'unsuppressPerson',
188+
mapping: defaultValues(unsuppressPerson.fields),
189+
type: 'automatic'
190+
},
133191
{
134192
name: 'Report Delivery Event',
135193
subscribe: 'event = "Report Delivery Event"',

packages/destination-actions/src/destinations/customerio/trackEvent/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ const action: ActionDefinition<Settings, Payload> = {
99
description: 'Track an event for a known or anonymous person.',
1010
defaultSubscription: `
1111
type = "track"
12+
and event != "Application Installed"
13+
and event != "Application Opened"
14+
and event != "Application Uninstalled"
15+
and event != "Device Created or Updated"
16+
and event != "Device Deleted"
1217
and event != "Relationship Deleted"
1318
and event != "User Deleted"
1419
and event != "User Suppressed"
1520
and event != "User Unsuppressed"
16-
and event != "Group Deleted"
21+
and event != "Object Deleted"
1722
and event != "Report Delivery Event"
1823
`,
1924
fields: {

0 commit comments

Comments
 (0)