@segment/action-destinations 3.71.1-alpha.2 → 3.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/gainsight-px-cloud-action/index.js +30 -36
- package/dist/destinations/gainsight-px-cloud-action/index.js.map +1 -1
- package/dist/destinations/gainsight-px-cloud-action/regional-endpoints.js +3 -3
- package/dist/destinations/gainsight-px-cloud-action/regional-endpoints.js.map +1 -1
- package/dist/destinations/gainsight-px-cloud-action/sendEvent/generated-types.d.ts +5 -0
- package/dist/destinations/gainsight-px-cloud-action/{groupIdentify → sendEvent}/generated-types.js +0 -0
- package/dist/destinations/gainsight-px-cloud-action/sendEvent/generated-types.js.map +1 -0
- package/dist/destinations/gainsight-px-cloud-action/{identifyUser → sendEvent}/index.d.ts +0 -0
- package/dist/destinations/gainsight-px-cloud-action/{groupIdentify → sendEvent}/index.js +5 -5
- package/dist/destinations/gainsight-px-cloud-action/sendEvent/index.js.map +1 -0
- package/dist/destinations/index.js +1 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/personas-messaging-twilio/generated-types.d.ts +3 -2
- package/dist/destinations/personas-messaging-twilio/index.js +12 -6
- package/dist/destinations/personas-messaging-twilio/index.js.map +1 -1
- package/dist/destinations/personas-messaging-twilio/sendSms/index.js +2 -2
- package/dist/destinations/personas-messaging-twilio/sendSms/index.js.map +1 -1
- package/dist/destinations/salesforce/account/index.js +4 -0
- package/dist/destinations/salesforce/account/index.js.map +1 -1
- package/dist/destinations/salesforce/cases/index.js +5 -0
- package/dist/destinations/salesforce/cases/index.js.map +1 -1
- package/dist/destinations/salesforce/contact/index.js +9 -3
- package/dist/destinations/salesforce/contact/index.js.map +1 -1
- package/dist/destinations/salesforce/customObject/index.d.ts +1 -1
- package/dist/destinations/salesforce/customObject/index.js +5 -0
- package/dist/destinations/salesforce/customObject/index.js.map +1 -1
- package/dist/destinations/salesforce/lead/index.js +4 -0
- package/dist/destinations/salesforce/lead/index.js.map +1 -1
- package/dist/destinations/salesforce/opportunity/index.js +3 -2
- package/dist/destinations/salesforce/opportunity/index.js.map +1 -1
- package/dist/destinations/salesforce/sf-utils.js +2 -6
- package/dist/destinations/salesforce/sf-utils.js.map +1 -1
- package/dist/destinations/snap-conversions-api/_tests_/index.test.d.ts +1 -0
- package/dist/destinations/snap-conversions-api/_tests_/index.test.js +204 -0
- package/dist/destinations/snap-conversions-api/_tests_/index.test.js.map +1 -0
- package/dist/destinations/snap-conversions-api/generated-types.d.ts +5 -0
- package/dist/destinations/{gainsight-px-cloud-action/identifyUser → snap-conversions-api}/generated-types.js +0 -0
- package/dist/destinations/snap-conversions-api/generated-types.js.map +1 -0
- package/dist/destinations/snap-conversions-api/index.d.ts +4 -0
- package/dist/destinations/snap-conversions-api/index.js +189 -0
- package/dist/destinations/snap-conversions-api/index.js.map +1 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/generated-types.d.ts +25 -0
- package/dist/destinations/{gainsight-px-cloud-action/trackEvent → snap-conversions-api/reportConversionEvent}/generated-types.js +0 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/generated-types.js.map +1 -0
- package/dist/destinations/{gainsight-px-cloud-action/trackEvent → snap-conversions-api/reportConversionEvent}/index.d.ts +1 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js +50 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js.map +1 -0
- package/dist/destinations/snap-conversions-api/snap-capi-properties.d.ts +30 -0
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js +310 -0
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js.map +1 -0
- package/dist/destinations/talon-one/t1-properties.js +10 -4
- package/dist/destinations/talon-one/t1-properties.js.map +1 -1
- package/dist/destinations/talon-one/trackEvent/index.js +10 -2
- package/dist/destinations/talon-one/trackEvent/index.js.map +1 -1
- package/dist/destinations/talon-one/updateCustomerProfile/index.js +1 -1
- package/dist/destinations/talon-one/updateCustomerProfile/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/destinations/gainsight-px-cloud-action/groupIdentify/generated-types.d.ts +0 -2
- package/dist/destinations/gainsight-px-cloud-action/groupIdentify/generated-types.js.map +0 -1
- package/dist/destinations/gainsight-px-cloud-action/groupIdentify/index.d.ts +0 -5
- package/dist/destinations/gainsight-px-cloud-action/groupIdentify/index.js.map +0 -1
- package/dist/destinations/gainsight-px-cloud-action/identifyUser/generated-types.d.ts +0 -2
- package/dist/destinations/gainsight-px-cloud-action/identifyUser/generated-types.js.map +0 -1
- package/dist/destinations/gainsight-px-cloud-action/identifyUser/index.js +0 -17
- package/dist/destinations/gainsight-px-cloud-action/identifyUser/index.js.map +0 -1
- package/dist/destinations/gainsight-px-cloud-action/trackEvent/generated-types.d.ts +0 -2
- package/dist/destinations/gainsight-px-cloud-action/trackEvent/generated-types.js.map +0 -1
- package/dist/destinations/gainsight-px-cloud-action/trackEvent/index.js +0 -17
- package/dist/destinations/gainsight-px-cloud-action/trackEvent/index.js.map +0 -1
- package/dist/destinations/gainsight-px-cloud-action/trackPageView/generated-types.d.ts +0 -2
- package/dist/destinations/gainsight-px-cloud-action/trackPageView/generated-types.js +0 -3
- package/dist/destinations/gainsight-px-cloud-action/trackPageView/generated-types.js.map +0 -1
- package/dist/destinations/gainsight-px-cloud-action/trackPageView/index.d.ts +0 -5
- package/dist/destinations/gainsight-px-cloud-action/trackPageView/index.js +0 -17
- package/dist/destinations/gainsight-px-cloud-action/trackPageView/index.js.map +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const nock_1 = __importDefault(require("nock"));
|
|
7
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
+
const index_1 = __importDefault(require("../index"));
|
|
9
|
+
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
10
|
+
const timestamp = '2022-05-12T15:21:15.449Z';
|
|
11
|
+
const settings = {
|
|
12
|
+
snap_app_id: 'test123',
|
|
13
|
+
pixel_id: 'test123',
|
|
14
|
+
app_id: 'test123'
|
|
15
|
+
};
|
|
16
|
+
const accessToken = 'test123';
|
|
17
|
+
const refreshToken = 'test123';
|
|
18
|
+
const testEvent = actions_core_1.createTestEvent({
|
|
19
|
+
timestamp: timestamp,
|
|
20
|
+
messageId: 'test-message-rv4t40s898k',
|
|
21
|
+
event: 'PURCHASE',
|
|
22
|
+
type: 'track',
|
|
23
|
+
properties: {
|
|
24
|
+
email: 'test123@gmail.com',
|
|
25
|
+
phone: '+44 844 412 4653',
|
|
26
|
+
event_tag: 'back-to-school',
|
|
27
|
+
number_items: 10,
|
|
28
|
+
price: '15',
|
|
29
|
+
currency: 'USD',
|
|
30
|
+
level: 3
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const conversionEventUrl = 'https://tr.snapchat.com/v2/conversion';
|
|
34
|
+
describe('Snap Conversions API ', () => {
|
|
35
|
+
describe('ReportConversionEvent', () => {
|
|
36
|
+
it('should handle a basic event', async () => {
|
|
37
|
+
nock_1.default(conversionEventUrl).post('').reply(200, {});
|
|
38
|
+
const event = actions_core_1.createTestEvent(testEvent);
|
|
39
|
+
const responses = await testDestination.testAction('reportConversionEvent', {
|
|
40
|
+
event,
|
|
41
|
+
settings,
|
|
42
|
+
useDefaultMappings: true,
|
|
43
|
+
auth: {
|
|
44
|
+
accessToken,
|
|
45
|
+
refreshToken
|
|
46
|
+
},
|
|
47
|
+
mapping: {
|
|
48
|
+
event_type: 'PURCHASE',
|
|
49
|
+
event_conversion_type: 'WEB'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
expect(responses).not.toBeNull();
|
|
53
|
+
expect(responses[0].status).toBe(200);
|
|
54
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"event_type\\":\\"PURCHASE\\",\\"event_conversion_type\\":\\"WEB\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"pixel_id\\":\\"test123\\"}"`);
|
|
55
|
+
});
|
|
56
|
+
it('should fail web event without pixel_id', async () => {
|
|
57
|
+
nock_1.default(conversionEventUrl).post('').reply(400, {});
|
|
58
|
+
const event = actions_core_1.createTestEvent(testEvent);
|
|
59
|
+
await expect(testDestination.testAction('reportConversionEvent', {
|
|
60
|
+
event,
|
|
61
|
+
settings: {
|
|
62
|
+
app_id: 'test123'
|
|
63
|
+
},
|
|
64
|
+
useDefaultMappings: true,
|
|
65
|
+
auth: {
|
|
66
|
+
accessToken,
|
|
67
|
+
refreshToken
|
|
68
|
+
},
|
|
69
|
+
mapping: {
|
|
70
|
+
event_type: 'PURCHASE',
|
|
71
|
+
event_conversion_type: 'WEB'
|
|
72
|
+
}
|
|
73
|
+
})).rejects.toThrowError('If event conversion type is "WEB" then pixel_id must be defined');
|
|
74
|
+
});
|
|
75
|
+
it('should fail web event without snap_app_id', async () => {
|
|
76
|
+
nock_1.default(conversionEventUrl).post('').reply(400, {});
|
|
77
|
+
const event = actions_core_1.createTestEvent(testEvent);
|
|
78
|
+
await expect(testDestination.testAction('reportConversionEvent', {
|
|
79
|
+
event,
|
|
80
|
+
settings: {
|
|
81
|
+
pixel_id: 'test123',
|
|
82
|
+
app_id: 'test123'
|
|
83
|
+
},
|
|
84
|
+
useDefaultMappings: true,
|
|
85
|
+
auth: {
|
|
86
|
+
accessToken,
|
|
87
|
+
refreshToken
|
|
88
|
+
},
|
|
89
|
+
mapping: {
|
|
90
|
+
event_type: 'PURCHASE',
|
|
91
|
+
event_conversion_type: 'MOBILE_APP'
|
|
92
|
+
}
|
|
93
|
+
})).rejects.toThrowError('If event conversion type is "MOBILE_APP" then snap_app_id and app_id must be defined');
|
|
94
|
+
});
|
|
95
|
+
it('should handle an offline event conversion type', async () => {
|
|
96
|
+
nock_1.default(conversionEventUrl).post('').reply(200, {});
|
|
97
|
+
const event = actions_core_1.createTestEvent(testEvent);
|
|
98
|
+
const responses = await testDestination.testAction('reportConversionEvent', {
|
|
99
|
+
event,
|
|
100
|
+
settings,
|
|
101
|
+
useDefaultMappings: true,
|
|
102
|
+
auth: {
|
|
103
|
+
accessToken,
|
|
104
|
+
refreshToken
|
|
105
|
+
},
|
|
106
|
+
mapping: {
|
|
107
|
+
event_type: 'SAVE',
|
|
108
|
+
event_conversion_type: 'OFFLINE'
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
expect(responses).not.toBeNull();
|
|
112
|
+
expect(responses[0].status).toBe(200);
|
|
113
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"event_type\\":\\"SAVE\\",\\"event_conversion_type\\":\\"OFFLINE\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"pixel_id\\":\\"test123\\"}"`);
|
|
114
|
+
});
|
|
115
|
+
it('should handle a mobile app event conversion type', async () => {
|
|
116
|
+
nock_1.default(conversionEventUrl).post('').reply(200, {});
|
|
117
|
+
const event = actions_core_1.createTestEvent(testEvent);
|
|
118
|
+
const responses = await testDestination.testAction('reportConversionEvent', {
|
|
119
|
+
event,
|
|
120
|
+
settings: {
|
|
121
|
+
snap_app_id: '123',
|
|
122
|
+
app_id: '123'
|
|
123
|
+
},
|
|
124
|
+
useDefaultMappings: true,
|
|
125
|
+
auth: {
|
|
126
|
+
accessToken,
|
|
127
|
+
refreshToken
|
|
128
|
+
},
|
|
129
|
+
mapping: {
|
|
130
|
+
event_type: 'SAVE',
|
|
131
|
+
event_conversion_type: 'MOBILE_APP'
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
expect(responses).not.toBeNull();
|
|
135
|
+
expect(responses[0].status).toBe(200);
|
|
136
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"event_type\\":\\"SAVE\\",\\"event_conversion_type\\":\\"MOBILE_APP\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"snap_app_id\\":\\"123\\",\\"app_id\\":\\"123\\"}"`);
|
|
137
|
+
});
|
|
138
|
+
it('should fail invalid currency', async () => {
|
|
139
|
+
nock_1.default(conversionEventUrl).post('').reply(400, {});
|
|
140
|
+
const event = actions_core_1.createTestEvent({
|
|
141
|
+
...testEvent,
|
|
142
|
+
properties: {
|
|
143
|
+
currency: 'Galleon'
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
await expect(testDestination.testAction('reportConversionEvent', {
|
|
147
|
+
event,
|
|
148
|
+
settings,
|
|
149
|
+
useDefaultMappings: true,
|
|
150
|
+
auth: {
|
|
151
|
+
accessToken,
|
|
152
|
+
refreshToken
|
|
153
|
+
},
|
|
154
|
+
mapping: {
|
|
155
|
+
event_type: 'PURCHASE',
|
|
156
|
+
event_conversion_type: 'WEB'
|
|
157
|
+
}
|
|
158
|
+
})).rejects.toThrowError('Galleon is not a valid currency code.');
|
|
159
|
+
});
|
|
160
|
+
it('should fail missing event conversion type', async () => {
|
|
161
|
+
nock_1.default(conversionEventUrl).post('').reply(400, {});
|
|
162
|
+
const event = actions_core_1.createTestEvent(testEvent);
|
|
163
|
+
await expect(testDestination.testAction('reportConversionEvent', {
|
|
164
|
+
event,
|
|
165
|
+
settings,
|
|
166
|
+
useDefaultMappings: true,
|
|
167
|
+
auth: {
|
|
168
|
+
accessToken,
|
|
169
|
+
refreshToken
|
|
170
|
+
},
|
|
171
|
+
mapping: {
|
|
172
|
+
event_type: 'PURCHASE'
|
|
173
|
+
}
|
|
174
|
+
})).rejects.toThrowError("The root value is missing the required field 'event_conversion_type'.");
|
|
175
|
+
});
|
|
176
|
+
it('should handle a custom event', async () => {
|
|
177
|
+
nock_1.default(conversionEventUrl).post('').reply(200, {});
|
|
178
|
+
const event = actions_core_1.createTestEvent({
|
|
179
|
+
...testEvent,
|
|
180
|
+
event: 'CUSTOM_EVENT_5'
|
|
181
|
+
});
|
|
182
|
+
const responses = await testDestination.testAction('reportConversionEvent', {
|
|
183
|
+
event,
|
|
184
|
+
settings: {
|
|
185
|
+
snap_app_id: '123',
|
|
186
|
+
app_id: '123'
|
|
187
|
+
},
|
|
188
|
+
useDefaultMappings: true,
|
|
189
|
+
auth: {
|
|
190
|
+
accessToken,
|
|
191
|
+
refreshToken
|
|
192
|
+
},
|
|
193
|
+
mapping: {
|
|
194
|
+
event_type: { '@path': '$.event' },
|
|
195
|
+
event_conversion_type: 'MOBILE_APP'
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
expect(responses).not.toBeNull();
|
|
199
|
+
expect(responses[0].status).toBe(200);
|
|
200
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"event_type\\":\\"CUSTOM_EVENT_5\\",\\"event_conversion_type\\":\\"MOBILE_APP\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"snap_app_id\\":\\"123\\",\\"app_id\\":\\"123\\"}"`);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../../src/destinations/snap-conversions-api/_tests_/index.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAA8E;AAC9E,qDAAiC;AAGjC,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAU,CAAC,CAAA;AACzD,MAAM,SAAS,GAAG,0BAA0B,CAAA;AAC5C,MAAM,QAAQ,GAAa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,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAErC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,CACrD,0rBAA0rB,CAC3rB,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/snap-conversions-api/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
7
|
+
const reportConversionEvent_1 = __importDefault(require("./reportConversionEvent"));
|
|
8
|
+
const DEFAULT_VALS = {
|
|
9
|
+
...actions_core_1.defaultValues(reportConversionEvent_1.default.fields)
|
|
10
|
+
};
|
|
11
|
+
const ACCESS_TOKEN_URL = 'https://accounts.snapchat.com/login/oauth2/access_token';
|
|
12
|
+
const presets = [
|
|
13
|
+
{
|
|
14
|
+
name: 'Add Billing',
|
|
15
|
+
subscribe: 'event = "Payment Info Entered"',
|
|
16
|
+
partnerAction: 'reportConversionEvent',
|
|
17
|
+
mapping: {
|
|
18
|
+
...DEFAULT_VALS,
|
|
19
|
+
event_type: 'ADD_BILLING'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Add to Cart',
|
|
24
|
+
subscribe: 'event = "Product Added"',
|
|
25
|
+
partnerAction: 'reportConversionEvent',
|
|
26
|
+
mapping: {
|
|
27
|
+
...DEFAULT_VALS,
|
|
28
|
+
event_type: 'ADD_CART'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Add to Wishlist',
|
|
33
|
+
subscribe: 'event = "Product Added to Wishlist"',
|
|
34
|
+
partnerAction: 'reportConversionEvent',
|
|
35
|
+
mapping: {
|
|
36
|
+
...DEFAULT_VALS,
|
|
37
|
+
event_type: 'ADD_TO_WISHLIST'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'App Install',
|
|
42
|
+
subscribe: 'event = "Application Installed"',
|
|
43
|
+
partnerAction: 'reportConversionEvent',
|
|
44
|
+
mapping: {
|
|
45
|
+
...DEFAULT_VALS,
|
|
46
|
+
event_type: 'APP_INSTALL'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'List View',
|
|
51
|
+
subscribe: 'event = "Product List Viewed"',
|
|
52
|
+
partnerAction: 'reportConversionEvent',
|
|
53
|
+
mapping: {
|
|
54
|
+
...DEFAULT_VALS,
|
|
55
|
+
event_type: 'LIST_VIEW'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'App Open',
|
|
60
|
+
subscribe: 'event = "Application Opened"',
|
|
61
|
+
partnerAction: 'reportConversionEvent',
|
|
62
|
+
mapping: {
|
|
63
|
+
...DEFAULT_VALS,
|
|
64
|
+
event_type: 'APP_OPEN'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'Login',
|
|
69
|
+
subscribe: 'event = "Signed In"',
|
|
70
|
+
partnerAction: 'reportConversionEvent',
|
|
71
|
+
mapping: {
|
|
72
|
+
...DEFAULT_VALS,
|
|
73
|
+
event_type: 'LOGIN'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Page View',
|
|
78
|
+
subscribe: 'type = "page"',
|
|
79
|
+
partnerAction: 'reportConversionEvent',
|
|
80
|
+
mapping: {
|
|
81
|
+
...DEFAULT_VALS,
|
|
82
|
+
event_type: 'PAGE_VIEW'
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'Purchase',
|
|
87
|
+
subscribe: 'event = "Order Completed"',
|
|
88
|
+
partnerAction: 'reportConversionEvent',
|
|
89
|
+
mapping: {
|
|
90
|
+
...DEFAULT_VALS,
|
|
91
|
+
event_type: 'PURCHASE'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'Search',
|
|
96
|
+
subscribe: 'event = "Products Searched"',
|
|
97
|
+
partnerAction: 'reportConversionEvent',
|
|
98
|
+
mapping: {
|
|
99
|
+
...DEFAULT_VALS,
|
|
100
|
+
event_type: 'SEARCH'
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'Share',
|
|
105
|
+
subscribe: 'event = "Product Shared"',
|
|
106
|
+
partnerAction: 'reportConversionEvent',
|
|
107
|
+
mapping: {
|
|
108
|
+
...DEFAULT_VALS,
|
|
109
|
+
event_type: 'SHARE'
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'Sign Up',
|
|
114
|
+
subscribe: 'event = "Signed Up"',
|
|
115
|
+
partnerAction: 'reportConversionEvent',
|
|
116
|
+
mapping: {
|
|
117
|
+
...DEFAULT_VALS,
|
|
118
|
+
event_type: 'SIGN_UP'
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'Start Checkout',
|
|
123
|
+
subscribe: 'event = "Checkout Started"',
|
|
124
|
+
partnerAction: 'reportConversionEvent',
|
|
125
|
+
mapping: {
|
|
126
|
+
...DEFAULT_VALS,
|
|
127
|
+
event_type: 'START_CHECKOUT'
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'View Content',
|
|
132
|
+
subscribe: 'event = "Product Viewed"',
|
|
133
|
+
partnerAction: 'reportConversionEvent',
|
|
134
|
+
mapping: {
|
|
135
|
+
...DEFAULT_VALS,
|
|
136
|
+
event_type: 'VIEW_CONTENT'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
];
|
|
140
|
+
const destination = {
|
|
141
|
+
name: 'Snap Conversions Api',
|
|
142
|
+
slug: 'actions-snap-conversions',
|
|
143
|
+
mode: 'cloud',
|
|
144
|
+
authentication: {
|
|
145
|
+
scheme: 'oauth2',
|
|
146
|
+
fields: {
|
|
147
|
+
pixel_id: {
|
|
148
|
+
label: 'Pixel ID',
|
|
149
|
+
description: 'The Pixel ID for your Snapchat Ad Account. Required for web and offline events.',
|
|
150
|
+
type: 'string'
|
|
151
|
+
},
|
|
152
|
+
snap_app_id: {
|
|
153
|
+
label: 'Snap App ID',
|
|
154
|
+
description: 'The Snap App ID associated with your app. This is a unique code generated in Snapchat Ads Manager and included in your MMP dashboard. Required for app events.',
|
|
155
|
+
type: 'string'
|
|
156
|
+
},
|
|
157
|
+
app_id: {
|
|
158
|
+
label: 'App ID',
|
|
159
|
+
description: 'The unique ID assigned for a given application. It should be numeric for iOS, and the human interpretable string for Android. Required for app events.',
|
|
160
|
+
type: 'string'
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
refreshAccessToken: async (request, { auth }) => {
|
|
164
|
+
const res = await request(ACCESS_TOKEN_URL, {
|
|
165
|
+
method: 'POST',
|
|
166
|
+
body: new URLSearchParams({
|
|
167
|
+
refresh_token: auth.refreshToken,
|
|
168
|
+
client_id: auth.clientId,
|
|
169
|
+
client_secret: auth.clientSecret,
|
|
170
|
+
grant_type: 'refresh_token'
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
return { accessToken: res.data.access_token };
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
extendRequest({ auth }) {
|
|
177
|
+
return {
|
|
178
|
+
headers: {
|
|
179
|
+
authorization: `Bearer ${auth?.accessToken}`
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
presets,
|
|
184
|
+
actions: {
|
|
185
|
+
reportConversionEvent: reportConversionEvent_1.default
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
exports.default = destination;
|
|
189
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/snap-conversions-api/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA4E;AAG5E,oFAA2D;AAE3D,MAAM,YAAY,GAAG;IACnB,GAAG,4BAAa,CAAC,+BAAqB,CAAC,MAAM,CAAC;CAC/C,CAAA;AAED,MAAM,gBAAgB,GAAG,yDAAyD,CAAA;AAMlF,MAAM,OAAO,GAAqC;IAChD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,gCAAgC;QAC3C,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,YAAY;YACf,UAAU,EAAE,aAAa;SAC1B;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,yBAAyB;QACpC,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,YAAY;YACf,UAAU,EAAE,UAAU;SACvB;KACF;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,SAAS,EAAE,qCAAqC;QAChD,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,YAAY;YACf,UAAU,EAAE,iBAAiB;SAC9B;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,iCAAiC;QAC5C,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,YAAY;YACf,UAAU,EAAE,aAAa;SAC1B;KACF;IACD;QACE,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,+BAA+B;QAC1C,aAAa,EAAE,uBAAuB;QACtC,OAAO,EAAE;YACP,GAAG,YAAY;YACf,UAAU,EAAE,WAAW;SACxB;KACF;IACD;QACE,IAAI,EAAE,UAAU;QACh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ED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
event_type: string;
|
|
3
|
+
event_conversion_type: string;
|
|
4
|
+
event_tag?: string;
|
|
5
|
+
timestamp: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
mobile_ad_id?: string;
|
|
8
|
+
uuid_c1?: string;
|
|
9
|
+
idfv?: string;
|
|
10
|
+
phone_number?: string;
|
|
11
|
+
user_agent?: string;
|
|
12
|
+
ip_address?: string;
|
|
13
|
+
item_category?: string;
|
|
14
|
+
item_ids?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
number_items?: string;
|
|
17
|
+
price?: number;
|
|
18
|
+
currency?: string;
|
|
19
|
+
transaction_id?: string;
|
|
20
|
+
level?: string;
|
|
21
|
+
client_dedup_id?: string;
|
|
22
|
+
search_string?: string;
|
|
23
|
+
page_url?: string;
|
|
24
|
+
sign_up_method?: string;
|
|
25
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/snap-conversions-api/reportConversionEvent/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ActionDefinition } from '@segment/actions-core';
|
|
2
2
|
import type { Settings } from '../generated-types';
|
|
3
3
|
import type { Payload } from './generated-types';
|
|
4
4
|
declare const action: ActionDefinition<Settings, Payload>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const snap_capi_properties_1 = require("../snap-capi-properties");
|
|
5
|
+
const CONVERSION_EVENT_URL = 'https://tr.snapchat.com/v2/conversion';
|
|
6
|
+
const action = {
|
|
7
|
+
title: 'Report Conversion Event',
|
|
8
|
+
description: 'Report events directly to Snapchat. Data shared can power Snap solutions such as custom audience targeting, campaign optimization, Dynamic Ads, and more.',
|
|
9
|
+
fields: {
|
|
10
|
+
event_type: { ...snap_capi_properties_1.event_type, required: true },
|
|
11
|
+
event_conversion_type: { ...snap_capi_properties_1.event_conversion_type, required: true },
|
|
12
|
+
event_tag: snap_capi_properties_1.event_tag,
|
|
13
|
+
timestamp: { ...snap_capi_properties_1.timestamp, required: true },
|
|
14
|
+
email: snap_capi_properties_1.email,
|
|
15
|
+
mobile_ad_id: snap_capi_properties_1.mobile_ad_id,
|
|
16
|
+
uuid_c1: snap_capi_properties_1.uuid_c1,
|
|
17
|
+
idfv: snap_capi_properties_1.idfv,
|
|
18
|
+
phone_number: snap_capi_properties_1.phone_number,
|
|
19
|
+
user_agent: snap_capi_properties_1.user_agent,
|
|
20
|
+
ip_address: snap_capi_properties_1.ip_address,
|
|
21
|
+
item_category: snap_capi_properties_1.item_category,
|
|
22
|
+
item_ids: snap_capi_properties_1.item_ids,
|
|
23
|
+
description: snap_capi_properties_1.description,
|
|
24
|
+
number_items: snap_capi_properties_1.number_items,
|
|
25
|
+
price: snap_capi_properties_1.price,
|
|
26
|
+
currency: snap_capi_properties_1.currency,
|
|
27
|
+
transaction_id: snap_capi_properties_1.transaction_id,
|
|
28
|
+
level: snap_capi_properties_1.level,
|
|
29
|
+
client_dedup_id: snap_capi_properties_1.client_dedup_id,
|
|
30
|
+
search_string: snap_capi_properties_1.search_string,
|
|
31
|
+
page_url: snap_capi_properties_1.page_url,
|
|
32
|
+
sign_up_method: snap_capi_properties_1.sign_up_method
|
|
33
|
+
},
|
|
34
|
+
perform: (request, data) => {
|
|
35
|
+
const payload = snap_capi_properties_1.formatPayload(data.payload);
|
|
36
|
+
const settings = snap_capi_properties_1.conversionType(data.settings, data.payload.event_conversion_type);
|
|
37
|
+
if (data.payload.currency && !snap_capi_properties_1.CURRENCY_ISO_4217_CODES.has(data.payload.currency)) {
|
|
38
|
+
throw new actions_core_1.IntegrationError(`${data.payload.currency} is not a valid currency code.`, 'Misconfigured required field', 400);
|
|
39
|
+
}
|
|
40
|
+
return request(CONVERSION_EVENT_URL, {
|
|
41
|
+
method: 'post',
|
|
42
|
+
json: {
|
|
43
|
+
...payload,
|
|
44
|
+
...settings
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.default = action;
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/snap-conversions-api/reportConversionEvent/index.ts"],"names":[],"mappings":";;AAAA,wDAA0E;AAG1E,kEA2BgC;AAEhC,MAAM,oBAAoB,GAAG,uCAAuC,CAAA;AAEpE,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EACT,2JAA2J;IAC7J,MAAM,EAAE;QACN,UAAU,EAAE,EAAE,GAAG,iCAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC7C,qBAAqB,EAAE,EAAE,GAAG,4CAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnE,SAAS,EAAE,gCAAS;QACpB,SAAS,EAAE,EAAE,GAAG,gCAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC3C,KAAK,EAAE,4BAAK;QACZ,YAAY,EAAE,mCAAY;QAC1B,OAAO,EAAE,8BAAO;QAChB,IAAI,EAAE,2BAAI;QACV,YAAY,EAAE,mCAAY;QAC1B,UAAU,EAAE,iCAAU;QACtB,UAAU,EAAE,iCAAU;QACtB,aAAa,EAAE,oCAAa;QAC5B,QAAQ,EAAE,+BAAQ;QAClB,WAAW,EAAE,kCAAW;QACxB,YAAY,EAAE,mCAAY;QAC1B,KAAK,EAAE,4BAAK;QACZ,QAAQ,EAAE,+BAAQ;QAClB,cAAc,EAAE,qCAAc;QAC9B,KAAK,EAAE,4BAAK;QACZ,eAAe,EAAE,sCAAe;QAChC,aAAa,EAAE,oCAAa;QAC5B,QAAQ,EAAE,+BAAQ;QAClB,cAAc,EAAE,qCAAc;KAC/B;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,OAAO,GAAW,oCAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAa,qCAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;QAE5F,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,8CAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAChF,MAAM,IAAI,+BAAgB,CACxB,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,gCAAgC,EACxD,8BAA8B,EAC9B,GAAG,CACJ,CAAA;SACF;QAGD,OAAO,OAAO,CAAC,oBAAoB,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,GAAG,OAAO;gBACV,GAAG,QAAQ;aACZ;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InputField } from '@segment/actions-core/src/destination-kit/types';
|
|
2
|
+
import { Settings } from '../snap-conversions-api/generated-types';
|
|
3
|
+
import { Payload } from './reportConversionEvent/generated-types';
|
|
4
|
+
export declare const CURRENCY_ISO_4217_CODES: Set<string>;
|
|
5
|
+
export declare const event_type: InputField;
|
|
6
|
+
export declare const event_conversion_type: InputField;
|
|
7
|
+
export declare const event_tag: InputField;
|
|
8
|
+
export declare const timestamp: InputField;
|
|
9
|
+
export declare const email: InputField;
|
|
10
|
+
export declare const mobile_ad_id: InputField;
|
|
11
|
+
export declare const uuid_c1: InputField;
|
|
12
|
+
export declare const idfv: InputField;
|
|
13
|
+
export declare const phone_number: InputField;
|
|
14
|
+
export declare const user_agent: InputField;
|
|
15
|
+
export declare const ip_address: InputField;
|
|
16
|
+
export declare const item_category: InputField;
|
|
17
|
+
export declare const item_ids: InputField;
|
|
18
|
+
export declare const description: InputField;
|
|
19
|
+
export declare const number_items: InputField;
|
|
20
|
+
export declare const price: InputField;
|
|
21
|
+
export declare const currency: InputField;
|
|
22
|
+
export declare const transaction_id: InputField;
|
|
23
|
+
export declare const level: InputField;
|
|
24
|
+
export declare const client_dedup_id: InputField;
|
|
25
|
+
export declare const search_string: InputField;
|
|
26
|
+
export declare const page_url: InputField;
|
|
27
|
+
export declare const sign_up_method: InputField;
|
|
28
|
+
export declare const conversionType: (settings: Settings, event_conversion_type: String) => Settings;
|
|
29
|
+
export declare const hash: (value: string | undefined) => string | undefined;
|
|
30
|
+
export declare const formatPayload: (payload: Payload) => Object;
|