@segment/action-destinations 3.478.0 → 3.478.1-staging-7ad09fc36.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-amc/function.d.ts +4 -3
- package/dist/destinations/amazon-amc/function.js +51 -8
- package/dist/destinations/amazon-amc/function.js.map +1 -1
- package/dist/destinations/amazon-amc/syncAudiencesToDSP/generated-types.d.ts +7 -0
- package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.js +58 -4
- package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.js.map +1 -1
- package/dist/destinations/amazon-amc/types.d.ts +24 -8
- package/dist/destinations/amazon-amc/types.js.map +1 -1
- package/dist/destinations/amazon-amc/utils.d.ts +3 -0
- package/dist/destinations/amazon-amc/utils.js +24 -1
- package/dist/destinations/amazon-amc/utils.js.map +1 -1
- package/dist/destinations/amplitude-cohorts/index.js +2 -2
- package/dist/destinations/amplitude-cohorts/index.js.map +1 -1
- package/dist/destinations/amplitude-cohorts/syncAudience/fields.js +6 -49
- package/dist/destinations/amplitude-cohorts/syncAudience/fields.js.map +1 -1
- package/dist/destinations/amplitude-cohorts/syncAudience/functions.d.ts +2 -2
- package/dist/destinations/amplitude-cohorts/syncAudience/functions.js +10 -8
- package/dist/destinations/amplitude-cohorts/syncAudience/functions.js.map +1 -1
- package/dist/destinations/amplitude-cohorts/syncAudience/generated-types.d.ts +1 -8
- package/dist/destinations/amplitude-cohorts/syncAudience/index.js +4 -4
- package/dist/destinations/amplitude-cohorts/syncAudience/index.js.map +1 -1
- package/dist/destinations/braze-cohorts/syncAudiences/index.js +28 -11
- package/dist/destinations/braze-cohorts/syncAudiences/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/addToCart/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/addToCart/index.js +4 -87
- package/dist/destinations/facebook-conversions-api/addToCart/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/addToCart2/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/addToCart2/index.js +4 -86
- package/dist/destinations/facebook-conversions-api/addToCart2/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/constants.d.ts +11 -0
- package/dist/destinations/facebook-conversions-api/constants.js +12 -1
- package/dist/destinations/facebook-conversions-api/constants.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/custom/generated-types.d.ts +9 -0
- package/dist/destinations/facebook-conversions-api/custom/index.js +5 -53
- package/dist/destinations/facebook-conversions-api/custom/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/custom2/generated-types.d.ts +9 -0
- package/dist/destinations/facebook-conversions-api/custom2/index.js +5 -52
- package/dist/destinations/facebook-conversions-api/custom2/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/{fb-capi-properties.d.ts → fields.d.ts} +14 -10
- package/dist/destinations/facebook-conversions-api/fields.js +842 -0
- package/dist/destinations/facebook-conversions-api/fields.js.map +1 -0
- package/dist/destinations/facebook-conversions-api/functions.d.ts +37 -0
- package/dist/destinations/facebook-conversions-api/functions.js +425 -0
- package/dist/destinations/facebook-conversions-api/functions.js.map +1 -0
- package/dist/destinations/facebook-conversions-api/initiateCheckout/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/initiateCheckout/index.js +4 -90
- package/dist/destinations/facebook-conversions-api/initiateCheckout/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/initiateCheckout2/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/initiateCheckout2/index.js +4 -89
- package/dist/destinations/facebook-conversions-api/initiateCheckout2/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/pageView/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/pageView/index.js +5 -46
- package/dist/destinations/facebook-conversions-api/pageView/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/pageView2/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/pageView2/index.js +5 -45
- package/dist/destinations/facebook-conversions-api/pageView2/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/purchase/generated-types.d.ts +11 -0
- package/dist/destinations/facebook-conversions-api/purchase/index.js +4 -95
- package/dist/destinations/facebook-conversions-api/purchase/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/purchase2/generated-types.d.ts +11 -0
- package/dist/destinations/facebook-conversions-api/purchase2/index.js +5 -4
- package/dist/destinations/facebook-conversions-api/purchase2/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/search/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/search/index.js +4 -94
- package/dist/destinations/facebook-conversions-api/search/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/search2/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/search2/index.js +4 -93
- package/dist/destinations/facebook-conversions-api/search2/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/types.d.ts +182 -0
- package/dist/destinations/facebook-conversions-api/types.js +3 -0
- package/dist/destinations/facebook-conversions-api/types.js.map +1 -0
- package/dist/destinations/facebook-conversions-api/viewContent/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/viewContent/index.js +4 -89
- package/dist/destinations/facebook-conversions-api/viewContent/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/viewContent2/generated-types.d.ts +1 -0
- package/dist/destinations/facebook-conversions-api/viewContent2/index.js +4 -88
- package/dist/destinations/facebook-conversions-api/viewContent2/index.js.map +1 -1
- package/dist/destinations/facebook-custom-audiences/constants.d.ts +1 -2
- package/dist/destinations/facebook-custom-audiences/constants.js +2 -54
- package/dist/destinations/facebook-custom-audiences/constants.js.map +1 -1
- package/dist/destinations/facebook-custom-audiences/fields.d.ts +3 -0
- package/dist/destinations/facebook-custom-audiences/fields.js +16 -0
- package/dist/destinations/facebook-custom-audiences/fields.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/functions.d.ts +19 -0
- package/dist/destinations/facebook-custom-audiences/functions.js +94 -0
- package/dist/destinations/facebook-custom-audiences/functions.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/generated-types.d.ts +1 -1
- package/dist/destinations/facebook-custom-audiences/index.js +25 -105
- package/dist/destinations/facebook-custom-audiences/index.js.map +1 -1
- package/dist/destinations/facebook-custom-audiences/presets.d.ts +2 -0
- package/dist/destinations/facebook-custom-audiences/presets.js +39 -0
- package/dist/destinations/facebook-custom-audiences/presets.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/sync/constants.d.ts +3 -0
- package/dist/destinations/facebook-custom-audiences/sync/constants.js +90 -0
- package/dist/destinations/facebook-custom-audiences/sync/constants.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/sync/fields.d.ts +7 -0
- package/dist/destinations/facebook-custom-audiences/sync/fields.js +269 -0
- package/dist/destinations/facebook-custom-audiences/sync/fields.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/sync/functions.d.ts +33 -0
- package/dist/destinations/facebook-custom-audiences/sync/functions.js +245 -0
- package/dist/destinations/facebook-custom-audiences/sync/functions.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/sync/generated-types.d.ts +3 -2
- package/dist/destinations/facebook-custom-audiences/sync/hook-functions.d.ts +45 -0
- package/dist/destinations/facebook-custom-audiences/sync/hook-functions.js +99 -0
- package/dist/destinations/facebook-custom-audiences/sync/hook-functions.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/sync/index.js +18 -267
- package/dist/destinations/facebook-custom-audiences/sync/index.js.map +1 -1
- package/dist/destinations/facebook-custom-audiences/sync/types.d.ts +35 -0
- package/dist/destinations/facebook-custom-audiences/sync/types.js +3 -0
- package/dist/destinations/facebook-custom-audiences/sync/types.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/types.d.ts +40 -0
- package/dist/destinations/facebook-custom-audiences/types.js +3 -0
- package/dist/destinations/facebook-custom-audiences/types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/functions.d.ts +3 -3
- package/dist/destinations/google-enhanced-conversions/functions.js +57 -31
- package/dist/destinations/google-enhanced-conversions/functions.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/userList/index.js +5 -5
- package/dist/destinations/google-enhanced-conversions/userList/index.js.map +1 -1
- package/dist/destinations/linkedin-audiences/updateAudience/functions.d.ts +2 -2
- package/dist/destinations/linkedin-audiences/updateAudience/functions.js +40 -16
- package/dist/destinations/linkedin-audiences/updateAudience/functions.js.map +1 -1
- package/dist/destinations/linkedin-audiences/updateAudience/index.js +4 -4
- package/dist/destinations/linkedin-audiences/updateAudience/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/destinations/facebook-conversions-api/fb-capi-app-data.d.ts +0 -11
- package/dist/destinations/facebook-conversions-api/fb-capi-app-data.js +0 -188
- package/dist/destinations/facebook-conversions-api/fb-capi-app-data.js.map +0 -1
- package/dist/destinations/facebook-conversions-api/fb-capi-properties.js +0 -185
- package/dist/destinations/facebook-conversions-api/fb-capi-properties.js.map +0 -1
- package/dist/destinations/facebook-conversions-api/fb-capi-user-data.d.ts +0 -7
- package/dist/destinations/facebook-conversions-api/fb-capi-user-data.js +0 -272
- package/dist/destinations/facebook-conversions-api/fb-capi-user-data.js.map +0 -1
- package/dist/destinations/facebook-conversions-api/purchase2/fields.d.ts +0 -2
- package/dist/destinations/facebook-conversions-api/purchase2/fields.js +0 -50
- package/dist/destinations/facebook-conversions-api/purchase2/fields.js.map +0 -1
- package/dist/destinations/facebook-conversions-api/purchase2/functions.d.ts +0 -4
- package/dist/destinations/facebook-conversions-api/purchase2/functions.js +0 -59
- package/dist/destinations/facebook-conversions-api/purchase2/functions.js.map +0 -1
- package/dist/destinations/facebook-conversions-api/utils.d.ts +0 -3
- package/dist/destinations/facebook-conversions-api/utils.js +0 -19
- package/dist/destinations/facebook-conversions-api/utils.js.map +0 -1
- package/dist/destinations/facebook-custom-audiences/fbca-operations.d.ts +0 -42
- package/dist/destinations/facebook-custom-audiences/fbca-operations.js +0 -144
- package/dist/destinations/facebook-custom-audiences/fbca-operations.js.map +0 -1
- package/dist/destinations/facebook-custom-audiences/fbca-properties.d.ts +0 -8
- package/dist/destinations/facebook-custom-audiences/fbca-properties.js +0 -148
- package/dist/destinations/facebook-custom-audiences/fbca-properties.js.map +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SEGMENT_SCHEMA_PROPERTIES = exports.SCHEMA_PROPERTIES = exports.US_STATE_CODES = void 0;
|
|
4
|
+
exports.US_STATE_CODES = new Map([
|
|
5
|
+
['arizona', 'az'],
|
|
6
|
+
['alabama', 'al'],
|
|
7
|
+
['alaska', 'ak'],
|
|
8
|
+
['arkansas', 'ar'],
|
|
9
|
+
['california', 'ca'],
|
|
10
|
+
['colorado', 'co'],
|
|
11
|
+
['connecticut', 'ct'],
|
|
12
|
+
['delaware', 'de'],
|
|
13
|
+
['florida', 'fl'],
|
|
14
|
+
['georgia', 'ga'],
|
|
15
|
+
['hawaii', 'hi'],
|
|
16
|
+
['idaho', 'id'],
|
|
17
|
+
['illinois', 'il'],
|
|
18
|
+
['indiana', 'in'],
|
|
19
|
+
['iowa', 'ia'],
|
|
20
|
+
['kansas', 'ks'],
|
|
21
|
+
['kentucky', 'ky'],
|
|
22
|
+
['louisiana', 'la'],
|
|
23
|
+
['maine', 'me'],
|
|
24
|
+
['maryland', 'md'],
|
|
25
|
+
['massachusetts', 'ma'],
|
|
26
|
+
['michigan', 'mi'],
|
|
27
|
+
['minnesota', 'mn'],
|
|
28
|
+
['mississippi', 'ms'],
|
|
29
|
+
['missouri', 'mo'],
|
|
30
|
+
['montana', 'mt'],
|
|
31
|
+
['nebraska', 'ne'],
|
|
32
|
+
['nevada', 'nv'],
|
|
33
|
+
['newhampshire', 'nh'],
|
|
34
|
+
['newjersey', 'nj'],
|
|
35
|
+
['newmexico', 'nm'],
|
|
36
|
+
['newyork', 'ny'],
|
|
37
|
+
['northcarolina', 'nc'],
|
|
38
|
+
['northdakota', 'nd'],
|
|
39
|
+
['ohio', 'oh'],
|
|
40
|
+
['oklahoma', 'ok'],
|
|
41
|
+
['oregon', 'or'],
|
|
42
|
+
['pennsylvania', 'pa'],
|
|
43
|
+
['rhodeisland', 'ri'],
|
|
44
|
+
['southcarolina', 'sc'],
|
|
45
|
+
['southdakota', 'sd'],
|
|
46
|
+
['tennessee', 'tn'],
|
|
47
|
+
['texas', 'tx'],
|
|
48
|
+
['utah', 'ut'],
|
|
49
|
+
['vermont', 'vt'],
|
|
50
|
+
['virginia', 'va'],
|
|
51
|
+
['washington', 'wa'],
|
|
52
|
+
['westvirginia', 'wv'],
|
|
53
|
+
['wisconsin', 'wi'],
|
|
54
|
+
['wyoming', 'wy']
|
|
55
|
+
]);
|
|
56
|
+
exports.SCHEMA_PROPERTIES = [
|
|
57
|
+
'EXTERN_ID',
|
|
58
|
+
'EMAIL',
|
|
59
|
+
'PHONE',
|
|
60
|
+
'DOBY',
|
|
61
|
+
'DOBM',
|
|
62
|
+
'DOBD',
|
|
63
|
+
'LN',
|
|
64
|
+
'FN',
|
|
65
|
+
'FI',
|
|
66
|
+
'GEN',
|
|
67
|
+
'CT',
|
|
68
|
+
'ST',
|
|
69
|
+
'ZIP',
|
|
70
|
+
'COUNTRY',
|
|
71
|
+
'MADID'
|
|
72
|
+
];
|
|
73
|
+
exports.SEGMENT_SCHEMA_PROPERTIES = [
|
|
74
|
+
'externalId',
|
|
75
|
+
'email',
|
|
76
|
+
'phone',
|
|
77
|
+
'year',
|
|
78
|
+
'month',
|
|
79
|
+
'day',
|
|
80
|
+
'last',
|
|
81
|
+
'first',
|
|
82
|
+
'firstInitial',
|
|
83
|
+
'gender',
|
|
84
|
+
'city',
|
|
85
|
+
'state',
|
|
86
|
+
'zip',
|
|
87
|
+
'country',
|
|
88
|
+
'mobileAdId'
|
|
89
|
+
];
|
|
90
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/destinations/facebook-custom-audiences/sync/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,IAAI,GAAG,CAAiB;IACpD,CAAC,SAAS,EAAE,IAAI,CAAC;IACjB,CAAC,SAAS,EAAE,IAAI,CAAC;IACjB,CAAC,QAAQ,EAAE,IAAI,CAAC;IAChB,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,YAAY,EAAE,IAAI,CAAC;IACpB,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,SAAS,EAAE,IAAI,CAAC;IACjB,CAAC,SAAS,EAAE,IAAI,CAAC;IACjB,CAAC,QAAQ,EAAE,IAAI,CAAC;IAChB,CAAC,OAAO,EAAE,IAAI,CAAC;IACf,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,SAAS,EAAE,IAAI,CAAC;IACjB,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,QAAQ,EAAE,IAAI,CAAC;IAChB,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,WAAW,EAAE,IAAI,CAAC;IACnB,CAAC,OAAO,EAAE,IAAI,CAAC;IACf,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,eAAe,EAAE,IAAI,CAAC;IACvB,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,WAAW,EAAE,IAAI,CAAC;IACnB,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,SAAS,EAAE,IAAI,CAAC;IACjB,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,QAAQ,EAAE,IAAI,CAAC;IAChB,CAAC,cAAc,EAAE,IAAI,CAAC;IACtB,CAAC,WAAW,EAAE,IAAI,CAAC;IACnB,CAAC,WAAW,EAAE,IAAI,CAAC;IACnB,CAAC,SAAS,EAAE,IAAI,CAAC;IACjB,CAAC,eAAe,EAAE,IAAI,CAAC;IACvB,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,QAAQ,EAAE,IAAI,CAAC;IAChB,CAAC,cAAc,EAAE,IAAI,CAAC;IACtB,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,eAAe,EAAE,IAAI,CAAC;IACvB,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,WAAW,EAAE,IAAI,CAAC;IACnB,CAAC,OAAO,EAAE,IAAI,CAAC;IACf,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,SAAS,EAAE,IAAI,CAAC;IACjB,CAAC,UAAU,EAAE,IAAI,CAAC;IAClB,CAAC,YAAY,EAAE,IAAI,CAAC;IACpB,CAAC,cAAc,EAAE,IAAI,CAAC;IACtB,CAAC,WAAW,EAAE,IAAI,CAAC;IACnB,CAAC,SAAS,EAAE,IAAI,CAAC;CAClB,CAAC,CAAA;AAIW,QAAA,iBAAiB,GAAG;IAC/B,WAAW;IACX,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,SAAS;IACT,OAAO;CACC,CAAA;AAIG,QAAA,yBAAyB,GAAG;IACvC,YAAY;IACZ,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,cAAc;IACd,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;IACL,SAAS;IACT,YAAY;CACb,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InputField } from '@segment/actions-core';
|
|
2
|
+
import { ActionHookDefinition } from '@segment/actions-core/destination-kit';
|
|
3
|
+
import type { Settings, AudienceSettings } from '../generated-types';
|
|
4
|
+
import type { Payload, RetlOnMappingSaveOutputs, RetlOnMappingSaveInputs } from './generated-types';
|
|
5
|
+
export declare const fields: Record<string, InputField>;
|
|
6
|
+
export declare const retlHookInputFields: ActionHookDefinition<Settings, Payload, AudienceSettings, RetlOnMappingSaveInputs, RetlOnMappingSaveOutputs>['inputFields'];
|
|
7
|
+
export declare const retlHookOutputTypes: ActionHookDefinition<Settings, Payload, AudienceSettings, RetlOnMappingSaveInputs, RetlOnMappingSaveOutputs>['outputTypes'];
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retlHookOutputTypes = exports.retlHookInputFields = exports.fields = void 0;
|
|
4
|
+
const hook_functions_1 = require("./hook-functions");
|
|
5
|
+
exports.fields = {
|
|
6
|
+
externalId: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
required: true,
|
|
9
|
+
label: 'External ID',
|
|
10
|
+
category: 'hashedPII',
|
|
11
|
+
description: 'Your company’s custom identifier for this user. This can be any unique ID, such as loyalty membership IDs, user IDs, and external cookie IDs.',
|
|
12
|
+
default: { '@path': '$.userId' }
|
|
13
|
+
},
|
|
14
|
+
email: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
label: 'Email',
|
|
17
|
+
description: 'User’s email (ex: foo@bar.com)',
|
|
18
|
+
category: 'hashedPII',
|
|
19
|
+
default: {
|
|
20
|
+
'@if': {
|
|
21
|
+
exists: { '@path': '$.traits.email' },
|
|
22
|
+
then: { '@path': '$.traits.email' },
|
|
23
|
+
else: { '@path': '$.properties.email' }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
phone: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
label: 'Phone',
|
|
30
|
+
description: 'User’s phone number, including country code. Punctuation and spaces are ok (ex: 1-234-567-8910 or +44 844 412 4653)',
|
|
31
|
+
category: 'hashedPII',
|
|
32
|
+
default: {
|
|
33
|
+
'@if': {
|
|
34
|
+
exists: { '@path': '$.traits.phone' },
|
|
35
|
+
then: { '@path': '$.traits.phone' },
|
|
36
|
+
else: { '@path': '$.properties.phone' }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
birth: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
label: 'Date of Birth',
|
|
43
|
+
description: 'User’s date of birth. Include as many fields as possible for better match rates (ex: year = YYYY, month = MM, day = DD)',
|
|
44
|
+
defaultObjectUI: 'keyvalue',
|
|
45
|
+
properties: {
|
|
46
|
+
year: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
label: 'Year'
|
|
49
|
+
},
|
|
50
|
+
month: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
label: 'Month'
|
|
53
|
+
},
|
|
54
|
+
day: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
label: 'Day'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
category: 'hashedPII'
|
|
60
|
+
},
|
|
61
|
+
name: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
label: 'Name',
|
|
64
|
+
description: 'User’s name. Include as many fields as possible for better match rates. Use a-z only. No punctuation. Special characters in UTF-8 format',
|
|
65
|
+
category: 'hashedPII',
|
|
66
|
+
defaultObjectUI: 'keyvalue',
|
|
67
|
+
properties: {
|
|
68
|
+
first: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
label: 'First Name',
|
|
71
|
+
category: 'hashedPII'
|
|
72
|
+
},
|
|
73
|
+
last: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
label: 'Last Name',
|
|
76
|
+
category: 'hashedPII'
|
|
77
|
+
},
|
|
78
|
+
firstInitial: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
label: 'First Initial'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
default: {
|
|
84
|
+
first: {
|
|
85
|
+
'@if': {
|
|
86
|
+
exists: { '@path': '$.traits.first_name' },
|
|
87
|
+
then: { '@path': '$.traits.first_name' },
|
|
88
|
+
else: { '@path': '$.properties.first_name' }
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
last: {
|
|
92
|
+
'@if': {
|
|
93
|
+
exists: { '@path': '$.traits.last_name' },
|
|
94
|
+
then: { '@path': '$.traits.last_name' },
|
|
95
|
+
else: { '@path': '$.properties.last_name' }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
gender: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
label: 'Gender',
|
|
103
|
+
description: 'User’s gender (m for male, f for female)',
|
|
104
|
+
category: 'hashedPII',
|
|
105
|
+
default: {
|
|
106
|
+
'@if': {
|
|
107
|
+
exists: { '@path': '$.traits.gender' },
|
|
108
|
+
then: { '@path': '$.traits.gender' },
|
|
109
|
+
else: { '@path': '$.properties.gender' }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
city: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
label: 'City',
|
|
116
|
+
description: 'User’s city. Use a-z only. No punctuation. No special characters.',
|
|
117
|
+
category: 'hashedPII',
|
|
118
|
+
default: {
|
|
119
|
+
'@if': {
|
|
120
|
+
exists: { '@path': '$.traits.city' },
|
|
121
|
+
then: { '@path': '$.traits.city' },
|
|
122
|
+
else: { '@path': '$.properties.city' }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
state: {
|
|
127
|
+
type: 'string',
|
|
128
|
+
label: 'State',
|
|
129
|
+
description: 'User’s state. Use the 2-character ANSI abbreviation code, Normalize states outside the US with no punctuation and no special characters.',
|
|
130
|
+
category: 'hashedPII',
|
|
131
|
+
default: {
|
|
132
|
+
'@if': {
|
|
133
|
+
exists: { '@path': '$.traits.state' },
|
|
134
|
+
then: { '@path': '$.traits.state' },
|
|
135
|
+
else: { '@path': '$.properties.state' }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
zip: {
|
|
140
|
+
type: 'string',
|
|
141
|
+
label: 'Postal Code',
|
|
142
|
+
description: 'User’s postal code. For the US, use only the first 5 digits. For the UK, use the Area/District/Sector format.',
|
|
143
|
+
category: 'hashedPII',
|
|
144
|
+
default: {
|
|
145
|
+
'@if': {
|
|
146
|
+
exists: { '@path': '$.traits.postal_code' },
|
|
147
|
+
then: { '@path': '$.traits.postal_code' },
|
|
148
|
+
else: { '@path': '$.properties.postal_code' }
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
country: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
label: 'Country',
|
|
155
|
+
description: 'User’s country. Use 2-letter country codes in ISO 3166-1 alpha-2 format.',
|
|
156
|
+
category: 'hashedPII',
|
|
157
|
+
default: {
|
|
158
|
+
'@if': {
|
|
159
|
+
exists: { '@path': '$.traits.country' },
|
|
160
|
+
then: { '@path': '$.traits.country' },
|
|
161
|
+
else: { '@path': '$.properties.country' }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
mobileAdId: {
|
|
166
|
+
type: 'string',
|
|
167
|
+
label: 'Mobile Advertising ID',
|
|
168
|
+
description: 'User’s Apple IDFA, Android Ad ID, or Facebook app scoped ID. Keep hyphens (ex: AB1234CD-E123-12FG-J123)',
|
|
169
|
+
category: 'hashedPII'
|
|
170
|
+
},
|
|
171
|
+
appId: {
|
|
172
|
+
type: 'string',
|
|
173
|
+
label: 'App ID',
|
|
174
|
+
description: 'The app ID of the user.',
|
|
175
|
+
category: 'hashedPII'
|
|
176
|
+
},
|
|
177
|
+
pageId: {
|
|
178
|
+
type: 'string',
|
|
179
|
+
label: 'Page ID',
|
|
180
|
+
description: 'The page ID of the user.',
|
|
181
|
+
category: 'hashedPII'
|
|
182
|
+
},
|
|
183
|
+
igAccountIds: {
|
|
184
|
+
type: 'string',
|
|
185
|
+
label: 'Instagram Account IDs',
|
|
186
|
+
description: 'The Instagram account ID of the user.'
|
|
187
|
+
},
|
|
188
|
+
external_audience_id: {
|
|
189
|
+
label: 'Facebook List ID',
|
|
190
|
+
description: `The ID representing the Facebook identifier. This is the identifier that is returned during audience creation.'`,
|
|
191
|
+
type: 'string',
|
|
192
|
+
default: {
|
|
193
|
+
'@path': '$.context.personas.external_audience_id'
|
|
194
|
+
},
|
|
195
|
+
unsafe_hidden: true
|
|
196
|
+
},
|
|
197
|
+
enable_batching: {
|
|
198
|
+
label: 'Enable Batching',
|
|
199
|
+
description: 'Enable batching of requests.',
|
|
200
|
+
type: 'boolean',
|
|
201
|
+
default: true,
|
|
202
|
+
unsafe_hidden: true,
|
|
203
|
+
required: true
|
|
204
|
+
},
|
|
205
|
+
batch_size: {
|
|
206
|
+
label: 'Batch Size',
|
|
207
|
+
description: 'Maximum number of events to include in each batch. Actual batch sizes may be lower.',
|
|
208
|
+
type: 'number',
|
|
209
|
+
default: 10000,
|
|
210
|
+
unsafe_hidden: true,
|
|
211
|
+
required: true
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
exports.retlHookInputFields = {
|
|
215
|
+
operation: {
|
|
216
|
+
type: 'string',
|
|
217
|
+
label: 'Create a new custom audience or connect to an existing one?',
|
|
218
|
+
description: 'Choose to either create a new custom audience or use an existing one. If you opt to create a new audience, we will display the required fields for audience creation. If you opt to use an existing audience, a drop-down menu will appear, allowing you to select from all the custom audiences in your ad account.',
|
|
219
|
+
choices: [
|
|
220
|
+
{ label: 'Create New Audience', value: 'create' },
|
|
221
|
+
{ label: 'Connect to Existing Audience', value: 'existing' }
|
|
222
|
+
],
|
|
223
|
+
default: 'create'
|
|
224
|
+
},
|
|
225
|
+
audienceName: {
|
|
226
|
+
type: 'string',
|
|
227
|
+
label: 'Audience Creation Name',
|
|
228
|
+
description: 'The name of the audience in Facebook.',
|
|
229
|
+
depends_on: {
|
|
230
|
+
conditions: [
|
|
231
|
+
{
|
|
232
|
+
fieldKey: 'operation',
|
|
233
|
+
operator: 'is',
|
|
234
|
+
value: 'create'
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
existingAudienceId: {
|
|
240
|
+
type: 'string',
|
|
241
|
+
label: 'Existing Audience ID',
|
|
242
|
+
description: 'The ID of the audience in Facebook.',
|
|
243
|
+
depends_on: {
|
|
244
|
+
conditions: [
|
|
245
|
+
{
|
|
246
|
+
fieldKey: 'operation',
|
|
247
|
+
operator: 'is',
|
|
248
|
+
value: 'existing'
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
dynamic: hook_functions_1.getExistingAudienceIdChoices
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
exports.retlHookOutputTypes = {
|
|
256
|
+
audienceName: {
|
|
257
|
+
type: 'string',
|
|
258
|
+
label: 'Audience Name',
|
|
259
|
+
description: 'The name of the audience in Facebook this mapping is connected to.',
|
|
260
|
+
required: true
|
|
261
|
+
},
|
|
262
|
+
audienceId: {
|
|
263
|
+
type: 'string',
|
|
264
|
+
label: 'Audience ID',
|
|
265
|
+
description: 'The ID of the audience in Facebook.',
|
|
266
|
+
required: true
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../src/destinations/facebook-custom-audiences/sync/fields.ts"],"names":[],"mappings":";;;AAIA,qDAA+D;AAElD,QAAA,MAAM,GAA+B;IAChD,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,WAAW;QACrB,WAAW,EAAE,+IAA+I;QAC5J,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;KACjC;IACD,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,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QAAQ;iBAChB;aACF;SACF;KACF;IACD,kBAAkB,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,qCAAqC;QAClD,UAAU,EAAE;YACV,UAAU,EAAE;gBACV;oBACE,QAAQ,EAAE,WAAW;oBACrB,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,UAAU;iBAClB;aACF;SACF;QACD,OAAO,EAAE,6CAA4B;KACtC;CACF,CAAA;AAEY,QAAA,mBAAmB,GAAgI;IAC9J,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,oEAAoE;QACjF,QAAQ,EAAE,IAAI;KACf;IACD,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,qCAAqC;QAClD,QAAQ,EAAE,IAAI;KACf;CACF,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Payload } from './generated-types';
|
|
2
|
+
import { RequestClient, MultiStatusResponse, ErrorCodes, Features } from '@segment/actions-core';
|
|
3
|
+
import type { JSONLikeObject, AudienceMembership } from '@segment/actions-core';
|
|
4
|
+
import { StatsContext } from '@segment/actions-core/destination-kit';
|
|
5
|
+
import { PayloadMap, AudienceJSON, FacebookDataRow } from './types';
|
|
6
|
+
export declare function send(request: RequestClient, payloads: Payload[], isBatch: boolean, audienceMemberships?: AudienceMembership[], hookOutputs?: {
|
|
7
|
+
retlOnMappingSave?: {
|
|
8
|
+
outputs?: {
|
|
9
|
+
audienceId?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}, features?: Features, statsContext?: StatsContext): Promise<MultiStatusResponse | void>;
|
|
13
|
+
export declare function sendRequest(request: RequestClient, audienceId: string, map: PayloadMap, msResponse: MultiStatusResponse, method: 'POST' | 'DELETE', isBatch: boolean, features?: Features, statsContext?: StatsContext): Promise<void>;
|
|
14
|
+
export declare function setErrorResponse(msResponse: MultiStatusResponse, payload: Payload, status: number, index: number, isBatch: boolean, errormessage: string, errortype: keyof typeof ErrorCodes | string, sent?: JSONLikeObject): void;
|
|
15
|
+
export declare function returnErrorResponse(msResponse: MultiStatusResponse, payloads: Payload[], isBatch: boolean, errormessage: string, errortype: keyof typeof ErrorCodes): MultiStatusResponse;
|
|
16
|
+
export declare function getAudienceId(payload: Payload, hookOutputs?: {
|
|
17
|
+
retlOnMappingSave?: {
|
|
18
|
+
outputs?: {
|
|
19
|
+
audienceId?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}): string;
|
|
23
|
+
export declare function getJSON(payloads: Payload[]): AudienceJSON;
|
|
24
|
+
export declare function validate(payloads: Payload[], audienceId: unknown, audienceMemberships?: AudienceMembership[]): string | undefined;
|
|
25
|
+
export declare function getData(payloads: Payload[]): FacebookDataRow[];
|
|
26
|
+
export declare function normalizePhone(value: string): string;
|
|
27
|
+
export declare function normalizeGender(value: string): string;
|
|
28
|
+
export declare function normalizeMonth(value: string): string;
|
|
29
|
+
export declare function normalizeName(value: string): string;
|
|
30
|
+
export declare function normalizeCity(value: string): string;
|
|
31
|
+
export declare function normalizeState(value: string): string;
|
|
32
|
+
export declare function normalizeZip(value: string): string;
|
|
33
|
+
export declare function normalizeCountry(value: string): string;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.send = send;
|
|
4
|
+
exports.sendRequest = sendRequest;
|
|
5
|
+
exports.setErrorResponse = setErrorResponse;
|
|
6
|
+
exports.returnErrorResponse = returnErrorResponse;
|
|
7
|
+
exports.getAudienceId = getAudienceId;
|
|
8
|
+
exports.getJSON = getJSON;
|
|
9
|
+
exports.validate = validate;
|
|
10
|
+
exports.getData = getData;
|
|
11
|
+
exports.normalizePhone = normalizePhone;
|
|
12
|
+
exports.normalizeGender = normalizeGender;
|
|
13
|
+
exports.normalizeMonth = normalizeMonth;
|
|
14
|
+
exports.normalizeName = normalizeName;
|
|
15
|
+
exports.normalizeCity = normalizeCity;
|
|
16
|
+
exports.normalizeState = normalizeState;
|
|
17
|
+
exports.normalizeZip = normalizeZip;
|
|
18
|
+
exports.normalizeCountry = normalizeCountry;
|
|
19
|
+
const constants_1 = require("./constants");
|
|
20
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
21
|
+
const hashing_utils_1 = require("../../../lib/hashing-utils");
|
|
22
|
+
const constants_2 = require("../constants");
|
|
23
|
+
const functions_1 = require("../functions");
|
|
24
|
+
async function send(request, payloads, isBatch, audienceMemberships, hookOutputs, features, statsContext) {
|
|
25
|
+
const msResponse = new actions_core_1.MultiStatusResponse();
|
|
26
|
+
const audienceId = getAudienceId(payloads[0], hookOutputs);
|
|
27
|
+
const errorMessage = validate(payloads, audienceId, audienceMemberships);
|
|
28
|
+
if (errorMessage) {
|
|
29
|
+
return returnErrorResponse(msResponse, payloads, isBatch, errorMessage, actions_core_1.ErrorCodes.PAYLOAD_VALIDATION_FAILED);
|
|
30
|
+
}
|
|
31
|
+
const addMap = new Map();
|
|
32
|
+
const deleteMap = new Map();
|
|
33
|
+
payloads.forEach((payload, index) => {
|
|
34
|
+
const audienceMembership = audienceMemberships?.[index];
|
|
35
|
+
if (audienceMembership === false) {
|
|
36
|
+
deleteMap.set(index, payload);
|
|
37
|
+
}
|
|
38
|
+
else if (audienceMembership === true) {
|
|
39
|
+
addMap.set(index, payload);
|
|
40
|
+
}
|
|
41
|
+
else if (audienceMembership === undefined) {
|
|
42
|
+
setErrorResponse(msResponse, payload, 400, index, isBatch, "Audience membership details missing", actions_core_1.ErrorCodes.PAYLOAD_VALIDATION_FAILED);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const requests = [];
|
|
46
|
+
if (addMap.size > 0) {
|
|
47
|
+
requests.push(sendRequest(request, audienceId, addMap, msResponse, 'POST', isBatch, features, statsContext));
|
|
48
|
+
}
|
|
49
|
+
if (deleteMap.size > 0) {
|
|
50
|
+
requests.push(sendRequest(request, audienceId, deleteMap, msResponse, 'DELETE', isBatch, features, statsContext));
|
|
51
|
+
}
|
|
52
|
+
await Promise.all(requests);
|
|
53
|
+
if (isBatch) {
|
|
54
|
+
return msResponse;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function sendRequest(request, audienceId, map, msResponse, method, isBatch, features, statsContext) {
|
|
58
|
+
const indices = Array.from(map.keys());
|
|
59
|
+
const payloads = Array.from(map.values());
|
|
60
|
+
const json = getJSON(payloads);
|
|
61
|
+
try {
|
|
62
|
+
await request(`${constants_2.BASE_URL}/${(0, functions_1.getApiVersion)(features, statsContext)}/${audienceId}/users`, {
|
|
63
|
+
method,
|
|
64
|
+
json
|
|
65
|
+
});
|
|
66
|
+
for (let i = 0; i < indices.length; i++) {
|
|
67
|
+
const originalIndex = indices[i];
|
|
68
|
+
msResponse.setSuccessResponseAtIndex(originalIndex, {
|
|
69
|
+
status: 200,
|
|
70
|
+
body: payloads[i],
|
|
71
|
+
sent: {
|
|
72
|
+
data: json.payload.data[i],
|
|
73
|
+
method,
|
|
74
|
+
audienceId
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const { message, code, status } = (0, functions_1.parseFacebookError)(error);
|
|
81
|
+
for (let i = 0; i < indices.length; i++) {
|
|
82
|
+
const sent = {
|
|
83
|
+
data: json.payload.data[i],
|
|
84
|
+
method,
|
|
85
|
+
audienceId
|
|
86
|
+
};
|
|
87
|
+
setErrorResponse(msResponse, payloads[i], status, indices[i], isBatch, message, code, sent);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function setErrorResponse(msResponse, payload, status, index, isBatch, errormessage, errortype, sent) {
|
|
92
|
+
if (!isBatch) {
|
|
93
|
+
if (errortype === actions_core_1.ErrorCodes.PAYLOAD_VALIDATION_FAILED) {
|
|
94
|
+
throw new actions_core_1.PayloadValidationError(errormessage);
|
|
95
|
+
}
|
|
96
|
+
throw new actions_core_1.IntegrationError(errormessage, errortype, status);
|
|
97
|
+
}
|
|
98
|
+
msResponse.setErrorResponseAtIndex(index, {
|
|
99
|
+
status,
|
|
100
|
+
errortype: errortype,
|
|
101
|
+
errormessage,
|
|
102
|
+
body: payload,
|
|
103
|
+
...(sent ? { sent } : {})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function returnErrorResponse(msResponse, payloads, isBatch, errormessage, errortype) {
|
|
107
|
+
payloads.forEach((payload, i) => {
|
|
108
|
+
setErrorResponse(msResponse, payload, 400, i, isBatch, errormessage, errortype);
|
|
109
|
+
});
|
|
110
|
+
return msResponse;
|
|
111
|
+
}
|
|
112
|
+
function getAudienceId(payload, hookOutputs) {
|
|
113
|
+
const { retlOnMappingSave: { outputs: { audienceId: hookAudienceId = undefined } = {} } = {} } = hookOutputs ?? {};
|
|
114
|
+
const { external_audience_id: payloadAudienceId } = payload;
|
|
115
|
+
return (hookAudienceId ?? payloadAudienceId);
|
|
116
|
+
}
|
|
117
|
+
function getJSON(payloads) {
|
|
118
|
+
const data = getData(payloads);
|
|
119
|
+
const app_ids = [];
|
|
120
|
+
const page_ids = [];
|
|
121
|
+
const ig_account_ids = [];
|
|
122
|
+
payloads.forEach((payload) => {
|
|
123
|
+
const { appId, pageId, igAccountIds } = payload;
|
|
124
|
+
app_ids.push(typeof appId === 'string' && appId ? appId : '');
|
|
125
|
+
page_ids.push(typeof pageId === 'string' && pageId ? pageId : '');
|
|
126
|
+
ig_account_ids.push(typeof igAccountIds === 'string' && igAccountIds ? igAccountIds : '');
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
payload: {
|
|
130
|
+
schema: constants_1.SCHEMA_PROPERTIES,
|
|
131
|
+
data,
|
|
132
|
+
...(app_ids?.some((id) => id?.trim() !== '') ? { app_ids } : {}),
|
|
133
|
+
...(page_ids?.some((id) => id?.trim() !== '') ? { page_ids } : {}),
|
|
134
|
+
...(ig_account_ids?.some((id) => id?.trim() !== '') ? { ig_account_ids } : {})
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function validate(payloads, audienceId, audienceMemberships) {
|
|
139
|
+
if (!Array.isArray(audienceMemberships)) {
|
|
140
|
+
return 'Audience membership details for batch missing.';
|
|
141
|
+
}
|
|
142
|
+
if (Array.isArray(audienceMemberships) && audienceMemberships.length !== payloads.length) {
|
|
143
|
+
return 'Audience membership details count does not match batch payload count.';
|
|
144
|
+
}
|
|
145
|
+
if (!audienceId || typeof audienceId !== 'string') {
|
|
146
|
+
return 'Missing audience ID.';
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function getData(payloads) {
|
|
150
|
+
const data = new Array(payloads.length);
|
|
151
|
+
payloads.forEach((payload, index) => {
|
|
152
|
+
const { externalId, email, phone, birth: { year, month, day } = {}, name: { last, first, firstInitial } = {}, gender, city, state, zip, country, mobileAdId } = payload;
|
|
153
|
+
const row = [
|
|
154
|
+
externalId ?? '',
|
|
155
|
+
email ? (0, hashing_utils_1.processHashing)(email.trim().toLowerCase(), 'sha256', 'hex') : '',
|
|
156
|
+
phone ? (0, hashing_utils_1.processHashing)(phone, 'sha256', 'hex', normalizePhone) ?? '' : '',
|
|
157
|
+
year ? (0, hashing_utils_1.processHashing)(year.trim(), 'sha256', 'hex') ?? '' : '',
|
|
158
|
+
month ? (0, hashing_utils_1.processHashing)(normalizeMonth(month), 'sha256', 'hex') ?? '' : '',
|
|
159
|
+
day ? (0, hashing_utils_1.processHashing)(day.trim(), 'sha256', 'hex') ?? '' : '',
|
|
160
|
+
last ? (0, hashing_utils_1.processHashing)(normalizeName(last), 'sha256', 'hex') ?? '' : '',
|
|
161
|
+
first ? (0, hashing_utils_1.processHashing)(normalizeName(first), 'sha256', 'hex') ?? '' : '',
|
|
162
|
+
firstInitial ? (0, hashing_utils_1.processHashing)(firstInitial.trim().toLowerCase(), 'sha256', 'hex') ?? '' : '',
|
|
163
|
+
gender ? (0, hashing_utils_1.processHashing)(normalizeGender(gender), 'sha256', 'hex') ?? '' : '',
|
|
164
|
+
city ? (0, hashing_utils_1.processHashing)(normalizeCity(city), 'sha256', 'hex') ?? '' : '',
|
|
165
|
+
state ? (0, hashing_utils_1.processHashing)(normalizeState(state), 'sha256', 'hex') ?? '' : '',
|
|
166
|
+
zip ? (0, hashing_utils_1.processHashing)(normalizeZip(zip), 'sha256', 'hex') ?? '' : '',
|
|
167
|
+
country ? (0, hashing_utils_1.processHashing)(normalizeCountry(country), 'sha256', 'hex') ?? '' : '',
|
|
168
|
+
mobileAdId ?? ''
|
|
169
|
+
];
|
|
170
|
+
data[index] = row;
|
|
171
|
+
});
|
|
172
|
+
return data;
|
|
173
|
+
}
|
|
174
|
+
function normalizePhone(value) {
|
|
175
|
+
const removedNonNumveric = value.replace(/\D/g, '');
|
|
176
|
+
return removedNonNumveric.replace(/^0+/, '');
|
|
177
|
+
}
|
|
178
|
+
function normalizeGender(value) {
|
|
179
|
+
const lowerCaseValue = value.toLowerCase().trim();
|
|
180
|
+
if (['male', 'boy', 'm'].includes(lowerCaseValue))
|
|
181
|
+
return 'm';
|
|
182
|
+
if (['female', 'woman', 'girl', 'f'].includes(lowerCaseValue))
|
|
183
|
+
return 'f';
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
function normalizeMonth(value) {
|
|
187
|
+
const normalizedValue = value.replace(/\s/g, '').trim();
|
|
188
|
+
if (normalizedValue.length === 2 && typeof Number(normalizedValue) === 'number') {
|
|
189
|
+
return normalizedValue;
|
|
190
|
+
}
|
|
191
|
+
const lowerCaseValue = value.trim().toLowerCase();
|
|
192
|
+
const months = [
|
|
193
|
+
'january',
|
|
194
|
+
'february',
|
|
195
|
+
'march',
|
|
196
|
+
'april',
|
|
197
|
+
'may',
|
|
198
|
+
'june',
|
|
199
|
+
'july',
|
|
200
|
+
'august',
|
|
201
|
+
'september',
|
|
202
|
+
'october',
|
|
203
|
+
'november',
|
|
204
|
+
'december'
|
|
205
|
+
];
|
|
206
|
+
const monthIndex = months.indexOf(lowerCaseValue);
|
|
207
|
+
if (monthIndex === -1) {
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
210
|
+
if (monthIndex < 9) {
|
|
211
|
+
return `0${monthIndex + 1}`;
|
|
212
|
+
}
|
|
213
|
+
return `${monthIndex + 1}`;
|
|
214
|
+
}
|
|
215
|
+
function normalizeName(value) {
|
|
216
|
+
return value.trim().toLowerCase().replace(/\p{P}/gu, '');
|
|
217
|
+
}
|
|
218
|
+
function normalizeCity(value) {
|
|
219
|
+
return value
|
|
220
|
+
.trim()
|
|
221
|
+
.replace(/[\s\W_]/g, '')
|
|
222
|
+
.toLowerCase();
|
|
223
|
+
}
|
|
224
|
+
function normalizeState(value) {
|
|
225
|
+
if (constants_1.US_STATE_CODES.has(value.toLowerCase().trim())) {
|
|
226
|
+
return constants_1.US_STATE_CODES.get(value.toLowerCase().trim());
|
|
227
|
+
}
|
|
228
|
+
return value
|
|
229
|
+
.trim()
|
|
230
|
+
.replace(/[\s\W_]/g, '')
|
|
231
|
+
.toLowerCase();
|
|
232
|
+
}
|
|
233
|
+
function normalizeZip(value) {
|
|
234
|
+
if (value.includes('-')) {
|
|
235
|
+
return value.split('-')[0];
|
|
236
|
+
}
|
|
237
|
+
return value.trim().replace(/\s/g, '').toLowerCase();
|
|
238
|
+
}
|
|
239
|
+
function normalizeCountry(value) {
|
|
240
|
+
return value
|
|
241
|
+
.trim()
|
|
242
|
+
.replace(/[\s\W_]/g, '')
|
|
243
|
+
.toLowerCase();
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=functions.js.map
|