@segment/action-destinations 3.260.0-staging.0 → 3.260.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/blackbaud-raisers-edge-nxt/utils/index.d.ts +1 -1
- package/dist/destinations/braze/index.js +1 -0
- package/dist/destinations/braze/index.js.map +1 -1
- package/dist/destinations/display-video-360/index.js +4 -2
- package/dist/destinations/display-video-360/index.js.map +1 -1
- package/dist/destinations/engage/utils/EngageActionPerformer.js +1 -0
- package/dist/destinations/engage/utils/EngageActionPerformer.js.map +1 -1
- package/dist/destinations/engage/utils/ResponseError.d.ts +1 -0
- package/dist/destinations/engage/utils/ResponseError.js.map +1 -1
- package/dist/destinations/engage/utils/track.d.ts +17 -17
- package/dist/destinations/google-enhanced-conversions/functions.d.ts +1 -1
- package/dist/destinations/google-enhanced-conversions/functions.js +2 -2
- package/dist/destinations/google-enhanced-conversions/functions.js.map +1 -1
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js +2 -2
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js.map +1 -1
- package/dist/destinations/index.js +2 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/kafka/index.js +14 -7
- package/dist/destinations/kafka/index.js.map +1 -1
- package/dist/destinations/kafka/utils.d.ts +4 -0
- package/dist/destinations/kafka/utils.js +39 -1
- package/dist/destinations/kafka/utils.js.map +1 -1
- package/dist/destinations/kameleoon/group/generated-types.d.ts +11 -0
- package/dist/destinations/kameleoon/group/generated-types.js.map +1 -0
- package/dist/destinations/{responsys/asyncMergePetRecords → kameleoon/group}/index.d.ts +1 -1
- package/dist/destinations/kameleoon/group/index.js +85 -0
- package/dist/destinations/kameleoon/group/index.js.map +1 -0
- package/dist/destinations/kameleoon/identify/generated-types.d.ts +10 -0
- package/dist/destinations/kameleoon/identify/generated-types.js.map +1 -0
- package/dist/destinations/{responsys/asyncMergeProfileListMembers → kameleoon/identify}/index.d.ts +1 -1
- package/dist/destinations/kameleoon/identify/index.js +78 -0
- package/dist/destinations/kameleoon/identify/index.js.map +1 -0
- package/dist/destinations/kameleoon/index.js +15 -9
- package/dist/destinations/kameleoon/index.js.map +1 -1
- package/dist/destinations/kameleoon/logEvent/generated-types.d.ts +2 -0
- package/dist/destinations/kameleoon/logEvent/index.js +13 -1
- package/dist/destinations/kameleoon/logEvent/index.js.map +1 -1
- package/dist/destinations/kameleoon/page/generated-types.d.ts +14 -0
- package/dist/destinations/{engage/sendgrid/Profile.js → kameleoon/page/generated-types.js} +1 -1
- package/dist/destinations/kameleoon/page/generated-types.js.map +1 -0
- package/dist/destinations/kameleoon/page/index.d.ts +5 -0
- package/dist/destinations/kameleoon/page/index.js +90 -0
- package/dist/destinations/kameleoon/page/index.js.map +1 -0
- package/dist/destinations/klaviyo/functions.d.ts +4 -7
- package/dist/destinations/klaviyo/functions.js +1 -80
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +0 -97
- package/dist/destinations/klaviyo/upsertProfile/index.js +19 -29
- package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
- package/dist/destinations/moloco-rmp/index.js +2 -2
- package/dist/destinations/segment/segment-properties.d.ts +0 -1
- package/dist/destinations/segment/segment-properties.js +1 -8
- package/dist/destinations/segment/segment-properties.js.map +1 -1
- package/dist/destinations/segment/sendGroup/generated-types.d.ts +0 -1
- package/dist/destinations/segment/sendGroup/index.js +0 -2
- package/dist/destinations/segment/sendGroup/index.js.map +1 -1
- package/dist/destinations/segment/sendIdentify/generated-types.d.ts +0 -1
- package/dist/destinations/segment/sendIdentify/index.js +0 -2
- package/dist/destinations/segment/sendIdentify/index.js.map +1 -1
- package/dist/destinations/segment/sendPage/generated-types.d.ts +0 -1
- package/dist/destinations/segment/sendPage/index.js +0 -2
- package/dist/destinations/segment/sendPage/index.js.map +1 -1
- package/dist/destinations/segment/sendScreen/generated-types.d.ts +0 -1
- package/dist/destinations/segment/sendScreen/index.js +0 -2
- package/dist/destinations/segment/sendScreen/index.js.map +1 -1
- package/dist/destinations/segment/sendTrack/generated-types.d.ts +0 -1
- package/dist/destinations/segment/sendTrack/index.js +0 -2
- package/dist/destinations/segment/sendTrack/index.js.map +1 -1
- package/dist/destinations/snap-conversions-api/_tests_/index.test.js +420 -488
- package/dist/destinations/snap-conversions-api/_tests_/index.test.js.map +1 -1
- package/dist/destinations/snap-conversions-api/index.js +42 -42
- package/dist/destinations/snap-conversions-api/index.js.map +1 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/generated-types.d.ts +97 -18
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js +7 -29
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js.map +1 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-deprecated.d.ts +31 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-deprecated.js +174 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-deprecated.js.map +1 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-v3.d.ts +16 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-v3.js +640 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-v3.js.map +1 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v3.d.ts +0 -4
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v3.js +593 -119
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v3.js.map +1 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/utils.d.ts +3 -4
- package/dist/destinations/snap-conversions-api/reportConversionEvent/utils.js +6 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/utils.js.map +1 -1
- package/dist/destinations/spiffy/generated-types.d.ts +5 -0
- package/dist/destinations/spiffy/generated-types.js +3 -0
- package/dist/destinations/spiffy/generated-types.js.map +1 -0
- package/dist/destinations/spiffy/index.d.ts +4 -0
- package/dist/destinations/spiffy/index.js +62 -0
- package/dist/destinations/spiffy/index.js.map +1 -0
- package/dist/destinations/spiffy/send/generated-types.d.ts +8 -0
- package/dist/destinations/spiffy/send/generated-types.js +3 -0
- package/dist/destinations/spiffy/send/generated-types.js.map +1 -0
- package/dist/destinations/spiffy/send/index.d.ts +5 -0
- package/dist/destinations/spiffy/send/index.js +42 -0
- package/dist/destinations/spiffy/send/index.js.map +1 -0
- package/dist/destinations/stackadapt/forwardEvent/generated-types.d.ts +4 -4
- package/dist/destinations/stackadapt/forwardEvent/index.js +11 -7
- package/dist/destinations/stackadapt/forwardEvent/index.js.map +1 -1
- package/dist/destinations/xtremepush/generated-types.d.ts +4 -0
- package/dist/destinations/xtremepush/generated-types.js +3 -0
- package/dist/destinations/xtremepush/generated-types.js.map +1 -0
- package/dist/destinations/xtremepush/identify/generated-types.d.ts +14 -0
- package/dist/destinations/xtremepush/identify/generated-types.js +3 -0
- package/dist/destinations/xtremepush/identify/generated-types.js.map +1 -0
- package/dist/destinations/xtremepush/identify/index.d.ts +5 -0
- package/dist/destinations/xtremepush/identify/index.js +87 -0
- package/dist/destinations/xtremepush/identify/index.js.map +1 -0
- package/dist/destinations/xtremepush/index.d.ts +4 -0
- package/dist/destinations/xtremepush/index.js +66 -0
- package/dist/destinations/xtremepush/index.js.map +1 -0
- package/dist/destinations/xtremepush/track/generated-types.d.ts +15 -0
- package/dist/destinations/xtremepush/track/generated-types.js +3 -0
- package/dist/destinations/xtremepush/track/generated-types.js.map +1 -0
- package/dist/destinations/xtremepush/track/index.d.ts +5 -0
- package/dist/destinations/xtremepush/track/index.js +95 -0
- package/dist/destinations/xtremepush/track/index.js.map +1 -0
- package/package.json +4 -4
- package/dist/destinations/engage/sendgrid/Profile.d.ts +0 -6
- package/dist/destinations/engage/sendgrid/Profile.js.map +0 -1
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.d.ts +0 -21
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js +0 -174
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js.map +0 -1
- package/dist/destinations/mixpanel/utils.d.ts +0 -13
- package/dist/destinations/mixpanel/utils.js +0 -117
- package/dist/destinations/mixpanel/utils.js.map +0 -1
- package/dist/destinations/responsys/asyncMergePetRecords/generated-types.d.ts +0 -14
- package/dist/destinations/responsys/asyncMergePetRecords/generated-types.js.map +0 -1
- package/dist/destinations/responsys/asyncMergePetRecords/index.js +0 -113
- package/dist/destinations/responsys/asyncMergePetRecords/index.js.map +0 -1
- package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.d.ts +0 -20
- package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.js.map +0 -1
- package/dist/destinations/responsys/asyncMergeProfileListMembers/index.js +0 -174
- package/dist/destinations/responsys/asyncMergeProfileListMembers/index.js.map +0 -1
- package/dist/destinations/responsys/rsp-operations.d.ts +0 -14
- package/dist/destinations/responsys/rsp-operations.js +0 -33
- package/dist/destinations/responsys/rsp-operations.js.map +0 -1
- package/dist/destinations/responsys/rsp-properties.d.ts +0 -4
- package/dist/destinations/responsys/rsp-properties.js +0 -27
- package/dist/destinations/responsys/rsp-properties.js.map +0 -1
- package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.d.ts +0 -1
- package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.js +0 -381
- package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.js.map +0 -1
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.d.ts +0 -1
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.js +0 -581
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.js.map +0 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.d.ts +0 -4
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.js +0 -97
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.js.map +0 -1
- package/dist/destinations/snap-conversions-api/snap-capi-properties.d.ts +0 -30
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js +0 -316
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js.map +0 -1
- package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.d.ts +0 -3
- package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.js +0 -43
- package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.js.map +0 -1
- /package/dist/destinations/{responsys/asyncMergePetRecords → kameleoon/group}/generated-types.js +0 -0
- /package/dist/destinations/{responsys/asyncMergeProfileListMembers → kameleoon/identify}/generated-types.js +0 -0
|
@@ -6,18 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const nock_1 = __importDefault(require("nock"));
|
|
7
7
|
const actions_core_1 = require("@segment/actions-core");
|
|
8
8
|
const index_1 = __importDefault(require("../index"));
|
|
9
|
-
const
|
|
9
|
+
const utils_1 = require("../reportConversionEvent/utils");
|
|
10
10
|
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
11
|
-
const timestamp = '2022-05-12T15:21:15.449Z';
|
|
12
|
-
const settings = {
|
|
13
|
-
snap_app_id: 'test123',
|
|
14
|
-
pixel_id: 'pixel123',
|
|
15
|
-
app_id: 'app123'
|
|
16
|
-
};
|
|
17
|
-
const accessToken = 'access123';
|
|
18
|
-
const refreshToken = 'refresh123';
|
|
19
11
|
const testEvent = actions_core_1.createTestEvent({
|
|
20
|
-
timestamp:
|
|
12
|
+
timestamp: '2022-05-12T15:21:15.449Z',
|
|
21
13
|
messageId: 'test-message-rv4t40s898k',
|
|
22
14
|
event: 'PURCHASE',
|
|
23
15
|
type: 'track',
|
|
@@ -29,18 +21,43 @@ const testEvent = actions_core_1.createTestEvent({
|
|
|
29
21
|
revenue: '15',
|
|
30
22
|
currency: 'USD',
|
|
31
23
|
level: 3
|
|
24
|
+
},
|
|
25
|
+
integrations: {
|
|
26
|
+
['Snap Conversions Api']: {
|
|
27
|
+
click_id: 'cliasdfck_id',
|
|
28
|
+
uuid_c1: 'sadfjklsdf;lksjd'
|
|
29
|
+
}
|
|
32
30
|
}
|
|
33
31
|
});
|
|
34
|
-
const
|
|
32
|
+
const reportConversionEvent = async (inputData) => {
|
|
33
|
+
const event = actions_core_1.createTestEvent(testEvent);
|
|
34
|
+
const accessToken = 'access123';
|
|
35
|
+
const refreshToken = 'refresh123';
|
|
36
|
+
const responses = await testDestination.testAction('reportConversionEvent', {
|
|
37
|
+
event,
|
|
38
|
+
settings: {
|
|
39
|
+
snap_app_id: 'test123',
|
|
40
|
+
pixel_id: 'pixel123',
|
|
41
|
+
app_id: '123'
|
|
42
|
+
},
|
|
43
|
+
useDefaultMappings: true,
|
|
44
|
+
auth: {
|
|
45
|
+
accessToken,
|
|
46
|
+
refreshToken
|
|
47
|
+
},
|
|
48
|
+
...inputData
|
|
49
|
+
});
|
|
50
|
+
return { url: responses[0].url, data: JSON.parse(responses[0].options.body).data[0] };
|
|
51
|
+
};
|
|
35
52
|
beforeEach(() => {
|
|
36
53
|
nock_1.default.cleanAll();
|
|
54
|
+
nock_1.default(/.*/).post(/.*/).reply(200);
|
|
37
55
|
});
|
|
38
56
|
describe('Snap Conversions API ', () => {
|
|
39
57
|
describe('ReportConversionEvent', () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const event = actions_core_1.createTestEvent({
|
|
58
|
+
it('should use products array over number_items, product_id and category fields', async () => {
|
|
59
|
+
const { data } = await reportConversionEvent({
|
|
60
|
+
event: {
|
|
44
61
|
...testEvent,
|
|
45
62
|
properties: {
|
|
46
63
|
email: 'test123@gmail.com',
|
|
@@ -56,386 +73,251 @@ describe('Snap Conversions API ', () => {
|
|
|
56
73
|
]
|
|
57
74
|
},
|
|
58
75
|
context: {}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
auth: {
|
|
65
|
-
accessToken,
|
|
66
|
-
refreshToken
|
|
67
|
-
},
|
|
68
|
-
features,
|
|
69
|
-
mapping: {
|
|
70
|
-
event_type: 'PURCHASE',
|
|
71
|
-
event_conversion_type: 'WEB'
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
expect(responses).not.toBeNull();
|
|
75
|
-
expect(responses[0].status).toBe(200);
|
|
76
|
-
const body = JSON.parse(responses[0].options.body);
|
|
77
|
-
const { data } = body;
|
|
78
|
-
expect(data.length).toBe(1);
|
|
79
|
-
const { integration, event_name, event_time, user_data, custom_data, action_source, app_data } = data[0];
|
|
80
|
-
const { em, ph } = user_data;
|
|
81
|
-
const { brands, content_category, content_ids, currency, num_items, value } = custom_data;
|
|
82
|
-
expect(integration).toBe('segment');
|
|
83
|
-
expect(event_name).toBe('PURCHASE');
|
|
84
|
-
expect(event_time).toBe(1652368875449);
|
|
85
|
-
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
86
|
-
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
87
|
-
expect(currency).toBe('USD');
|
|
88
|
-
expect(value).toBe(15);
|
|
89
|
-
expect(action_source).toBe('website');
|
|
90
|
-
expect(app_data).toBeUndefined();
|
|
91
|
-
expect(brands).toEqual(['Hasbro', 'Mattel']);
|
|
92
|
-
expect(content_category).toEqual(['games', 'games']);
|
|
93
|
-
expect(content_ids).toEqual(['123', '456']);
|
|
94
|
-
expect(num_items).toBe(2);
|
|
95
|
-
});
|
|
96
|
-
it('should handle a basic event', async () => {
|
|
97
|
-
nock_1.default(/.*/).post(/.*/).reply(200);
|
|
98
|
-
const event = actions_core_1.createTestEvent(testEvent);
|
|
99
|
-
const responses = await testDestination.testAction('reportConversionEvent', {
|
|
100
|
-
event,
|
|
101
|
-
settings,
|
|
102
|
-
useDefaultMappings: true,
|
|
103
|
-
auth: {
|
|
104
|
-
accessToken,
|
|
105
|
-
refreshToken
|
|
106
|
-
},
|
|
107
|
-
features,
|
|
108
|
-
mapping: {
|
|
109
|
-
event_type: 'PURCHASE',
|
|
110
|
-
event_conversion_type: 'WEB'
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
expect(responses).not.toBeNull();
|
|
114
|
-
expect(responses[0].status).toBe(200);
|
|
115
|
-
const body = JSON.parse(responses[0].options.body);
|
|
116
|
-
const { data } = body;
|
|
117
|
-
expect(data.length).toBe(1);
|
|
118
|
-
const { integration, event_name, event_source_url, event_time, user_data, custom_data, action_source, app_data } = data[0];
|
|
119
|
-
const { client_ip_address, client_user_agent, em, ph } = user_data;
|
|
120
|
-
const { currency, value } = custom_data;
|
|
121
|
-
expect(integration).toBe('segment');
|
|
122
|
-
expect(event_name).toBe('PURCHASE');
|
|
123
|
-
expect(event_source_url).toBe('https://segment.com/academy/');
|
|
124
|
-
expect(event_time).toBe(1652368875449);
|
|
125
|
-
expect(client_ip_address).toBe('8.8.8.8');
|
|
126
|
-
expect(client_user_agent).toBe('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');
|
|
127
|
-
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
128
|
-
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
129
|
-
expect(currency).toBe('USD');
|
|
130
|
-
expect(value).toBe(15);
|
|
131
|
-
expect(action_source).toBe('website');
|
|
132
|
-
expect(app_data).toBeUndefined();
|
|
133
|
-
});
|
|
134
|
-
it('should fail web event without pixel_id', async () => {
|
|
135
|
-
nock_1.default(/.*/).post(/.*/).reply(200);
|
|
136
|
-
const event = actions_core_1.createTestEvent(testEvent);
|
|
137
|
-
await expect(testDestination.testAction('reportConversionEvent', {
|
|
138
|
-
event,
|
|
139
|
-
settings: {
|
|
140
|
-
snap_app_id: 'test123'
|
|
141
|
-
},
|
|
142
|
-
useDefaultMappings: true,
|
|
143
|
-
auth: {
|
|
144
|
-
accessToken,
|
|
145
|
-
refreshToken
|
|
146
|
-
},
|
|
147
|
-
features,
|
|
148
|
-
mapping: {
|
|
149
|
-
event_type: 'PURCHASE',
|
|
150
|
-
event_conversion_type: 'WEB'
|
|
151
|
-
}
|
|
152
|
-
})).rejects.toThrowError('If event conversion type is "WEB" then Pixel ID must be defined');
|
|
76
|
+
},
|
|
77
|
+
mapping: {
|
|
78
|
+
event_type: 'PURCHASE',
|
|
79
|
+
event_conversion_type: 'WEB'
|
|
80
|
+
}
|
|
153
81
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
82
|
+
const { integration, event_name, event_time, user_data, custom_data, action_source, app_data } = data;
|
|
83
|
+
const { em, ph } = user_data;
|
|
84
|
+
const { brands, content_category, content_ids, currency, num_items, value } = custom_data;
|
|
85
|
+
expect(integration).toBe('segment');
|
|
86
|
+
expect(event_name).toBe('PURCHASE');
|
|
87
|
+
expect(event_time).toBe(1652368875449);
|
|
88
|
+
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
89
|
+
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
90
|
+
expect(currency).toBe('USD');
|
|
91
|
+
expect(value).toBe(15);
|
|
92
|
+
expect(action_source).toBe('website');
|
|
93
|
+
expect(app_data).toBeUndefined();
|
|
94
|
+
expect(brands).toEqual(['Hasbro', 'Mattel']);
|
|
95
|
+
expect(content_category).toEqual(['games', 'games']);
|
|
96
|
+
expect(content_ids).toEqual(['123', '456']);
|
|
97
|
+
expect(num_items).toBe(10);
|
|
98
|
+
});
|
|
99
|
+
it('should handle a basic event', async () => {
|
|
100
|
+
const { data } = await reportConversionEvent({
|
|
101
|
+
mapping: {
|
|
102
|
+
event_type: 'PURCHASE',
|
|
103
|
+
event_conversion_type: 'WEB'
|
|
104
|
+
}
|
|
174
105
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
106
|
+
const { integration, event_name, event_source_url, event_time, user_data, custom_data, action_source, app_data } = data;
|
|
107
|
+
const { client_ip_address, client_user_agent, em, ph } = user_data;
|
|
108
|
+
const { currency, value } = custom_data;
|
|
109
|
+
expect(integration).toBe('segment');
|
|
110
|
+
expect(event_name).toBe('PURCHASE');
|
|
111
|
+
expect(event_source_url).toBe('https://segment.com/academy/');
|
|
112
|
+
expect(event_time).toBe(1652368875449);
|
|
113
|
+
expect(client_ip_address).toBe('8.8.8.8');
|
|
114
|
+
expect(client_user_agent).toBe('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');
|
|
115
|
+
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
116
|
+
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
117
|
+
expect(currency).toBe('USD');
|
|
118
|
+
expect(value).toBe(15);
|
|
119
|
+
expect(action_source).toBe('website');
|
|
120
|
+
expect(app_data).toBeUndefined();
|
|
121
|
+
});
|
|
122
|
+
it('should fail web event without pixel_id', async () => {
|
|
123
|
+
await expect(reportConversionEvent({
|
|
124
|
+
mapping: {
|
|
125
|
+
event_type: 'PURCHASE',
|
|
126
|
+
event_conversion_type: 'WEB'
|
|
127
|
+
},
|
|
128
|
+
settings: {
|
|
129
|
+
snap_app_id: 'test123'
|
|
130
|
+
}
|
|
131
|
+
})).rejects.toThrowError('If event conversion type is "WEB" then Pixel ID must be defined');
|
|
132
|
+
});
|
|
133
|
+
it('should fail app event without snap_app_id', async () => {
|
|
134
|
+
await expect(reportConversionEvent({
|
|
135
|
+
settings: {},
|
|
136
|
+
mapping: {
|
|
137
|
+
event_type: 'PURCHASE',
|
|
138
|
+
event_conversion_type: 'MOBILE_APP'
|
|
139
|
+
}
|
|
140
|
+
})).rejects.toThrowError('If event conversion type is "MOBILE_APP" then Snap App ID must be defined');
|
|
141
|
+
});
|
|
142
|
+
it('should handle an offline event conversion type', async () => {
|
|
143
|
+
const { data } = await reportConversionEvent({
|
|
144
|
+
mapping: {
|
|
145
|
+
event_type: 'SAVE',
|
|
146
|
+
event_conversion_type: 'OFFLINE'
|
|
147
|
+
}
|
|
212
148
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const { data } = body;
|
|
238
|
-
expect(data.length).toBe(1);
|
|
239
|
-
const { integration, event_name, event_source_url, event_time, user_data, custom_data, action_source, app_data } = data[0];
|
|
240
|
-
const { client_ip_address, client_user_agent, em, ph } = user_data;
|
|
241
|
-
const { currency, value } = custom_data;
|
|
242
|
-
const { extinfo, advertiser_tracking_enabled } = app_data;
|
|
243
|
-
expect(integration).toBe('segment');
|
|
244
|
-
expect(event_name).toBe('SAVE');
|
|
245
|
-
expect(event_source_url).toBe('https://segment.com/academy/');
|
|
246
|
-
expect(event_time).toBe(1652368875449);
|
|
247
|
-
expect(client_ip_address).toBe('8.8.8.8');
|
|
248
|
-
expect(client_user_agent).toBe('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');
|
|
249
|
-
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
250
|
-
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
251
|
-
expect(currency).toBe('USD');
|
|
252
|
-
expect(value).toBe(15);
|
|
253
|
-
expect(action_source).toBe('app');
|
|
254
|
-
expect(extinfo).toEqual(['i2', '', '', '', '17.2', 'iPhone12,1', '', '', '', '', '', '', '', '', '', '']);
|
|
255
|
-
expect(advertiser_tracking_enabled).toBe(0);
|
|
149
|
+
const { integration, event_name, event_source_url, event_time, user_data, custom_data, action_source, app_data } = data;
|
|
150
|
+
const { client_ip_address, client_user_agent, em, ph } = user_data;
|
|
151
|
+
const { currency, value } = custom_data;
|
|
152
|
+
expect(integration).toBe('segment');
|
|
153
|
+
expect(event_name).toBe('SAVE');
|
|
154
|
+
expect(event_source_url).toBe('https://segment.com/academy/');
|
|
155
|
+
expect(event_time).toBe(1652368875449);
|
|
156
|
+
expect(client_ip_address).toBe('8.8.8.8');
|
|
157
|
+
expect(client_user_agent).toBe('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');
|
|
158
|
+
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
159
|
+
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
160
|
+
expect(currency).toBe('USD');
|
|
161
|
+
expect(value).toBe(15);
|
|
162
|
+
expect(action_source).toBe('OFFLINE');
|
|
163
|
+
expect(app_data).toBeUndefined();
|
|
164
|
+
});
|
|
165
|
+
it('should handle a mobile app event conversion type', async () => {
|
|
166
|
+
const { data } = await reportConversionEvent({
|
|
167
|
+
mapping: {
|
|
168
|
+
device_model: 'iPhone12,1',
|
|
169
|
+
os_version: '17.2',
|
|
170
|
+
event_type: 'SAVE',
|
|
171
|
+
event_conversion_type: 'MOBILE_APP'
|
|
172
|
+
}
|
|
256
173
|
});
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
174
|
+
const { integration, event_name, event_source_url, event_time, user_data, custom_data, action_source, app_data } = data;
|
|
175
|
+
const { client_ip_address, client_user_agent, em, ph } = user_data;
|
|
176
|
+
const { currency, value } = custom_data;
|
|
177
|
+
const { extinfo, advertiser_tracking_enabled } = app_data;
|
|
178
|
+
expect(integration).toBe('segment');
|
|
179
|
+
expect(event_name).toBe('SAVE');
|
|
180
|
+
expect(event_source_url).toBe('https://segment.com/academy/');
|
|
181
|
+
expect(event_time).toBe(1652368875449);
|
|
182
|
+
expect(client_ip_address).toBe('8.8.8.8');
|
|
183
|
+
expect(client_user_agent).toBe('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');
|
|
184
|
+
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
185
|
+
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
186
|
+
expect(currency).toBe('USD');
|
|
187
|
+
expect(value).toBe(15);
|
|
188
|
+
expect(action_source).toBe('app');
|
|
189
|
+
expect(extinfo).toEqual([
|
|
190
|
+
'i2',
|
|
191
|
+
'',
|
|
192
|
+
'',
|
|
193
|
+
'',
|
|
194
|
+
'17.2',
|
|
195
|
+
'iPhone12,1',
|
|
196
|
+
'en-US',
|
|
197
|
+
'',
|
|
198
|
+
'',
|
|
199
|
+
'',
|
|
200
|
+
'',
|
|
201
|
+
'',
|
|
202
|
+
'',
|
|
203
|
+
'',
|
|
204
|
+
'',
|
|
205
|
+
'Europe/Amsterdam'
|
|
206
|
+
]);
|
|
207
|
+
expect(advertiser_tracking_enabled).toBe(0);
|
|
208
|
+
});
|
|
209
|
+
it('should fail invalid currency', async () => {
|
|
210
|
+
await expect(reportConversionEvent({
|
|
211
|
+
event: {
|
|
260
212
|
...testEvent,
|
|
261
213
|
properties: {
|
|
262
214
|
currency: 'Galleon'
|
|
263
215
|
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
nock_1.default(/.*/).post(/.*/).reply(200);
|
|
282
|
-
const event = actions_core_1.createTestEvent(testEvent);
|
|
283
|
-
await expect(testDestination.testAction('reportConversionEvent', {
|
|
284
|
-
event,
|
|
285
|
-
settings,
|
|
286
|
-
useDefaultMappings: true,
|
|
287
|
-
auth: {
|
|
288
|
-
accessToken,
|
|
289
|
-
refreshToken
|
|
290
|
-
},
|
|
291
|
-
features,
|
|
292
|
-
mapping: {
|
|
293
|
-
event_type: 'PURCHASE'
|
|
294
|
-
}
|
|
295
|
-
})).rejects.toThrowError("The root value is missing the required field 'event_conversion_type'.");
|
|
296
|
-
});
|
|
297
|
-
it('should handle a custom event', async () => {
|
|
298
|
-
nock_1.default(/.*/).post(/.*/).reply(200);
|
|
299
|
-
const event = actions_core_1.createTestEvent({
|
|
216
|
+
},
|
|
217
|
+
mapping: {
|
|
218
|
+
event_type: 'PURCHASE',
|
|
219
|
+
event_conversion_type: 'WEB'
|
|
220
|
+
}
|
|
221
|
+
})).rejects.toThrowError('GALLEON is not a valid currency code.');
|
|
222
|
+
});
|
|
223
|
+
it('should fail missing event conversion type', async () => {
|
|
224
|
+
await expect(reportConversionEvent({
|
|
225
|
+
mapping: {
|
|
226
|
+
event_type: 'PURCHASE'
|
|
227
|
+
}
|
|
228
|
+
})).rejects.toThrowError("The root value is missing the required field 'action_source'.");
|
|
229
|
+
});
|
|
230
|
+
it('should handle a custom event', async () => {
|
|
231
|
+
const { data } = await reportConversionEvent({
|
|
232
|
+
event: {
|
|
300
233
|
...testEvent,
|
|
301
234
|
event: 'CUSTOM_EVENT_5'
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
event,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
app_id: '123'
|
|
308
|
-
},
|
|
309
|
-
useDefaultMappings: true,
|
|
310
|
-
auth: {
|
|
311
|
-
accessToken,
|
|
312
|
-
refreshToken
|
|
313
|
-
},
|
|
314
|
-
features,
|
|
315
|
-
mapping: {
|
|
316
|
-
event_type: { '@path': '$.event' },
|
|
317
|
-
event_conversion_type: 'MOBILE_APP'
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
expect(responses).not.toBeNull();
|
|
321
|
-
expect(responses[0].status).toBe(200);
|
|
322
|
-
const body = JSON.parse(responses[0].options.body);
|
|
323
|
-
const { data } = body;
|
|
324
|
-
expect(data.length).toBe(1);
|
|
325
|
-
const { integration, event_name, event_source_url, event_time, user_data, custom_data, action_source, app_data } = data[0];
|
|
326
|
-
const { client_ip_address, client_user_agent, em, ph } = user_data;
|
|
327
|
-
const { currency, value } = custom_data;
|
|
328
|
-
const { app_id, advertiser_tracking_enabled } = app_data;
|
|
329
|
-
expect(integration).toBe('segment');
|
|
330
|
-
expect(event_name).toBe('CUSTOM_EVENT_5');
|
|
331
|
-
expect(event_source_url).toBe('https://segment.com/academy/');
|
|
332
|
-
expect(event_time).toBe(1652368875449);
|
|
333
|
-
expect(client_ip_address).toBe('8.8.8.8');
|
|
334
|
-
expect(client_user_agent).toBe('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');
|
|
335
|
-
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
336
|
-
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
337
|
-
expect(currency).toBe('USD');
|
|
338
|
-
expect(value).toBe(15);
|
|
339
|
-
expect(action_source).toBe('app');
|
|
340
|
-
expect(app_id).toBe('123');
|
|
341
|
-
expect(advertiser_tracking_enabled).toBe(0);
|
|
235
|
+
},
|
|
236
|
+
mapping: {
|
|
237
|
+
event_type: { '@path': '$.event' },
|
|
238
|
+
event_conversion_type: 'MOBILE_APP'
|
|
239
|
+
}
|
|
342
240
|
});
|
|
343
|
-
|
|
344
|
-
|
|
241
|
+
const { integration, event_name, event_source_url, event_time, user_data, custom_data, action_source, app_data } = data;
|
|
242
|
+
const { client_ip_address, client_user_agent, em, ph } = user_data;
|
|
243
|
+
const { currency, value } = custom_data;
|
|
244
|
+
const { app_id, advertiser_tracking_enabled } = app_data;
|
|
245
|
+
expect(integration).toBe('segment');
|
|
246
|
+
expect(event_name).toBe('CUSTOM_EVENT_5');
|
|
247
|
+
expect(event_source_url).toBe('https://segment.com/academy/');
|
|
248
|
+
expect(event_time).toBe(1652368875449);
|
|
249
|
+
expect(client_ip_address).toBe('8.8.8.8');
|
|
250
|
+
expect(client_user_agent).toBe('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');
|
|
251
|
+
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
252
|
+
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
253
|
+
expect(currency).toBe('USD');
|
|
254
|
+
expect(value).toBe(15);
|
|
255
|
+
expect(action_source).toBe('app');
|
|
256
|
+
expect(app_id).toBe('123');
|
|
257
|
+
expect(advertiser_tracking_enabled).toBe(0);
|
|
258
|
+
});
|
|
259
|
+
it('should fail event missing all Snap identifiers', async () => {
|
|
260
|
+
await expect(reportConversionEvent({
|
|
261
|
+
event: {
|
|
345
262
|
...testEvent,
|
|
346
263
|
properties: {},
|
|
347
264
|
context: {}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
mapping: {
|
|
359
|
-
event_type: 'PURCHASE',
|
|
360
|
-
event_conversion_type: 'WEB'
|
|
361
|
-
}
|
|
362
|
-
})).rejects.toThrowError('Payload must contain values for Email or Phone Number or Mobile Ad Identifier or both IP Address and User Agent fields');
|
|
363
|
-
});
|
|
364
|
-
it('should handle event with email as only Snap identifier', async () => {
|
|
365
|
-
nock_1.default(/.*/).post(/.*/).reply(200);
|
|
366
|
-
const event = actions_core_1.createTestEvent({
|
|
265
|
+
},
|
|
266
|
+
mapping: {
|
|
267
|
+
event_type: 'PURCHASE',
|
|
268
|
+
event_conversion_type: 'WEB'
|
|
269
|
+
}
|
|
270
|
+
})).rejects.toThrowError('Payload must contain values for Email or Phone Number or Mobile Ad Identifier or both IP Address and User Agent fields');
|
|
271
|
+
});
|
|
272
|
+
it('should handle event with email as only Snap identifier', async () => {
|
|
273
|
+
const { data } = await reportConversionEvent({
|
|
274
|
+
event: {
|
|
367
275
|
...testEvent,
|
|
368
276
|
properties: {
|
|
369
277
|
email: 'test123@gmail.com'
|
|
370
278
|
},
|
|
371
279
|
context: {}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
auth: {
|
|
378
|
-
accessToken,
|
|
379
|
-
refreshToken
|
|
380
|
-
},
|
|
381
|
-
features,
|
|
382
|
-
mapping: {
|
|
383
|
-
event_type: 'PURCHASE',
|
|
384
|
-
event_conversion_type: 'WEB'
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
expect(responses).not.toBeNull();
|
|
388
|
-
expect(responses[0].status).toBe(200);
|
|
389
|
-
const body = JSON.parse(responses[0].options.body);
|
|
390
|
-
const { data } = body;
|
|
391
|
-
expect(data.length).toBe(1);
|
|
392
|
-
const { integration, event_name, event_time, user_data, action_source } = data[0];
|
|
393
|
-
const { em, ph } = user_data;
|
|
394
|
-
expect(integration).toBe('segment');
|
|
395
|
-
expect(event_name).toBe('PURCHASE');
|
|
396
|
-
expect(event_time).toBe(1652368875449);
|
|
397
|
-
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
398
|
-
expect(ph).toBeUndefined();
|
|
399
|
-
expect(action_source).toBe('website');
|
|
280
|
+
},
|
|
281
|
+
mapping: {
|
|
282
|
+
event_type: 'PURCHASE',
|
|
283
|
+
event_conversion_type: 'WEB'
|
|
284
|
+
}
|
|
400
285
|
});
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
286
|
+
const { integration, event_name, event_time, user_data, action_source } = data;
|
|
287
|
+
const { em, ph } = user_data;
|
|
288
|
+
expect(integration).toBe('segment');
|
|
289
|
+
expect(event_name).toBe('PURCHASE');
|
|
290
|
+
expect(event_time).toBe(1652368875449);
|
|
291
|
+
expect(em[0]).toBe('cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9');
|
|
292
|
+
expect(ph).toBeUndefined();
|
|
293
|
+
expect(action_source).toBe('website');
|
|
294
|
+
});
|
|
295
|
+
it('should handle event with phone as only Snap identifier', async () => {
|
|
296
|
+
const { data } = await reportConversionEvent({
|
|
297
|
+
event: {
|
|
404
298
|
...testEvent,
|
|
405
299
|
properties: {
|
|
406
300
|
phone: '+44 844 412 4653'
|
|
407
301
|
},
|
|
408
302
|
context: {}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
auth: {
|
|
415
|
-
accessToken,
|
|
416
|
-
refreshToken
|
|
417
|
-
},
|
|
418
|
-
features,
|
|
419
|
-
mapping: {
|
|
420
|
-
event_type: 'PURCHASE',
|
|
421
|
-
event_conversion_type: 'WEB'
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
const body = JSON.parse(responses[0].options.body);
|
|
425
|
-
const { data } = body;
|
|
426
|
-
expect(data.length).toBe(1);
|
|
427
|
-
const { integration, event_name, event_time, user_data, action_source } = data[0];
|
|
428
|
-
const { ph } = user_data;
|
|
429
|
-
expect(integration).toBe('segment');
|
|
430
|
-
expect(event_name).toBe('PURCHASE');
|
|
431
|
-
expect(event_time).toBe(1652368875449);
|
|
432
|
-
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
433
|
-
expect(action_source).toBe('website');
|
|
303
|
+
},
|
|
304
|
+
mapping: {
|
|
305
|
+
event_type: 'PURCHASE',
|
|
306
|
+
event_conversion_type: 'WEB'
|
|
307
|
+
}
|
|
434
308
|
});
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
309
|
+
const { integration, event_name, event_time, user_data, action_source } = data;
|
|
310
|
+
const { ph } = user_data;
|
|
311
|
+
expect(integration).toBe('segment');
|
|
312
|
+
expect(event_name).toBe('PURCHASE');
|
|
313
|
+
expect(event_time).toBe(1652368875449);
|
|
314
|
+
expect(ph[0]).toBe('dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383');
|
|
315
|
+
expect(action_source).toBe('website');
|
|
316
|
+
});
|
|
317
|
+
it('should handle event with advertising_id as only Snap identifier', async () => {
|
|
318
|
+
const advertisingId = '87a7def4-b6e9-4bf7-91b6-66372842007a';
|
|
319
|
+
const { data } = await reportConversionEvent({
|
|
320
|
+
event: {
|
|
439
321
|
...testEvent,
|
|
440
322
|
properties: {},
|
|
441
323
|
context: {
|
|
@@ -443,140 +325,190 @@ describe('Snap Conversions API ', () => {
|
|
|
443
325
|
advertisingId
|
|
444
326
|
}
|
|
445
327
|
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
auth: {
|
|
452
|
-
accessToken,
|
|
453
|
-
refreshToken
|
|
454
|
-
},
|
|
455
|
-
features,
|
|
456
|
-
mapping: {
|
|
457
|
-
event_type: 'PURCHASE',
|
|
458
|
-
event_conversion_type: 'WEB'
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
const body = JSON.parse(responses[0].options.body);
|
|
462
|
-
const { data } = body;
|
|
463
|
-
expect(data.length).toBe(1);
|
|
464
|
-
const { integration, event_name, event_time, user_data, action_source } = data[0];
|
|
465
|
-
const { madid } = user_data;
|
|
466
|
-
expect(integration).toBe('segment');
|
|
467
|
-
expect(event_name).toBe('PURCHASE');
|
|
468
|
-
expect(event_time).toBe(1652368875449);
|
|
469
|
-
expect(madid).toBe(advertisingId);
|
|
470
|
-
expect(action_source).toBe('website');
|
|
328
|
+
},
|
|
329
|
+
mapping: {
|
|
330
|
+
event_type: 'PURCHASE',
|
|
331
|
+
event_conversion_type: 'WEB'
|
|
332
|
+
}
|
|
471
333
|
});
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
334
|
+
const { integration, event_name, event_time, user_data, action_source } = data;
|
|
335
|
+
const { madid } = user_data;
|
|
336
|
+
expect(integration).toBe('segment');
|
|
337
|
+
expect(event_name).toBe('PURCHASE');
|
|
338
|
+
expect(event_time).toBe(1652368875449);
|
|
339
|
+
expect(madid).toBe(advertisingId);
|
|
340
|
+
expect(action_source).toBe('website');
|
|
341
|
+
});
|
|
342
|
+
it('should handle event with ip and user_agent as only Snap identifiers', async () => {
|
|
343
|
+
const { data } = await reportConversionEvent({
|
|
344
|
+
event: {
|
|
475
345
|
...testEvent,
|
|
476
346
|
properties: {}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
auth: {
|
|
483
|
-
accessToken,
|
|
484
|
-
refreshToken
|
|
485
|
-
},
|
|
486
|
-
features,
|
|
487
|
-
mapping: {
|
|
488
|
-
event_type: 'PURCHASE',
|
|
489
|
-
event_conversion_type: 'WEB'
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
const body = JSON.parse(responses[0].options.body);
|
|
493
|
-
const { data } = body;
|
|
494
|
-
expect(data.length).toBe(1);
|
|
495
|
-
const { integration, event_name, event_time, user_data, action_source } = data[0];
|
|
496
|
-
const { client_ip_address, client_user_agent } = user_data;
|
|
497
|
-
expect(integration).toBe('segment');
|
|
498
|
-
expect(event_name).toBe('PURCHASE');
|
|
499
|
-
expect(event_time).toBe(1652368875449);
|
|
500
|
-
expect(client_ip_address).toBe('8.8.8.8');
|
|
501
|
-
expect(client_user_agent).toBe('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');
|
|
502
|
-
expect(action_source).toBe('website');
|
|
347
|
+
},
|
|
348
|
+
mapping: {
|
|
349
|
+
event_type: 'PURCHASE',
|
|
350
|
+
event_conversion_type: 'WEB'
|
|
351
|
+
}
|
|
503
352
|
});
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
353
|
+
const { integration, event_name, event_time, user_data, action_source } = data;
|
|
354
|
+
const { client_ip_address, client_user_agent } = user_data;
|
|
355
|
+
expect(integration).toBe('segment');
|
|
356
|
+
expect(event_name).toBe('PURCHASE');
|
|
357
|
+
expect(event_time).toBe(1652368875449);
|
|
358
|
+
expect(client_ip_address).toBe('8.8.8.8');
|
|
359
|
+
expect(client_user_agent).toBe('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');
|
|
360
|
+
expect(action_source).toBe('website');
|
|
361
|
+
});
|
|
362
|
+
it('should always use the pixel id in settings for web events', async () => {
|
|
363
|
+
const { url } = await reportConversionEvent({
|
|
364
|
+
event: {
|
|
507
365
|
...testEvent,
|
|
508
366
|
properties: {}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
auth: {
|
|
515
|
-
accessToken,
|
|
516
|
-
refreshToken
|
|
517
|
-
},
|
|
518
|
-
features,
|
|
519
|
-
mapping: {
|
|
520
|
-
event_type: 'PURCHASE',
|
|
521
|
-
event_conversion_type: 'WEB'
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
expect(responses[0].url).toBe(snap_capi_v3_1.buildRequestURL('pixel123', 'access123'));
|
|
367
|
+
},
|
|
368
|
+
mapping: {
|
|
369
|
+
event_type: 'PURCHASE',
|
|
370
|
+
event_conversion_type: 'WEB'
|
|
371
|
+
}
|
|
525
372
|
});
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
373
|
+
expect(url).toBe('https://tr.snapchat.com/v3/pixel123/events?access_token=access123');
|
|
374
|
+
});
|
|
375
|
+
it('should trim a pixel id with leading or trailing whitespace', async () => {
|
|
376
|
+
const { url } = await reportConversionEvent({
|
|
377
|
+
event: {
|
|
529
378
|
...testEvent,
|
|
530
379
|
properties: {}
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
accessToken,
|
|
540
|
-
refreshToken
|
|
541
|
-
},
|
|
542
|
-
features,
|
|
543
|
-
mapping: {
|
|
544
|
-
event_type: 'PURCHASE',
|
|
545
|
-
event_conversion_type: 'WEB'
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
expect(responses[0].url).toBe(snap_capi_v3_1.buildRequestURL('pixel123', 'access123'));
|
|
380
|
+
},
|
|
381
|
+
settings: {
|
|
382
|
+
pixel_id: ' pixel123 '
|
|
383
|
+
},
|
|
384
|
+
mapping: {
|
|
385
|
+
event_type: 'PURCHASE',
|
|
386
|
+
event_conversion_type: 'WEB'
|
|
387
|
+
}
|
|
549
388
|
});
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
389
|
+
expect(url).toBe('https://tr.snapchat.com/v3/pixel123/events?access_token=access123');
|
|
390
|
+
});
|
|
391
|
+
it('should exclude number_items that is not a valid integer', async () => {
|
|
392
|
+
const { url, data } = await reportConversionEvent({
|
|
393
|
+
event: {
|
|
553
394
|
...testEvent,
|
|
554
395
|
properties: {}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
396
|
+
},
|
|
397
|
+
settings: {
|
|
398
|
+
pixel_id: ' pixel123 '
|
|
399
|
+
},
|
|
400
|
+
auth: {
|
|
401
|
+
accessToken: ' access123 ',
|
|
402
|
+
refreshToken: ''
|
|
403
|
+
},
|
|
404
|
+
mapping: {
|
|
405
|
+
event_type: 'PURCHASE',
|
|
406
|
+
event_conversion_type: 'WEB',
|
|
407
|
+
number_items: 'six'
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
expect(url).toBe('https://tr.snapchat.com/v3/pixel123/events?access_token=access123');
|
|
411
|
+
const { custom_data } = data;
|
|
412
|
+
expect(custom_data).toBeUndefined();
|
|
413
|
+
});
|
|
414
|
+
it('supports all the v3 fields', async () => {
|
|
415
|
+
const { data: { action_source, app_data, custom_data, data_processing_options, data_processing_options_country, data_processing_options_state, event_id, event_name, event_source_url, event_time, user_data } } = await reportConversionEvent({
|
|
416
|
+
event: {
|
|
417
|
+
...testEvent,
|
|
418
|
+
properties: {
|
|
419
|
+
currency: 'USD',
|
|
420
|
+
email: ' Test123@gmail.com ',
|
|
421
|
+
phone: '+44 844 412 4653',
|
|
422
|
+
birthday: '19970216',
|
|
423
|
+
gender: 'Male',
|
|
424
|
+
last_name: 'McTest',
|
|
425
|
+
first_name: 'Tester',
|
|
426
|
+
address: {
|
|
427
|
+
city: 'A Fake City',
|
|
428
|
+
state: 'Not Even A State',
|
|
429
|
+
country: 'Bolivia',
|
|
430
|
+
postalCode: '1234'
|
|
431
|
+
},
|
|
432
|
+
query: 'test-query',
|
|
433
|
+
order_id: 'A1234',
|
|
434
|
+
revenue: 1000
|
|
565
435
|
},
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
436
|
+
context: {
|
|
437
|
+
...testEvent.context,
|
|
438
|
+
app: {
|
|
439
|
+
namespace: 'com.segment.app',
|
|
440
|
+
version: '1.0.0'
|
|
441
|
+
},
|
|
442
|
+
device: {
|
|
443
|
+
adTrackingEnabled: true
|
|
444
|
+
},
|
|
445
|
+
screen: {
|
|
446
|
+
width: '1920',
|
|
447
|
+
height: '1080',
|
|
448
|
+
density: '2.0'
|
|
449
|
+
},
|
|
450
|
+
os: {
|
|
451
|
+
version: '19.5'
|
|
452
|
+
}
|
|
571
453
|
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
454
|
+
},
|
|
455
|
+
mapping: {
|
|
456
|
+
event_name: 'PURCHASE',
|
|
457
|
+
action_source: 'app',
|
|
458
|
+
data_processing_options: true,
|
|
459
|
+
data_processing_options_country: 1,
|
|
460
|
+
data_processing_options_state: 1000
|
|
461
|
+
}
|
|
579
462
|
});
|
|
463
|
+
console.log(custom_data);
|
|
464
|
+
expect(action_source).toEqual('app');
|
|
465
|
+
expect(event_name).toEqual('PURCHASE');
|
|
466
|
+
expect(event_id).toEqual(testEvent.messageId);
|
|
467
|
+
expect(event_source_url).toEqual(testEvent.context?.page?.url ?? '');
|
|
468
|
+
expect(event_time).toEqual(Date.parse(testEvent.timestamp));
|
|
469
|
+
expect(data_processing_options).toEqual(['LDU']);
|
|
470
|
+
expect(data_processing_options_country).toEqual(1);
|
|
471
|
+
expect(data_processing_options_state).toEqual(1000);
|
|
472
|
+
expect(app_data.application_tracking_enabled).toEqual(1);
|
|
473
|
+
expect(app_data.extinfo).toEqual([
|
|
474
|
+
'i2',
|
|
475
|
+
'com.segment.app',
|
|
476
|
+
'',
|
|
477
|
+
'1.0.0',
|
|
478
|
+
'19.5',
|
|
479
|
+
'',
|
|
480
|
+
'en-US',
|
|
481
|
+
'',
|
|
482
|
+
'',
|
|
483
|
+
'1920',
|
|
484
|
+
'1080',
|
|
485
|
+
'2.0',
|
|
486
|
+
'',
|
|
487
|
+
'',
|
|
488
|
+
'',
|
|
489
|
+
'Europe/Amsterdam'
|
|
490
|
+
]);
|
|
491
|
+
expect(custom_data.currency).toEqual('USD');
|
|
492
|
+
expect(custom_data.order_id).toEqual('A1234');
|
|
493
|
+
expect(custom_data.search_string).toEqual('test-query');
|
|
494
|
+
expect(custom_data.value).toEqual(1000);
|
|
495
|
+
expect(user_data.external_id[0]).toEqual(utils_1.hash(testEvent.userId ?? ''));
|
|
496
|
+
expect(user_data.em[0]).toEqual(utils_1.hash('test123@gmail.com'));
|
|
497
|
+
expect(user_data.ph[0]).toEqual(utils_1.hash('448444124653'));
|
|
498
|
+
expect(user_data.db).toEqual(utils_1.hash('19970216'));
|
|
499
|
+
expect(user_data.fn).toEqual(utils_1.hash('tester'));
|
|
500
|
+
expect(user_data.ln).toEqual(utils_1.hash('mctest'));
|
|
501
|
+
expect(user_data.ge).toEqual(utils_1.hash('m'));
|
|
502
|
+
expect(user_data.ct).toEqual(utils_1.hash('afakecity'));
|
|
503
|
+
expect(user_data.st).toEqual(utils_1.hash('notevenastate'));
|
|
504
|
+
expect(user_data.country).toEqual(utils_1.hash('bo'));
|
|
505
|
+
expect(user_data.zp).toEqual(utils_1.hash('1234'));
|
|
506
|
+
expect(user_data.client_ip_address).toBe(testEvent.context?.ip);
|
|
507
|
+
expect(user_data.client_user_agent).toBe(testEvent.context?.userAgent);
|
|
508
|
+
expect(user_data.idfv).toBe(testEvent.context?.device?.id);
|
|
509
|
+
expect(user_data.madid).toBe(testEvent.context?.device?.advertisingId);
|
|
510
|
+
expect(user_data.sc_click_id).toEqual(testEvent.integrations?.['Snap Conversions Api']?.click_id);
|
|
511
|
+
expect(user_data.sc_cookie1).toEqual(testEvent.integrations?.['Snap Conversions Api']?.uuid_c1);
|
|
580
512
|
});
|
|
581
513
|
});
|
|
582
514
|
});
|