@segment/action-destinations 3.260.1-staging.1 → 3.261.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/amazon-ads/generated-types.d.ts +0 -9
- package/dist/destinations/amazon-ads/index.d.ts +2 -2
- package/dist/destinations/amazon-ads/index.js +3 -174
- package/dist/destinations/amazon-ads/index.js.map +1 -1
- package/dist/destinations/amazon-ads/syncAudiences/generated-types.d.ts +0 -19
- package/dist/destinations/amazon-ads/syncAudiences/index.js +7 -158
- package/dist/destinations/amazon-ads/syncAudiences/index.js.map +1 -1
- package/dist/destinations/chartmogul/index.js +1 -1
- package/dist/destinations/chartmogul/index.js.map +1 -1
- package/dist/destinations/display-video-360/addToAudience/index.js +1 -2
- package/dist/destinations/display-video-360/addToAudience/index.js.map +1 -1
- package/dist/destinations/engage/utils/EngageActionPerformer.js +2 -17
- package/dist/destinations/engage/utils/EngageActionPerformer.js.map +1 -1
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.d.ts +0 -3
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.js +0 -15
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.js.map +1 -1
- package/dist/destinations/engage/utils/track.d.ts +0 -3
- package/dist/destinations/gameball/index.js +1 -1
- package/dist/destinations/gameball/index.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/functions.js.map +1 -1
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js +4 -4
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js.map +1 -1
- package/dist/destinations/index.js +3 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/inleads-ai/common-fields.d.ts +3 -0
- package/dist/destinations/inleads-ai/common-fields.js +238 -0
- package/dist/destinations/inleads-ai/common-fields.js.map +1 -0
- package/dist/destinations/inleads-ai/contants.d.ts +4 -0
- package/dist/destinations/inleads-ai/contants.js +8 -0
- package/dist/destinations/inleads-ai/contants.js.map +1 -0
- package/dist/destinations/inleads-ai/generated-types.d.ts +3 -0
- package/dist/destinations/inleads-ai/generated-types.js.map +1 -0
- package/dist/destinations/inleads-ai/group/generated-types.d.ts +44 -0
- package/dist/destinations/inleads-ai/group/generated-types.js.map +1 -0
- package/dist/destinations/{responsys/asyncMergePetRecords → inleads-ai/group}/index.d.ts +1 -1
- package/dist/destinations/inleads-ai/group/index.js +76 -0
- package/dist/destinations/inleads-ai/group/index.js.map +1 -0
- package/dist/destinations/inleads-ai/identify/generated-types.d.ts +46 -0
- package/dist/destinations/{engage/sendgrid/Profile.js → inleads-ai/identify/generated-types.js} +1 -1
- package/dist/destinations/inleads-ai/identify/generated-types.js.map +1 -0
- package/dist/destinations/{responsys/asyncMergeProfileListMembers → inleads-ai/identify}/index.d.ts +1 -1
- package/dist/destinations/inleads-ai/identify/index.js +120 -0
- package/dist/destinations/inleads-ai/identify/index.js.map +1 -0
- package/dist/destinations/inleads-ai/index.d.ts +4 -0
- package/dist/destinations/inleads-ai/index.js +66 -0
- package/dist/destinations/inleads-ai/index.js.map +1 -0
- package/dist/destinations/inleads-ai/track/generated-types.d.ts +45 -0
- package/dist/destinations/inleads-ai/track/generated-types.js +3 -0
- package/dist/destinations/inleads-ai/track/generated-types.js.map +1 -0
- package/dist/destinations/inleads-ai/track/index.d.ts +5 -0
- package/dist/destinations/inleads-ai/track/index.js +64 -0
- package/dist/destinations/inleads-ai/track/index.js.map +1 -0
- package/dist/destinations/kameleoon/group/generated-types.d.ts +12 -0
- package/dist/destinations/kameleoon/group/generated-types.js +3 -0
- package/dist/destinations/kameleoon/group/generated-types.js.map +1 -0
- package/dist/destinations/kameleoon/group/index.d.ts +5 -0
- package/dist/destinations/kameleoon/group/index.js +94 -0
- package/dist/destinations/kameleoon/group/index.js.map +1 -0
- package/dist/destinations/kameleoon/identify/generated-types.d.ts +11 -0
- package/dist/destinations/kameleoon/identify/generated-types.js +3 -0
- package/dist/destinations/kameleoon/identify/generated-types.js.map +1 -0
- package/dist/destinations/kameleoon/identify/index.d.ts +5 -0
- package/dist/destinations/kameleoon/identify/index.js +87 -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 +15 -0
- package/dist/destinations/kameleoon/page/generated-types.js +3 -0
- 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 +99 -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/removeProfile/index.js +0 -2
- package/dist/destinations/klaviyo/removeProfile/index.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/liveramp-audiences/audienceEnteredS3/index.js +2 -2
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js.map +1 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js +2 -2
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/addToList/index.js +2 -4
- package/dist/destinations/marketo-static-lists/addToList/index.js.map +1 -1
- package/dist/destinations/moloco-rmp/index.js +2 -2
- package/dist/destinations/segment/segment-properties.js +2 -2
- package/dist/destinations/segment/segment-properties.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/tiktok-conversions/common_fields.d.ts +2 -0
- package/dist/destinations/tiktok-conversions/common_fields.js +244 -0
- package/dist/destinations/tiktok-conversions/common_fields.js.map +1 -0
- package/dist/destinations/{tiktok-offline-conversions/reportOfflineEvent → tiktok-conversions}/formatter.js +11 -11
- package/dist/destinations/tiktok-conversions/formatter.js.map +1 -0
- package/dist/destinations/tiktok-conversions/index.js +163 -75
- package/dist/destinations/tiktok-conversions/index.js.map +1 -1
- package/dist/destinations/tiktok-conversions/reportWebEvent/generated-types.d.ts +12 -4
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.d.ts +1 -1
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.js +5 -233
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.js.map +1 -1
- package/dist/destinations/tiktok-conversions/utils.d.ts +4 -0
- package/dist/destinations/tiktok-conversions/utils.js +65 -0
- package/dist/destinations/tiktok-conversions/utils.js.map +1 -0
- 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/amazon-ads/utils.d.ts +0 -25
- package/dist/destinations/amazon-ads/utils.js +0 -8
- package/dist/destinations/amazon-ads/utils.js.map +0 -1
- 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-conversions/reportWebEvent/formatter.d.ts +0 -3
- package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js +0 -34
- package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js.map +0 -1
- package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.js.map +0 -1
- package/dist/destinations/{responsys/asyncMergePetRecords → inleads-ai}/generated-types.js +0 -0
- package/dist/destinations/{responsys/asyncMergeProfileListMembers → inleads-ai/group}/generated-types.js +0 -0
- package/dist/destinations/{tiktok-offline-conversions/reportOfflineEvent → tiktok-conversions}/formatter.d.ts +1 -1
|
@@ -1,147 +1,621 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.performSnapCAPIv3 =
|
|
3
|
+
exports.performSnapCAPIv3 = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const CURRENCY_ISO_4217_CODES = new Set([
|
|
6
|
+
'USD',
|
|
7
|
+
'AED',
|
|
8
|
+
'AUD',
|
|
9
|
+
'BGN',
|
|
10
|
+
'BRL',
|
|
11
|
+
'CAD',
|
|
12
|
+
'CHF',
|
|
13
|
+
'CLP',
|
|
14
|
+
'CNY',
|
|
15
|
+
'COP',
|
|
16
|
+
'CZK',
|
|
17
|
+
'DKK',
|
|
18
|
+
'EGP',
|
|
19
|
+
'EUR',
|
|
20
|
+
'GBP',
|
|
21
|
+
'GIP',
|
|
22
|
+
'HKD',
|
|
23
|
+
'HRK',
|
|
24
|
+
'HUF',
|
|
25
|
+
'IDR',
|
|
26
|
+
'ILS',
|
|
27
|
+
'INR',
|
|
28
|
+
'JPY',
|
|
29
|
+
'KRW',
|
|
30
|
+
'KWD',
|
|
31
|
+
'KZT',
|
|
32
|
+
'LBP',
|
|
33
|
+
'MXN',
|
|
34
|
+
'MYR',
|
|
35
|
+
'NGN',
|
|
36
|
+
'NOK',
|
|
37
|
+
'NZD',
|
|
38
|
+
'PEN',
|
|
39
|
+
'PHP',
|
|
40
|
+
'PKR',
|
|
41
|
+
'PLN',
|
|
42
|
+
'QAR',
|
|
43
|
+
'RON',
|
|
44
|
+
'RUB',
|
|
45
|
+
'SAR',
|
|
46
|
+
'SEK',
|
|
47
|
+
'SGD',
|
|
48
|
+
'THB',
|
|
49
|
+
'TRY',
|
|
50
|
+
'TWD',
|
|
51
|
+
'TZS',
|
|
52
|
+
'UAH',
|
|
53
|
+
'VND',
|
|
54
|
+
'ZAR',
|
|
55
|
+
'ALL',
|
|
56
|
+
'BHD',
|
|
57
|
+
'DZD',
|
|
58
|
+
'GHS',
|
|
59
|
+
'IQD',
|
|
60
|
+
'ISK',
|
|
61
|
+
'JOD',
|
|
62
|
+
'KES',
|
|
63
|
+
'MAD',
|
|
64
|
+
'OMR',
|
|
65
|
+
'XOF'
|
|
66
|
+
]);
|
|
67
|
+
const US_STATE_CODES = new Map([
|
|
68
|
+
['arizona', 'az'],
|
|
69
|
+
['alabama', 'al'],
|
|
70
|
+
['alaska', 'ak'],
|
|
71
|
+
['arkansas', 'ar'],
|
|
72
|
+
['california', 'ca'],
|
|
73
|
+
['colorado', 'co'],
|
|
74
|
+
['connecticut', 'ct'],
|
|
75
|
+
['delaware', 'de'],
|
|
76
|
+
['florida', 'fl'],
|
|
77
|
+
['georgia', 'ga'],
|
|
78
|
+
['hawaii', 'hi'],
|
|
79
|
+
['idaho', 'id'],
|
|
80
|
+
['illinois', 'il'],
|
|
81
|
+
['indiana', 'in'],
|
|
82
|
+
['iowa', 'ia'],
|
|
83
|
+
['kansas', 'ks'],
|
|
84
|
+
['kentucky', 'ky'],
|
|
85
|
+
['louisiana', 'la'],
|
|
86
|
+
['maine', 'me'],
|
|
87
|
+
['maryland', 'md'],
|
|
88
|
+
['massachusetts', 'ma'],
|
|
89
|
+
['michigan', 'mi'],
|
|
90
|
+
['minnesota', 'mn'],
|
|
91
|
+
['mississippi', 'ms'],
|
|
92
|
+
['missouri', 'mo'],
|
|
93
|
+
['montana', 'mt'],
|
|
94
|
+
['nebraska', 'ne'],
|
|
95
|
+
['nevada', 'nv'],
|
|
96
|
+
['newhampshire', 'nh'],
|
|
97
|
+
['newjersey', 'nj'],
|
|
98
|
+
['newmexico', 'nm'],
|
|
99
|
+
['newyork', 'ny'],
|
|
100
|
+
['northcarolina', 'nc'],
|
|
101
|
+
['northdakota', 'nd'],
|
|
102
|
+
['ohio', 'oh'],
|
|
103
|
+
['oklahoma', 'ok'],
|
|
104
|
+
['oregon', 'or'],
|
|
105
|
+
['pennsylvania', 'pa'],
|
|
106
|
+
['rhodeisland', 'ri'],
|
|
107
|
+
['southcarolina', 'sc'],
|
|
108
|
+
['southdakota', 'sd'],
|
|
109
|
+
['tennessee', 'tn'],
|
|
110
|
+
['texas', 'tx'],
|
|
111
|
+
['utah', 'ut'],
|
|
112
|
+
['vermont', 'vt'],
|
|
113
|
+
['virginia', 'va'],
|
|
114
|
+
['washington', 'wa'],
|
|
115
|
+
['westvirginia', 'wv'],
|
|
116
|
+
['wisconsin', 'wi'],
|
|
117
|
+
['wyoming', 'wy']
|
|
118
|
+
]);
|
|
119
|
+
const COUNTRY_CODES = new Map([
|
|
120
|
+
['afghanistan', 'af'],
|
|
121
|
+
['alandislands', 'ax'],
|
|
122
|
+
['albania', 'al'],
|
|
123
|
+
['algeria', 'dz'],
|
|
124
|
+
['americansamoa', 'as'],
|
|
125
|
+
['andorra', 'ad'],
|
|
126
|
+
['angola', 'ao'],
|
|
127
|
+
['anguilla', 'ai'],
|
|
128
|
+
['antarctica', 'aq'],
|
|
129
|
+
['antiguaandbarbuda', 'ag'],
|
|
130
|
+
['argentina', 'ar'],
|
|
131
|
+
['armenia', 'am'],
|
|
132
|
+
['aruba', 'aw'],
|
|
133
|
+
['australia', 'au'],
|
|
134
|
+
['austria', 'at'],
|
|
135
|
+
['azerbaijan', 'az'],
|
|
136
|
+
['bahamas', 'bs'],
|
|
137
|
+
['bahrain', 'bh'],
|
|
138
|
+
['bangladesh', 'bd'],
|
|
139
|
+
['barbados', 'bb'],
|
|
140
|
+
['belarus', 'by'],
|
|
141
|
+
['belgium', 'be'],
|
|
142
|
+
['belize', 'bz'],
|
|
143
|
+
['benin', 'bj'],
|
|
144
|
+
['bermuda', 'bm'],
|
|
145
|
+
['bhutan', 'bt'],
|
|
146
|
+
['bolivia', 'bo'],
|
|
147
|
+
['bosniaandherzegovina', 'ba'],
|
|
148
|
+
['botswana', 'bw'],
|
|
149
|
+
['bouvetisland', 'bv'],
|
|
150
|
+
['brazil', 'br'],
|
|
151
|
+
['britishindianoceanterritory', 'io'],
|
|
152
|
+
['bruneidarussalam', 'bn'],
|
|
153
|
+
['bulgaria', 'bg'],
|
|
154
|
+
['burkinafaso', 'bf'],
|
|
155
|
+
['burundi', 'bi'],
|
|
156
|
+
['cambodia', 'kh'],
|
|
157
|
+
['cameroon', 'cm'],
|
|
158
|
+
['canada', 'ca'],
|
|
159
|
+
['capeverde', 'cv'],
|
|
160
|
+
['caymanislands', 'ky'],
|
|
161
|
+
['centralafricanrepublic', 'cf'],
|
|
162
|
+
['chad', 'td'],
|
|
163
|
+
['chile', 'cl'],
|
|
164
|
+
['china', 'cn'],
|
|
165
|
+
['christmasisland', 'cx'],
|
|
166
|
+
['cocos(keeling)islands', 'cc'],
|
|
167
|
+
['colombia', 'co'],
|
|
168
|
+
['comoros', 'km'],
|
|
169
|
+
['congo', 'cg'],
|
|
170
|
+
['congo,democraticrepublic', 'cd'],
|
|
171
|
+
['cookislands', 'ck'],
|
|
172
|
+
['costarica', 'cr'],
|
|
173
|
+
["coted'ivoire", 'ci'],
|
|
174
|
+
['croatia', 'hr'],
|
|
175
|
+
['cuba', 'cu'],
|
|
176
|
+
['cyprus', 'cy'],
|
|
177
|
+
['czechrepublic', 'cz'],
|
|
178
|
+
['denmark', 'dk'],
|
|
179
|
+
['djibouti', 'dj'],
|
|
180
|
+
['dominica', 'dm'],
|
|
181
|
+
['dominicanrepublic', 'do'],
|
|
182
|
+
['ecuador', 'ec'],
|
|
183
|
+
['egypt', 'eg'],
|
|
184
|
+
['elsalvador', 'sv'],
|
|
185
|
+
['equatorialguinea', 'gq'],
|
|
186
|
+
['eritrea', 'er'],
|
|
187
|
+
['estonia', 'ee'],
|
|
188
|
+
['ethiopia', 'et'],
|
|
189
|
+
['falklandislands(malvinas)', 'fk'],
|
|
190
|
+
['faroeislands', 'fo'],
|
|
191
|
+
['fiji', 'fj'],
|
|
192
|
+
['finland', 'fi'],
|
|
193
|
+
['france', 'fr'],
|
|
194
|
+
['frenchguiana', 'gf'],
|
|
195
|
+
['frenchpolynesia', 'pf'],
|
|
196
|
+
['frenchsouthernterritories', 'tf'],
|
|
197
|
+
['gabon', 'ga'],
|
|
198
|
+
['gambia', 'gm'],
|
|
199
|
+
['georgia', 'ge'],
|
|
200
|
+
['germany', 'de'],
|
|
201
|
+
['ghana', 'gh'],
|
|
202
|
+
['gibraltar', 'gi'],
|
|
203
|
+
['greece', 'gr'],
|
|
204
|
+
['greenland', 'gl'],
|
|
205
|
+
['grenada', 'gd'],
|
|
206
|
+
['guadeloupe', 'gp'],
|
|
207
|
+
['guam', 'gu'],
|
|
208
|
+
['guatemala', 'gt'],
|
|
209
|
+
['guernsey', 'gg'],
|
|
210
|
+
['guinea', 'gn'],
|
|
211
|
+
['guinea-bissau', 'gw'],
|
|
212
|
+
['guyana', 'gy'],
|
|
213
|
+
['haiti', 'ht'],
|
|
214
|
+
['heardisland&mcdonaldislands', 'hm'],
|
|
215
|
+
['holysee(vaticancitystate)', 'va'],
|
|
216
|
+
['honduras', 'hn'],
|
|
217
|
+
['hongkong', 'hk'],
|
|
218
|
+
['hungary', 'hu'],
|
|
219
|
+
['iceland', 'is'],
|
|
220
|
+
['india', 'in'],
|
|
221
|
+
['indonesia', 'id'],
|
|
222
|
+
['iran,islamicrepublicof', 'ir'],
|
|
223
|
+
['iraq', 'iq'],
|
|
224
|
+
['ireland', 'ie'],
|
|
225
|
+
['isleofman', 'im'],
|
|
226
|
+
['israel', 'il'],
|
|
227
|
+
['italy', 'it'],
|
|
228
|
+
['jamaica', 'jm'],
|
|
229
|
+
['japan', 'jp'],
|
|
230
|
+
['jersey', 'je'],
|
|
231
|
+
['jordan', 'jo'],
|
|
232
|
+
['kazakhstan', 'kz'],
|
|
233
|
+
['kenya', 'ke'],
|
|
234
|
+
['kiribati', 'ki'],
|
|
235
|
+
['korea', 'kr'],
|
|
236
|
+
['kuwait', 'kw'],
|
|
237
|
+
['kyrgyzstan', 'kg'],
|
|
238
|
+
["laopeople'sdemocraticrepublic", 'la'],
|
|
239
|
+
['latvia', 'lv'],
|
|
240
|
+
['lebanon', 'lb'],
|
|
241
|
+
['lesotho', 'ls'],
|
|
242
|
+
['liberia', 'lr'],
|
|
243
|
+
['libyanarabjamahiriya', 'ly'],
|
|
244
|
+
['liechtenstein', 'li'],
|
|
245
|
+
['lithuania', 'lt'],
|
|
246
|
+
['luxembourg', 'lu'],
|
|
247
|
+
['macao', 'mo'],
|
|
248
|
+
['macedonia', 'mk'],
|
|
249
|
+
['madagascar', 'mg'],
|
|
250
|
+
['malawi', 'mw'],
|
|
251
|
+
['malaysia', 'my'],
|
|
252
|
+
['maldives', 'mv'],
|
|
253
|
+
['mali', 'ml'],
|
|
254
|
+
['malta', 'mt'],
|
|
255
|
+
['marshallislands', 'mh'],
|
|
256
|
+
['martinique', 'mq'],
|
|
257
|
+
['mauritania', 'mr'],
|
|
258
|
+
['mauritius', 'mu'],
|
|
259
|
+
['mayotte', 'yt'],
|
|
260
|
+
['mexico', 'mx'],
|
|
261
|
+
['micronesia,federatedstatesof', 'fm'],
|
|
262
|
+
['moldova', 'md'],
|
|
263
|
+
['monaco', 'mc'],
|
|
264
|
+
['mongolia', 'mn'],
|
|
265
|
+
['montenegro', 'me'],
|
|
266
|
+
['montserrat', 'ms'],
|
|
267
|
+
['morocco', 'ma'],
|
|
268
|
+
['mozambique', 'mz'],
|
|
269
|
+
['myanmar', 'mm'],
|
|
270
|
+
['namibia', 'na'],
|
|
271
|
+
['nauru', 'nr'],
|
|
272
|
+
['nepal', 'np'],
|
|
273
|
+
['netherlands', 'nl'],
|
|
274
|
+
['netherlandsantilles', 'an'],
|
|
275
|
+
['newcaledonia', 'nc'],
|
|
276
|
+
['newzealand', 'nz'],
|
|
277
|
+
['nicaragua', 'ni'],
|
|
278
|
+
['niger', 'ne'],
|
|
279
|
+
['nigeria', 'ng'],
|
|
280
|
+
['niue', 'nu'],
|
|
281
|
+
['norfolkisland', 'nf'],
|
|
282
|
+
['northernmarianaislands', 'mp'],
|
|
283
|
+
['norway', 'no'],
|
|
284
|
+
['oman', 'om'],
|
|
285
|
+
['pakistan', 'pk'],
|
|
286
|
+
['palau', 'pw'],
|
|
287
|
+
['palestinianterritory,occupied', 'ps'],
|
|
288
|
+
['panama', 'pa'],
|
|
289
|
+
['papuanewguinea', 'pg'],
|
|
290
|
+
['paraguay', 'py'],
|
|
291
|
+
['peru', 'pe'],
|
|
292
|
+
['philippines', 'ph'],
|
|
293
|
+
['pitcairn', 'pn'],
|
|
294
|
+
['poland', 'pl'],
|
|
295
|
+
['portugal', 'pt'],
|
|
296
|
+
['puertorico', 'pr'],
|
|
297
|
+
['qatar', 'qa'],
|
|
298
|
+
['reunion', 're'],
|
|
299
|
+
['romania', 'ro'],
|
|
300
|
+
['russianfederation', 'ru'],
|
|
301
|
+
['rwanda', 'rw'],
|
|
302
|
+
['saintbarthelemy', 'bl'],
|
|
303
|
+
['sainthelena', 'sh'],
|
|
304
|
+
['saintkittsandnevis', 'kn'],
|
|
305
|
+
['saintlucia', 'lc'],
|
|
306
|
+
['saintmartin', 'mf'],
|
|
307
|
+
['saintpierreandmiquelon', 'pm'],
|
|
308
|
+
['saintvincentandgrenadines', 'vc'],
|
|
309
|
+
['samoa', 'ws'],
|
|
310
|
+
['sanmarino', 'sm'],
|
|
311
|
+
['saotomeandprincipe', 'st'],
|
|
312
|
+
['saudiarabia', 'sa'],
|
|
313
|
+
['senegal', 'sn'],
|
|
314
|
+
['serbia', 'rs'],
|
|
315
|
+
['seychelles', 'sc'],
|
|
316
|
+
['sierraleone', 'sl'],
|
|
317
|
+
['singapore', 'sg'],
|
|
318
|
+
['slovakia', 'sk'],
|
|
319
|
+
['slovenia', 'si'],
|
|
320
|
+
['solomonislands', 'sb'],
|
|
321
|
+
['somalia', 'so'],
|
|
322
|
+
['southafrica', 'za'],
|
|
323
|
+
['southgeorgiaandsandwichisl.', 'gs'],
|
|
324
|
+
['spain', 'es'],
|
|
325
|
+
['srilanka', 'lk'],
|
|
326
|
+
['sudan', 'sd'],
|
|
327
|
+
['suriname', 'sr'],
|
|
328
|
+
['svalbardandjanmayen', 'sj'],
|
|
329
|
+
['swaziland', 'sz'],
|
|
330
|
+
['sweden', 'se'],
|
|
331
|
+
['switzerland', 'ch'],
|
|
332
|
+
['syrianarabrepublic', 'sy'],
|
|
333
|
+
['taiwan', 'tw'],
|
|
334
|
+
['tajikistan', 'tj'],
|
|
335
|
+
['tanzania', 'tz'],
|
|
336
|
+
['thailand', 'th'],
|
|
337
|
+
['timor-leste', 'tl'],
|
|
338
|
+
['togo', 'tg'],
|
|
339
|
+
['tokelau', 'tk'],
|
|
340
|
+
['tonga', 'to'],
|
|
341
|
+
['trinidadandtobago', 'tt'],
|
|
342
|
+
['tunisia', 'tn'],
|
|
343
|
+
['turkey', 'tr'],
|
|
344
|
+
['turkmenistan', 'tm'],
|
|
345
|
+
['turksandcaicosislands', 'tc'],
|
|
346
|
+
['tuvalu', 'tv'],
|
|
347
|
+
['uganda', 'ug'],
|
|
348
|
+
['ukraine', 'ua'],
|
|
349
|
+
['unitedarabemirates', 'ae'],
|
|
350
|
+
['unitedkingdom', 'gb'],
|
|
351
|
+
['unitedstates', 'us'],
|
|
352
|
+
['unitedstatesoutlyingislands', 'um'],
|
|
353
|
+
['uruguay', 'uy'],
|
|
354
|
+
['uzbekistan', 'uz'],
|
|
355
|
+
['vanuatu', 'vu'],
|
|
356
|
+
['venezuela', 've'],
|
|
357
|
+
['vietnam', 'vn'],
|
|
358
|
+
['virginislands,british', 'vg'],
|
|
359
|
+
['virginislands,u.s.', 'vi'],
|
|
360
|
+
['wallisandfutuna', 'wf'],
|
|
361
|
+
['westernsahara', 'eh'],
|
|
362
|
+
['yemen', 'ye'],
|
|
363
|
+
['zambia', 'zm'],
|
|
364
|
+
['zimbabwe', 'zw']
|
|
365
|
+
]);
|
|
366
|
+
const iosAppIDRegex = new RegExp('^[0-9]+$');
|
|
367
|
+
const buildAppData = (payload, settings) => {
|
|
368
|
+
const { app_data } = payload;
|
|
369
|
+
const app_id = utils_1.emptyStringToUndefined(settings.app_id);
|
|
370
|
+
const advertiser_tracking_enabled = app_data?.advertiser_tracking_enabled ? 1 : 0;
|
|
371
|
+
const appDataApplicationTrackingEnabled = app_data?.application_tracking_enabled ? 1 : 0;
|
|
372
|
+
const application_tracking_enabled = app_data != null ? appDataApplicationTrackingEnabled : undefined;
|
|
373
|
+
const appDataExtInfoVersion = app_data?.version;
|
|
374
|
+
const appIDExtInfoVersion = iosAppIDRegex.test(app_id ?? '') ? 'i2' : 'a2';
|
|
375
|
+
const extInfoVersion = appDataExtInfoVersion ?? appIDExtInfoVersion;
|
|
376
|
+
const extinfo = [
|
|
377
|
+
extInfoVersion,
|
|
378
|
+
app_data?.packageName ?? '',
|
|
379
|
+
app_data?.shortVersion ?? '',
|
|
380
|
+
app_data?.longVersion ?? '',
|
|
381
|
+
app_data?.osVersion ?? payload.os_version ?? '',
|
|
382
|
+
app_data?.deviceName ?? payload.device_model ?? '',
|
|
383
|
+
app_data?.locale ?? '',
|
|
384
|
+
app_data?.timezone ?? '',
|
|
385
|
+
app_data?.carrier ?? '',
|
|
386
|
+
app_data?.width ?? '',
|
|
387
|
+
app_data?.height ?? '',
|
|
388
|
+
app_data?.density ?? '',
|
|
389
|
+
app_data?.cpuCores ?? '',
|
|
390
|
+
app_data?.storageSize ?? '',
|
|
391
|
+
app_data?.freeStorage ?? '',
|
|
392
|
+
app_data?.deviceTimezone ?? ''
|
|
393
|
+
];
|
|
394
|
+
return {
|
|
395
|
+
app_id,
|
|
396
|
+
advertiser_tracking_enabled,
|
|
397
|
+
application_tracking_enabled,
|
|
398
|
+
extinfo
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
const buildUserData = (payload) => {
|
|
402
|
+
const { user_data } = payload;
|
|
403
|
+
const normalizedEmail = (user_data?.email ?? payload.email)?.replace(/\s/g, '').toLowerCase();
|
|
404
|
+
const email = utils_1.hashEmailSafe(normalizedEmail);
|
|
405
|
+
const normalizedPhoneNumber = (user_data?.phone ?? payload.phone_number)?.replace(/\D|^0+/g, '');
|
|
406
|
+
const phone_number = utils_1.hash(normalizedPhoneNumber);
|
|
407
|
+
const madid = (user_data?.madid ?? payload.mobile_ad_id)?.toLowerCase();
|
|
408
|
+
const normalizedGender = user_data?.gender?.replace(/\s/g, '').toLowerCase();
|
|
409
|
+
const gender = normalizedGender === 'male' ? 'm' : normalizedGender === 'female' ? 'f' : normalizedGender;
|
|
410
|
+
const hashedGender = utils_1.hash(gender);
|
|
411
|
+
const normalizedLastName = user_data?.lastName?.replace(/\s/g, '')?.toLowerCase();
|
|
412
|
+
const hashedLastName = utils_1.hash(normalizedLastName);
|
|
413
|
+
const normalizedFirstName = user_data?.firstName?.replace(/\s/g, '')?.toLowerCase();
|
|
414
|
+
const hashedFirstName = utils_1.hash(normalizedFirstName);
|
|
415
|
+
const client_ip_address = user_data?.client_ip_address ?? payload.ip_address;
|
|
416
|
+
const client_user_agent = user_data?.client_user_agent ?? payload.user_agent;
|
|
417
|
+
const normalizedCity = user_data?.city?.replace(/\s/g, '')?.toLowerCase();
|
|
418
|
+
const hashedCity = utils_1.hash(normalizedCity);
|
|
419
|
+
const normalizedState = user_data?.state?.replace(/\s/g, '').toLowerCase();
|
|
420
|
+
const state = US_STATE_CODES.get(normalizedState ?? '') ?? normalizedState;
|
|
421
|
+
const hashedState = utils_1.hash(state);
|
|
422
|
+
const normalizedZip = user_data?.zip?.replace(/\s/g, '').toLowerCase();
|
|
423
|
+
const hashedZip = utils_1.hash(normalizedZip);
|
|
424
|
+
const normalizedCountry = user_data?.country?.replace(/\s/g, '').toLowerCase();
|
|
425
|
+
const country = COUNTRY_CODES.get(normalizedCountry ?? '') ?? normalizedCountry;
|
|
426
|
+
const hashedCountry = utils_1.hash(country);
|
|
427
|
+
const external_id = user_data?.externalId?.map((id) => {
|
|
428
|
+
const normalizedId = id.replace(/\s/g, '').toLowerCase();
|
|
429
|
+
return utils_1.hash(normalizedId);
|
|
430
|
+
});
|
|
431
|
+
const db = utils_1.hash(user_data?.dateOfBirth);
|
|
432
|
+
const lead_id = user_data?.leadID;
|
|
433
|
+
const subscription_id = user_data?.subscriptionID;
|
|
434
|
+
const idfv = user_data?.idfv ?? payload.idfv;
|
|
435
|
+
const sc_click_id = user_data?.sc_click_id ?? payload.click_id;
|
|
436
|
+
const sc_cookie1 = user_data?.sc_cookie1 ?? payload.uuid_c1;
|
|
437
|
+
return {
|
|
438
|
+
client_ip_address,
|
|
439
|
+
client_user_agent,
|
|
440
|
+
country: hashedCountry,
|
|
441
|
+
ct: hashedCity,
|
|
442
|
+
db,
|
|
443
|
+
em: utils_1.box(email),
|
|
444
|
+
external_id,
|
|
445
|
+
fn: hashedFirstName,
|
|
446
|
+
ge: hashedGender,
|
|
447
|
+
idfv,
|
|
448
|
+
lead_id,
|
|
449
|
+
ln: hashedLastName,
|
|
450
|
+
madid,
|
|
451
|
+
ph: utils_1.box(phone_number),
|
|
452
|
+
sc_click_id,
|
|
453
|
+
sc_cookie1,
|
|
454
|
+
st: hashedState,
|
|
455
|
+
subscription_id,
|
|
456
|
+
zp: hashedZip
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
const buildCustomData = (payload) => {
|
|
460
|
+
const { custom_data } = payload;
|
|
461
|
+
const products = payload.products?.filter(({ item_id }) => item_id != null);
|
|
462
|
+
const content_ids = products?.map(({ item_id }) => item_id ?? '') ?? utils_1.splitListValueToArray(payload.item_ids ?? '');
|
|
463
|
+
const content_category = products?.map(({ item_category }) => item_category ?? '') ?? utils_1.splitListValueToArray(payload.item_category ?? '');
|
|
464
|
+
const brands = products?.map((product) => product.brand ?? '') ?? payload.brands;
|
|
465
|
+
const num_items = custom_data?.num_items ?? products?.length ?? utils_1.parseNumberSafe(payload.number_items);
|
|
466
|
+
const currency = utils_1.emptyStringToUndefined(custom_data?.currency ?? payload.currency)?.toUpperCase();
|
|
467
|
+
const order_id = utils_1.emptyStringToUndefined(custom_data?.order_id ?? payload.transaction_id);
|
|
468
|
+
const search_string = utils_1.emptyStringToUndefined(custom_data?.search_string ?? payload.search_string);
|
|
469
|
+
const sign_up_method = utils_1.emptyStringToUndefined(custom_data?.sign_up_method ?? payload.sign_up_method);
|
|
470
|
+
const value = custom_data?.value ?? payload.price;
|
|
471
|
+
const checkin_date = utils_1.emptyStringToUndefined(custom_data?.checkin_date);
|
|
472
|
+
const travel_end = utils_1.emptyStringToUndefined(custom_data?.travel_end);
|
|
473
|
+
const travel_start = utils_1.emptyStringToUndefined(custom_data?.travel_start);
|
|
474
|
+
const suggested_destinations = utils_1.emptyStringToUndefined(custom_data?.suggested_destinations);
|
|
475
|
+
const destination_airport = utils_1.emptyStringToUndefined(custom_data?.destination_airport);
|
|
476
|
+
const country = utils_1.emptyStringToUndefined(custom_data?.country);
|
|
477
|
+
const city = utils_1.emptyStringToUndefined(custom_data?.city);
|
|
478
|
+
const region = utils_1.emptyStringToUndefined(custom_data?.region);
|
|
479
|
+
const neighborhood = utils_1.emptyStringToUndefined(custom_data?.neighborhood);
|
|
480
|
+
const departing_departure_date = utils_1.emptyStringToUndefined(custom_data?.departing_departure_date);
|
|
481
|
+
const departing_arrival_date = utils_1.emptyStringToUndefined(custom_data?.departing_arrival_date);
|
|
482
|
+
const num_adults = custom_data?.num_adults;
|
|
483
|
+
const origin_airport = utils_1.emptyStringToUndefined(custom_data?.origin_airport);
|
|
484
|
+
const returning_departure_date = utils_1.emptyStringToUndefined(custom_data?.returning_departure_date);
|
|
485
|
+
const returning_arrival_date = utils_1.emptyStringToUndefined(custom_data?.returning_arrival_date);
|
|
486
|
+
const num_children = custom_data?.num_children;
|
|
487
|
+
const hotel_score = utils_1.emptyStringToUndefined(custom_data?.hotel_score);
|
|
488
|
+
const postal_code = utils_1.emptyStringToUndefined(custom_data?.postal_code);
|
|
489
|
+
const num_infants = custom_data?.num_infants;
|
|
490
|
+
const preferred_neighborhoods = utils_1.emptyStringToUndefined(custom_data?.preferred_neighborhoods);
|
|
491
|
+
const preferred_star_ratings = utils_1.emptyStringToUndefined(custom_data?.preferred_star_ratings);
|
|
492
|
+
const suggested_hotels = utils_1.emptyStringToUndefined(custom_data?.suggested_hotels);
|
|
493
|
+
const dta_fields = {
|
|
494
|
+
checkin_date,
|
|
495
|
+
travel_end,
|
|
496
|
+
travel_start,
|
|
497
|
+
suggested_destinations,
|
|
498
|
+
destination_airport,
|
|
499
|
+
country,
|
|
500
|
+
city,
|
|
501
|
+
region,
|
|
502
|
+
neighborhood,
|
|
503
|
+
departing_departure_date,
|
|
504
|
+
departing_arrival_date,
|
|
505
|
+
num_adults,
|
|
506
|
+
origin_airport,
|
|
507
|
+
returning_departure_date,
|
|
508
|
+
returning_arrival_date,
|
|
509
|
+
num_children,
|
|
510
|
+
hotel_score,
|
|
511
|
+
postal_code,
|
|
512
|
+
num_infants,
|
|
513
|
+
preferred_neighborhoods,
|
|
514
|
+
preferred_star_ratings,
|
|
515
|
+
suggested_hotels
|
|
516
|
+
};
|
|
517
|
+
return utils_1.emptyObjectToUndefined({
|
|
518
|
+
brands,
|
|
519
|
+
content_category,
|
|
520
|
+
content_ids,
|
|
521
|
+
currency,
|
|
522
|
+
num_items,
|
|
523
|
+
order_id,
|
|
524
|
+
search_string,
|
|
525
|
+
sign_up_method,
|
|
526
|
+
value,
|
|
527
|
+
...dta_fields
|
|
528
|
+
});
|
|
13
529
|
};
|
|
14
|
-
exports.validatePayload = validatePayload;
|
|
15
530
|
const eventConversionTypeToActionSource = {
|
|
16
531
|
WEB: 'website',
|
|
17
532
|
MOBILE_APP: 'app',
|
|
18
533
|
OFFLINE: 'OFFLINE'
|
|
19
534
|
};
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'',
|
|
56
|
-
'',
|
|
57
|
-
'',
|
|
58
|
-
'',
|
|
59
|
-
'',
|
|
60
|
-
'',
|
|
61
|
-
'',
|
|
62
|
-
'',
|
|
63
|
-
'',
|
|
64
|
-
''
|
|
65
|
-
]
|
|
66
|
-
: undefined;
|
|
67
|
-
const app_data = action_source === 'app'
|
|
68
|
-
? utils_1.emptyObjectToUndefined({
|
|
69
|
-
app_id,
|
|
70
|
-
advertiser_tracking_enabled,
|
|
71
|
-
extinfo
|
|
72
|
-
})
|
|
73
|
-
: undefined;
|
|
74
|
-
const result = {
|
|
75
|
-
data: [
|
|
76
|
-
{
|
|
77
|
-
integration: 'segment',
|
|
78
|
-
event_id,
|
|
79
|
-
event_name: payload.event_type,
|
|
80
|
-
event_source_url: payload.page_url,
|
|
81
|
-
event_time: Date.parse(payload.timestamp),
|
|
82
|
-
user_data: utils_1.emptyObjectToUndefined({
|
|
83
|
-
client_ip_address: payload.ip_address,
|
|
84
|
-
client_user_agent: payload.user_agent,
|
|
85
|
-
em: utils_1.box(email),
|
|
86
|
-
idfv: payload.idfv,
|
|
87
|
-
madid,
|
|
88
|
-
ph: utils_1.box(phone_number),
|
|
89
|
-
sc_click_id: payload.click_id,
|
|
90
|
-
sc_cookie1: payload.uuid_c1
|
|
91
|
-
}),
|
|
92
|
-
custom_data: utils_1.emptyObjectToUndefined({
|
|
93
|
-
brands,
|
|
94
|
-
content_category,
|
|
95
|
-
content_ids,
|
|
96
|
-
currency: payload.currency,
|
|
97
|
-
num_items,
|
|
98
|
-
order_id: utils_1.emptyStringToUndefined(payload.transaction_id),
|
|
99
|
-
search_string: payload.search_string,
|
|
100
|
-
sign_up_method: payload.sign_up_method,
|
|
101
|
-
value: payload.price
|
|
102
|
-
}),
|
|
103
|
-
action_source,
|
|
104
|
-
app_data
|
|
105
|
-
}
|
|
106
|
-
]
|
|
535
|
+
const getSupportedActionSource = (action_source) => {
|
|
536
|
+
const normalizedActionSource = utils_1.emptyStringToUndefined(action_source);
|
|
537
|
+
return ['website', 'app'].indexOf(normalizedActionSource ?? '') > -1
|
|
538
|
+
? normalizedActionSource
|
|
539
|
+
: normalizedActionSource != null
|
|
540
|
+
? 'OFFLINE'
|
|
541
|
+
: undefined;
|
|
542
|
+
};
|
|
543
|
+
const buildPayloadData = (payload, settings) => {
|
|
544
|
+
const action_source = getSupportedActionSource(payload.action_source) ??
|
|
545
|
+
eventConversionTypeToActionSource[payload.event_conversion_type ?? ''];
|
|
546
|
+
const event_name = payload.event_name ?? payload.event_type;
|
|
547
|
+
const event_source_url = payload.event_source_url ?? payload.page_url;
|
|
548
|
+
const event_id = utils_1.emptyStringToUndefined(payload.event_id) ?? utils_1.emptyStringToUndefined(payload.client_dedup_id);
|
|
549
|
+
const payload_event_time = payload.event_time ?? payload.timestamp;
|
|
550
|
+
const event_time_number = utils_1.parseNumberSafe(payload_event_time ?? '');
|
|
551
|
+
const event_time_date_time = utils_1.parseDateSafe(payload_event_time ?? '');
|
|
552
|
+
const event_time = event_time_date_time ?? event_time_number;
|
|
553
|
+
const app_data = action_source === 'app' ? buildAppData(payload, settings) : undefined;
|
|
554
|
+
const user_data = buildUserData(payload);
|
|
555
|
+
const custom_data = buildCustomData(payload);
|
|
556
|
+
const data_processing_options = payload.data_processing_options ?? false ? ['LDU'] : undefined;
|
|
557
|
+
return {
|
|
558
|
+
integration: 'segment',
|
|
559
|
+
event_id,
|
|
560
|
+
event_name,
|
|
561
|
+
event_source_url,
|
|
562
|
+
event_time,
|
|
563
|
+
user_data,
|
|
564
|
+
custom_data,
|
|
565
|
+
action_source,
|
|
566
|
+
app_data,
|
|
567
|
+
data_processing_options,
|
|
568
|
+
data_processing_options_country: payload.data_processing_options_country,
|
|
569
|
+
data_processing_options_state: payload.data_processing_options_state
|
|
107
570
|
};
|
|
108
|
-
return result;
|
|
109
571
|
};
|
|
110
|
-
|
|
111
|
-
const validateAppOrPixelID = (settings, event_conversion_type) => {
|
|
572
|
+
const validateSettingsConfig = (settings, action_source) => {
|
|
112
573
|
const { snap_app_id, pixel_id } = settings;
|
|
113
574
|
const snapAppID = utils_1.emptyStringToUndefined(snap_app_id);
|
|
114
575
|
const snapPixelID = utils_1.emptyStringToUndefined(pixel_id);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
576
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(action_source === 'OFFLINE' && utils_1.isNullOrUndefined(snapPixelID), 'If event conversion type is "OFFLINE" then Pixel ID must be defined');
|
|
577
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(action_source === 'app' && utils_1.isNullOrUndefined(snapAppID), 'If event conversion type is "MOBILE_APP" then Snap App ID must be defined');
|
|
578
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(action_source === 'website' && utils_1.isNullOrUndefined(snapPixelID), `If event conversion type is "WEB" then Pixel ID must be defined`);
|
|
579
|
+
};
|
|
580
|
+
const buildRequestURL = (settings, action_source, authToken) => {
|
|
581
|
+
const { snap_app_id, pixel_id } = settings;
|
|
582
|
+
const appOrPixelID = utils_1.emptyStringToUndefined((() => {
|
|
583
|
+
switch (action_source) {
|
|
584
|
+
case 'website':
|
|
118
585
|
case 'OFFLINE':
|
|
119
|
-
return
|
|
120
|
-
case '
|
|
121
|
-
return
|
|
586
|
+
return pixel_id;
|
|
587
|
+
case 'app':
|
|
588
|
+
return snap_app_id;
|
|
122
589
|
default:
|
|
123
590
|
return undefined;
|
|
124
591
|
}
|
|
125
|
-
})();
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
592
|
+
})());
|
|
593
|
+
return `https://tr.snapchat.com/v3/${appOrPixelID}/events?access_token=${authToken}`;
|
|
594
|
+
};
|
|
595
|
+
const validatePayload = (payload) => {
|
|
596
|
+
const { action_source, event_name, event_time, custom_data = {}, user_data } = payload;
|
|
597
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIfNullOrUndefined(action_source, "The root value is missing the required field 'action_source'.");
|
|
598
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIfNullOrUndefined(event_name, "The root value is missing the required field 'event_name'.");
|
|
599
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIfNullOrUndefined(event_time, "The root value is missing the required field 'event_time'.");
|
|
600
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(!utils_1.isNullOrUndefined(custom_data.currency) && !CURRENCY_ISO_4217_CODES.has(custom_data.currency), `${custom_data.currency} is not a valid currency code.`);
|
|
601
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(utils_1.isNullOrUndefined(user_data.em) &&
|
|
602
|
+
utils_1.isNullOrUndefined(user_data.ph) &&
|
|
603
|
+
utils_1.isNullOrUndefined(user_data.madid) &&
|
|
604
|
+
(utils_1.isNullOrUndefined(user_data.client_ip_address) || utils_1.isNullOrUndefined(user_data.client_user_agent)), `Payload must contain values for Email or Phone Number or Mobile Ad Identifier or both IP Address and User Agent fields`);
|
|
131
605
|
};
|
|
132
|
-
exports.validateAppOrPixelID = validateAppOrPixelID;
|
|
133
|
-
const buildRequestURL = (appOrPixelID, authToken) => `https://tr.snapchat.com/v3/${appOrPixelID}/events?access_token=${authToken}`;
|
|
134
|
-
exports.buildRequestURL = buildRequestURL;
|
|
135
606
|
const performSnapCAPIv3 = async (request, data) => {
|
|
136
607
|
const { payload, settings } = data;
|
|
137
|
-
const
|
|
608
|
+
const payloadData = buildPayloadData(payload, settings);
|
|
609
|
+
validatePayload(payloadData);
|
|
610
|
+
validateSettingsConfig(settings, payloadData.action_source);
|
|
138
611
|
const authToken = utils_1.emptyStringToUndefined(data.auth?.accessToken);
|
|
139
612
|
utils_1.raiseMisconfiguredRequiredFieldErrorIfNullOrUndefined(authToken, 'Missing valid auth token');
|
|
140
|
-
const url =
|
|
141
|
-
const json = exports.formatPayload(exports.validatePayload(payload), settings);
|
|
613
|
+
const url = buildRequestURL(settings, payloadData.action_source, authToken);
|
|
142
614
|
return request(url, {
|
|
143
615
|
method: 'post',
|
|
144
|
-
json
|
|
616
|
+
json: {
|
|
617
|
+
data: [payloadData]
|
|
618
|
+
}
|
|
145
619
|
});
|
|
146
620
|
};
|
|
147
621
|
exports.performSnapCAPIv3 = performSnapCAPIv3;
|