@segment/action-destinations 3.261.0 → 3.261.1-staging.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 +9 -0
- package/dist/destinations/amazon-ads/index.d.ts +2 -2
- package/dist/destinations/amazon-ads/index.js +180 -3
- package/dist/destinations/amazon-ads/index.js.map +1 -1
- package/dist/destinations/amazon-ads/syncAudiences/generated-types.d.ts +19 -0
- package/dist/destinations/amazon-ads/syncAudiences/index.js +158 -7
- package/dist/destinations/amazon-ads/syncAudiences/index.js.map +1 -1
- package/dist/destinations/amazon-ads/utils.d.ts +25 -0
- package/dist/destinations/amazon-ads/utils.js +8 -0
- package/dist/destinations/amazon-ads/utils.js.map +1 -0
- 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 +2 -1
- package/dist/destinations/display-video-360/addToAudience/index.js.map +1 -1
- package/dist/destinations/engage/sendgrid/Profile.d.ts +6 -0
- package/dist/destinations/{inleads-ai/identify/generated-types.js → engage/sendgrid/Profile.js} +1 -1
- package/dist/destinations/engage/sendgrid/Profile.js.map +1 -0
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.d.ts +21 -0
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js +174 -0
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js.map +1 -0
- package/dist/destinations/engage/utils/EngageActionPerformer.js +17 -2
- package/dist/destinations/engage/utils/EngageActionPerformer.js.map +1 -1
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.d.ts +3 -0
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.js +15 -0
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.js.map +1 -1
- package/dist/destinations/engage/utils/track.d.ts +3 -0
- 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 +0 -3
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/kameleoon/index.js +9 -15
- package/dist/destinations/kameleoon/index.js.map +1 -1
- package/dist/destinations/kameleoon/logEvent/generated-types.d.ts +0 -2
- package/dist/destinations/kameleoon/logEvent/index.js +1 -13
- package/dist/destinations/kameleoon/logEvent/index.js.map +1 -1
- package/dist/destinations/klaviyo/functions.d.ts +7 -4
- package/dist/destinations/klaviyo/functions.js +80 -1
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/removeProfile/index.js +2 -0
- package/dist/destinations/klaviyo/removeProfile/index.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +97 -0
- package/dist/destinations/klaviyo/upsertProfile/index.js +29 -19
- 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 +4 -2
- package/dist/destinations/marketo-static-lists/addToList/index.js.map +1 -1
- package/dist/destinations/mixpanel/utils.d.ts +13 -0
- package/dist/destinations/mixpanel/utils.js +117 -0
- package/dist/destinations/mixpanel/utils.js.map +1 -0
- package/dist/destinations/moloco-rmp/index.js +2 -2
- package/dist/destinations/responsys/asyncMergePetRecords/generated-types.d.ts +14 -0
- package/dist/destinations/responsys/asyncMergePetRecords/generated-types.js.map +1 -0
- package/dist/destinations/{kameleoon/group → responsys/asyncMergePetRecords}/index.d.ts +1 -1
- package/dist/destinations/responsys/asyncMergePetRecords/index.js +113 -0
- package/dist/destinations/responsys/asyncMergePetRecords/index.js.map +1 -0
- package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.d.ts +20 -0
- package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.js.map +1 -0
- package/dist/destinations/{inleads-ai/group → responsys/asyncMergeProfileListMembers}/index.d.ts +1 -1
- package/dist/destinations/responsys/asyncMergeProfileListMembers/index.js +174 -0
- package/dist/destinations/responsys/asyncMergeProfileListMembers/index.js.map +1 -0
- package/dist/destinations/responsys/rsp-operations.d.ts +14 -0
- package/dist/destinations/responsys/rsp-operations.js +33 -0
- package/dist/destinations/responsys/rsp-operations.js.map +1 -0
- package/dist/destinations/responsys/rsp-properties.d.ts +4 -0
- package/dist/destinations/responsys/rsp-properties.js +27 -0
- package/dist/destinations/responsys/rsp-properties.js.map +1 -0
- 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_/capiV2tests.d.ts +1 -0
- package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.js +381 -0
- package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.js.map +1 -0
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.d.ts +1 -0
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.js +581 -0
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.js.map +1 -0
- package/dist/destinations/snap-conversions-api/_tests_/index.test.js +488 -420
- 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 +18 -97
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js +29 -7
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js.map +1 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.d.ts +4 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.js +97 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.js.map +1 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v3.d.ts +4 -0
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v3.js +119 -593
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v3.js.map +1 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/utils.d.ts +4 -3
- package/dist/destinations/snap-conversions-api/reportConversionEvent/utils.js +1 -6
- package/dist/destinations/snap-conversions-api/reportConversionEvent/utils.js.map +1 -1
- package/dist/destinations/snap-conversions-api/snap-capi-properties.d.ts +30 -0
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js +316 -0
- package/dist/destinations/snap-conversions-api/snap-capi-properties.js.map +1 -0
- package/dist/destinations/stackadapt/forwardEvent/generated-types.d.ts +4 -4
- package/dist/destinations/stackadapt/forwardEvent/index.js +7 -11
- package/dist/destinations/stackadapt/forwardEvent/index.js.map +1 -1
- package/dist/destinations/tiktok-conversions/index.js +75 -163
- package/dist/destinations/tiktok-conversions/index.js.map +1 -1
- package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.d.ts +3 -0
- package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js +34 -0
- package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js.map +1 -0
- package/dist/destinations/tiktok-conversions/reportWebEvent/generated-types.d.ts +4 -12
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.d.ts +1 -1
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.js +233 -5
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.js.map +1 -1
- package/dist/destinations/{tiktok-conversions → tiktok-offline-conversions/reportOfflineEvent}/formatter.js +11 -11
- package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.js.map +1 -0
- package/package.json +4 -4
- package/dist/destinations/inleads-ai/common-fields.d.ts +0 -3
- package/dist/destinations/inleads-ai/common-fields.js +0 -238
- package/dist/destinations/inleads-ai/common-fields.js.map +0 -1
- package/dist/destinations/inleads-ai/contants.d.ts +0 -4
- package/dist/destinations/inleads-ai/contants.js +0 -8
- package/dist/destinations/inleads-ai/contants.js.map +0 -1
- package/dist/destinations/inleads-ai/generated-types.d.ts +0 -3
- package/dist/destinations/inleads-ai/generated-types.js.map +0 -1
- package/dist/destinations/inleads-ai/group/generated-types.d.ts +0 -44
- package/dist/destinations/inleads-ai/group/generated-types.js.map +0 -1
- package/dist/destinations/inleads-ai/group/index.js +0 -76
- package/dist/destinations/inleads-ai/group/index.js.map +0 -1
- package/dist/destinations/inleads-ai/identify/generated-types.d.ts +0 -46
- package/dist/destinations/inleads-ai/identify/generated-types.js.map +0 -1
- package/dist/destinations/inleads-ai/identify/index.d.ts +0 -5
- package/dist/destinations/inleads-ai/identify/index.js +0 -120
- package/dist/destinations/inleads-ai/identify/index.js.map +0 -1
- package/dist/destinations/inleads-ai/index.d.ts +0 -4
- package/dist/destinations/inleads-ai/index.js +0 -66
- package/dist/destinations/inleads-ai/index.js.map +0 -1
- package/dist/destinations/inleads-ai/track/generated-types.d.ts +0 -45
- package/dist/destinations/inleads-ai/track/generated-types.js +0 -3
- package/dist/destinations/inleads-ai/track/generated-types.js.map +0 -1
- package/dist/destinations/inleads-ai/track/index.d.ts +0 -5
- package/dist/destinations/inleads-ai/track/index.js +0 -64
- package/dist/destinations/inleads-ai/track/index.js.map +0 -1
- package/dist/destinations/kameleoon/group/generated-types.d.ts +0 -12
- package/dist/destinations/kameleoon/group/generated-types.js +0 -3
- package/dist/destinations/kameleoon/group/generated-types.js.map +0 -1
- package/dist/destinations/kameleoon/group/index.js +0 -94
- package/dist/destinations/kameleoon/group/index.js.map +0 -1
- package/dist/destinations/kameleoon/identify/generated-types.d.ts +0 -11
- package/dist/destinations/kameleoon/identify/generated-types.js +0 -3
- package/dist/destinations/kameleoon/identify/generated-types.js.map +0 -1
- package/dist/destinations/kameleoon/identify/index.d.ts +0 -5
- package/dist/destinations/kameleoon/identify/index.js +0 -87
- package/dist/destinations/kameleoon/identify/index.js.map +0 -1
- package/dist/destinations/kameleoon/page/generated-types.d.ts +0 -15
- package/dist/destinations/kameleoon/page/generated-types.js +0 -3
- package/dist/destinations/kameleoon/page/generated-types.js.map +0 -1
- package/dist/destinations/kameleoon/page/index.d.ts +0 -5
- package/dist/destinations/kameleoon/page/index.js +0 -99
- package/dist/destinations/kameleoon/page/index.js.map +0 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-deprecated.d.ts +0 -31
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-deprecated.js +0 -174
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-deprecated.js.map +0 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-v3.d.ts +0 -16
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-v3.js +0 -640
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-input-fields-v3.js.map +0 -1
- package/dist/destinations/spiffy/generated-types.d.ts +0 -5
- package/dist/destinations/spiffy/generated-types.js +0 -3
- package/dist/destinations/spiffy/generated-types.js.map +0 -1
- package/dist/destinations/spiffy/index.d.ts +0 -4
- package/dist/destinations/spiffy/index.js +0 -62
- package/dist/destinations/spiffy/index.js.map +0 -1
- package/dist/destinations/spiffy/send/generated-types.d.ts +0 -8
- package/dist/destinations/spiffy/send/generated-types.js +0 -3
- package/dist/destinations/spiffy/send/generated-types.js.map +0 -1
- package/dist/destinations/spiffy/send/index.d.ts +0 -5
- package/dist/destinations/spiffy/send/index.js +0 -42
- package/dist/destinations/spiffy/send/index.js.map +0 -1
- package/dist/destinations/tiktok-conversions/common_fields.d.ts +0 -2
- package/dist/destinations/tiktok-conversions/common_fields.js +0 -244
- package/dist/destinations/tiktok-conversions/common_fields.js.map +0 -1
- package/dist/destinations/tiktok-conversions/formatter.js.map +0 -1
- package/dist/destinations/tiktok-conversions/utils.d.ts +0 -4
- package/dist/destinations/tiktok-conversions/utils.js +0 -65
- package/dist/destinations/tiktok-conversions/utils.js.map +0 -1
- package/dist/destinations/xtremepush/generated-types.d.ts +0 -4
- package/dist/destinations/xtremepush/generated-types.js +0 -3
- package/dist/destinations/xtremepush/generated-types.js.map +0 -1
- package/dist/destinations/xtremepush/identify/generated-types.d.ts +0 -14
- package/dist/destinations/xtremepush/identify/generated-types.js +0 -3
- package/dist/destinations/xtremepush/identify/generated-types.js.map +0 -1
- package/dist/destinations/xtremepush/identify/index.d.ts +0 -5
- package/dist/destinations/xtremepush/identify/index.js +0 -87
- package/dist/destinations/xtremepush/identify/index.js.map +0 -1
- package/dist/destinations/xtremepush/index.d.ts +0 -4
- package/dist/destinations/xtremepush/index.js +0 -66
- package/dist/destinations/xtremepush/index.js.map +0 -1
- package/dist/destinations/xtremepush/track/generated-types.d.ts +0 -15
- package/dist/destinations/xtremepush/track/generated-types.js +0 -3
- package/dist/destinations/xtremepush/track/generated-types.js.map +0 -1
- package/dist/destinations/xtremepush/track/index.d.ts +0 -5
- package/dist/destinations/xtremepush/track/index.js +0 -95
- package/dist/destinations/xtremepush/track/index.js.map +0 -1
- package/dist/destinations/{inleads-ai → responsys/asyncMergePetRecords}/generated-types.js +0 -0
- package/dist/destinations/{inleads-ai/group → responsys/asyncMergeProfileListMembers}/generated-types.js +0 -0
- package/dist/destinations/{tiktok-conversions → tiktok-offline-conversions/reportOfflineEvent}/formatter.d.ts +1 -1
|
@@ -1,621 +1,147 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.performSnapCAPIv3 = void 0;
|
|
3
|
+
exports.performSnapCAPIv3 = exports.buildRequestURL = exports.validateAppOrPixelID = exports.formatPayload = exports.validatePayload = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
});
|
|
5
|
+
const snap_capi_properties_1 = require("../snap-capi-properties");
|
|
6
|
+
const validatePayload = (payload) => {
|
|
7
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(!utils_1.isNullOrUndefined(payload.currency) && !snap_capi_properties_1.CURRENCY_ISO_4217_CODES.has(payload.currency.toUpperCase()), `${payload.currency} is not a valid currency code.`);
|
|
8
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(utils_1.isNullOrUndefined(payload.email) &&
|
|
9
|
+
utils_1.isNullOrUndefined(payload.phone_number) &&
|
|
10
|
+
utils_1.isNullOrUndefined(payload.mobile_ad_id) &&
|
|
11
|
+
(utils_1.isNullOrUndefined(payload.ip_address) || utils_1.isNullOrUndefined(payload.user_agent)), `Payload must contain values for Email or Phone Number or Mobile Ad Identifier or both IP Address and User Agent fields`);
|
|
12
|
+
return payload;
|
|
529
13
|
};
|
|
14
|
+
exports.validatePayload = validatePayload;
|
|
530
15
|
const eventConversionTypeToActionSource = {
|
|
531
16
|
WEB: 'website',
|
|
532
17
|
MOBILE_APP: 'app',
|
|
533
18
|
OFFLINE: 'OFFLINE'
|
|
534
19
|
};
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
20
|
+
const iosAppIDRegex = new RegExp('^[0-9]+$');
|
|
21
|
+
const formatPayload = (payload, settings) => {
|
|
22
|
+
const app_id = utils_1.emptyStringToUndefined(settings.app_id);
|
|
23
|
+
const action_source = eventConversionTypeToActionSource[payload.event_conversion_type];
|
|
24
|
+
const event_id = utils_1.emptyStringToUndefined(payload.client_dedup_id);
|
|
25
|
+
const email = utils_1.hashEmailSafe(payload.email?.replace(/\s/g, '').toLowerCase());
|
|
26
|
+
const phone_number = utils_1.hash(payload.phone_number?.replace(/\D|^0+/g, ''));
|
|
27
|
+
const madid = payload.mobile_ad_id?.toLowerCase();
|
|
28
|
+
const products = (payload.products ?? []).filter(({ item_id }) => item_id != null);
|
|
29
|
+
const { content_ids, content_category, brands, num_items } = products.length > 0
|
|
30
|
+
? {
|
|
31
|
+
content_ids: products.map(({ item_id }) => item_id),
|
|
32
|
+
content_category: products.map(({ item_category }) => item_category ?? ''),
|
|
33
|
+
brands: products.map((product) => product.brand ?? ''),
|
|
34
|
+
num_items: products.length
|
|
35
|
+
}
|
|
36
|
+
: (() => {
|
|
37
|
+
const content_ids = utils_1.splitListValueToArray(payload.item_ids ?? '');
|
|
38
|
+
return {
|
|
39
|
+
content_ids,
|
|
40
|
+
content_category: utils_1.splitListValueToArray(payload.item_category ?? ''),
|
|
41
|
+
brands: payload.brands,
|
|
42
|
+
num_items: utils_1.parseNumberSafe(payload.number_items) ?? content_ids?.length
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
const advertiser_tracking_enabled = !utils_1.isNullOrUndefined(app_id) ? 0 : undefined;
|
|
46
|
+
const extInfoVersion = iosAppIDRegex.test((app_id ?? '').trim()) ? 'i2' : 'a2';
|
|
47
|
+
const extinfo = !utils_1.isNullOrUndefined(app_id)
|
|
48
|
+
? [
|
|
49
|
+
extInfoVersion,
|
|
50
|
+
'',
|
|
51
|
+
'',
|
|
52
|
+
'',
|
|
53
|
+
payload.os_version ?? '',
|
|
54
|
+
payload.device_model ?? '',
|
|
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
|
+
]
|
|
570
107
|
};
|
|
108
|
+
return result;
|
|
571
109
|
};
|
|
572
|
-
|
|
110
|
+
exports.formatPayload = formatPayload;
|
|
111
|
+
const validateAppOrPixelID = (settings, event_conversion_type) => {
|
|
573
112
|
const { snap_app_id, pixel_id } = settings;
|
|
574
113
|
const snapAppID = utils_1.emptyStringToUndefined(snap_app_id);
|
|
575
114
|
const snapPixelID = utils_1.emptyStringToUndefined(pixel_id);
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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':
|
|
115
|
+
const appOrPixelID = (() => {
|
|
116
|
+
switch (event_conversion_type) {
|
|
117
|
+
case 'WEB':
|
|
585
118
|
case 'OFFLINE':
|
|
586
|
-
return
|
|
587
|
-
case '
|
|
588
|
-
return
|
|
119
|
+
return snapPixelID;
|
|
120
|
+
case 'MOBILE_APP':
|
|
121
|
+
return snapAppID;
|
|
589
122
|
default:
|
|
590
123
|
return undefined;
|
|
591
124
|
}
|
|
592
|
-
})()
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
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`);
|
|
125
|
+
})();
|
|
126
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(event_conversion_type === 'OFFLINE' && utils_1.isNullOrUndefined(snapPixelID), 'If event conversion type is "OFFLINE" then Pixel ID must be defined');
|
|
127
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(event_conversion_type === 'MOBILE_APP' && utils_1.isNullOrUndefined(snapAppID), 'If event conversion type is "MOBILE_APP" then Snap App ID must be defined');
|
|
128
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIf(event_conversion_type === 'WEB' && utils_1.isNullOrUndefined(snapPixelID), `If event conversion type is "${event_conversion_type}" then Pixel ID must be defined`);
|
|
129
|
+
utils_1.raiseMisconfiguredRequiredFieldErrorIfNullOrUndefined(appOrPixelID, 'Missing valid app or pixel ID');
|
|
130
|
+
return appOrPixelID;
|
|
605
131
|
};
|
|
132
|
+
exports.validateAppOrPixelID = validateAppOrPixelID;
|
|
133
|
+
const buildRequestURL = (appOrPixelID, authToken) => `https://tr.snapchat.com/v3/${appOrPixelID}/events?access_token=${authToken}`;
|
|
134
|
+
exports.buildRequestURL = buildRequestURL;
|
|
606
135
|
const performSnapCAPIv3 = async (request, data) => {
|
|
607
136
|
const { payload, settings } = data;
|
|
608
|
-
const
|
|
609
|
-
validatePayload(payloadData);
|
|
610
|
-
validateSettingsConfig(settings, payloadData.action_source);
|
|
137
|
+
const { event_conversion_type } = payload;
|
|
611
138
|
const authToken = utils_1.emptyStringToUndefined(data.auth?.accessToken);
|
|
612
139
|
utils_1.raiseMisconfiguredRequiredFieldErrorIfNullOrUndefined(authToken, 'Missing valid auth token');
|
|
613
|
-
const url = buildRequestURL(settings,
|
|
140
|
+
const url = exports.buildRequestURL(exports.validateAppOrPixelID(settings, event_conversion_type), authToken);
|
|
141
|
+
const json = exports.formatPayload(exports.validatePayload(payload), settings);
|
|
614
142
|
return request(url, {
|
|
615
143
|
method: 'post',
|
|
616
|
-
json
|
|
617
|
-
data: [payloadData]
|
|
618
|
-
}
|
|
144
|
+
json
|
|
619
145
|
});
|
|
620
146
|
};
|
|
621
147
|
exports.performSnapCAPIv3 = performSnapCAPIv3;
|