@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
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const fields_1 = require("../fields");
|
|
5
|
+
const functions_1 = require("../functions");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
|
-
const utils_1 = require("../utils");
|
|
8
|
-
const fb_capi_app_data_1 = require("../fb-capi-app-data");
|
|
9
7
|
const action = {
|
|
10
8
|
title: 'View Content V2',
|
|
11
9
|
description: 'Send event when a user views content or a product',
|
|
@@ -16,92 +14,10 @@ const action = {
|
|
|
16
14
|
default: 'add',
|
|
17
15
|
choices: [{ label: 'Insert Records', value: 'add' }]
|
|
18
16
|
},
|
|
19
|
-
fields:
|
|
20
|
-
action_source: { ...fb_capi_properties_1.action_source, required: true },
|
|
21
|
-
event_time: { ...fb_capi_properties_1.event_time, required: true },
|
|
22
|
-
user_data: fb_capi_user_data_1.user_data_field,
|
|
23
|
-
app_data_field: fb_capi_app_data_1.app_data_field,
|
|
24
|
-
content_category: fb_capi_properties_1.content_category,
|
|
25
|
-
content_ids: { ...fb_capi_properties_1.content_ids, default: { '@path': '$.properties.product_id' } },
|
|
26
|
-
content_name: fb_capi_properties_1.content_name,
|
|
27
|
-
content_type: fb_capi_properties_1.content_type,
|
|
28
|
-
contents: {
|
|
29
|
-
...fb_capi_properties_1.contents,
|
|
30
|
-
default: {
|
|
31
|
-
'@arrayPath': [
|
|
32
|
-
'$.properties',
|
|
33
|
-
{
|
|
34
|
-
id: {
|
|
35
|
-
'@path': '$.product_id'
|
|
36
|
-
},
|
|
37
|
-
quantity: {
|
|
38
|
-
'@path': '$.quantity'
|
|
39
|
-
},
|
|
40
|
-
item_price: {
|
|
41
|
-
'@path': '$.price'
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
currency: fb_capi_properties_1.currency,
|
|
48
|
-
event_id: fb_capi_properties_1.event_id,
|
|
49
|
-
event_source_url: fb_capi_properties_1.event_source_url,
|
|
50
|
-
value: { ...fb_capi_properties_1.value, default: { '@path': '$.properties.price' } },
|
|
51
|
-
custom_data: fb_capi_properties_1.custom_data,
|
|
52
|
-
data_processing_options: fb_capi_properties_1.data_processing_options,
|
|
53
|
-
data_processing_options_country: fb_capi_properties_1.data_processing_options_country,
|
|
54
|
-
data_processing_options_state: fb_capi_properties_1.data_processing_options_state,
|
|
55
|
-
test_event_code: fb_capi_properties_1.test_event_code
|
|
56
|
-
},
|
|
17
|
+
fields: fields_1.viewContentFields,
|
|
57
18
|
perform: (request, { payload, settings, features, statsContext, syncMode }) => {
|
|
58
19
|
if (syncMode === 'add') {
|
|
59
|
-
|
|
60
|
-
throw new actions_core_1.IntegrationError(`${payload.currency} is not a valid currency code.`, 'Misconfigured required field', 400);
|
|
61
|
-
}
|
|
62
|
-
if (!payload.user_data) {
|
|
63
|
-
throw new actions_core_1.IntegrationError('Must include at least one user data property', 'Misconfigured required field', 400);
|
|
64
|
-
}
|
|
65
|
-
if (payload.action_source === 'website' && payload.user_data.client_user_agent === undefined) {
|
|
66
|
-
throw new actions_core_1.IntegrationError('If action source is "Website" then client_user_agent must be defined', 'Misconfigured required field', 400);
|
|
67
|
-
}
|
|
68
|
-
if (payload.contents) {
|
|
69
|
-
const err = (0, fb_capi_properties_1.validateContents)(payload.contents);
|
|
70
|
-
if (err)
|
|
71
|
-
throw err;
|
|
72
|
-
}
|
|
73
|
-
const [data_options, country_code, state_code] = (0, fb_capi_properties_1.dataProcessingOptions)(payload.data_processing_options, payload.data_processing_options_country, payload.data_processing_options_state);
|
|
74
|
-
const testEventCode = payload.test_event_code || settings.testEventCode;
|
|
75
|
-
return request(`https://graph.facebook.com/v${(0, utils_1.get_api_version)(features, statsContext)}/${settings.pixelId}/events`, {
|
|
76
|
-
method: 'POST',
|
|
77
|
-
json: {
|
|
78
|
-
data: [
|
|
79
|
-
{
|
|
80
|
-
event_name: 'ViewContent',
|
|
81
|
-
event_time: payload.event_time,
|
|
82
|
-
action_source: payload.action_source,
|
|
83
|
-
event_id: payload.event_id,
|
|
84
|
-
event_source_url: payload.event_source_url,
|
|
85
|
-
user_data: (0, fb_capi_user_data_1.hash_user_data)({ user_data: payload.user_data }),
|
|
86
|
-
custom_data: {
|
|
87
|
-
...payload.custom_data,
|
|
88
|
-
currency: payload.currency,
|
|
89
|
-
value: payload.value,
|
|
90
|
-
content_ids: payload.content_ids,
|
|
91
|
-
content_name: payload.content_name,
|
|
92
|
-
content_type: payload.content_type,
|
|
93
|
-
contents: payload.contents,
|
|
94
|
-
content_category: payload.content_category
|
|
95
|
-
},
|
|
96
|
-
app_data: (0, fb_capi_app_data_1.generate_app_data)(payload.app_data_field),
|
|
97
|
-
data_processing_options: data_options,
|
|
98
|
-
data_processing_options_country: country_code,
|
|
99
|
-
data_processing_options_state: state_code
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
...(testEventCode && { test_event_code: testEventCode })
|
|
103
|
-
}
|
|
104
|
-
});
|
|
20
|
+
return (0, functions_1.send)(request, payload, settings, constants_1.EventType.ViewContent, features, statsContext);
|
|
105
21
|
}
|
|
106
22
|
else {
|
|
107
23
|
throw new actions_core_1.IntegrationError(`Sync mode ${syncMode} is not supported`, 'Misconfigured sync mode', 400);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/facebook-conversions-api/viewContent2/index.ts"],"names":[],"mappings":";;AAAA,wDAA0E;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/facebook-conversions-api/viewContent2/index.ts"],"names":[],"mappings":";;AAAA,wDAA0E;AAG1E,sCAA6C;AAC7C,4CAAmC;AACnC,4CAAwC;AAExC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,mDAAmD;IAChE,mBAAmB,EAAE,6CAA6C;IAClE,QAAQ,EAAE;QACR,WAAW,EAAE,8DAA8D;QAC3E,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KACrD;IACD,MAAM,EAAE,0BAAiB;IACzB,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC5E,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YACvB,OAAO,IAAA,gBAAI,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,qBAAS,CAAC,WAAW,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;QACxF,CAAC;aACI,CAAC;YACJ,MAAM,IAAI,+BAAgB,CAAC,aAAa,QAAQ,mBAAmB,EAAE,yBAAyB,EAAE,GAAG,CAAC,CAAA;QACtG,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export declare const US_STATE_CODES: Map<string, string>;
|
|
2
1
|
export declare const API_VERSION = "v24.0";
|
|
3
2
|
export declare const CANARY_API_VERSION = "v24.0";
|
|
4
|
-
export declare const BASE_URL = "https://graph.facebook.com";
|
|
5
3
|
export declare const FACEBOOK_CUSTOM_AUDIENCE_FLAGON = "facebook-custom-audience-actions-canary-version";
|
|
4
|
+
export declare const BASE_URL = "https://graph.facebook.com";
|
|
@@ -1,60 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
|
-
]);
|
|
3
|
+
exports.BASE_URL = exports.FACEBOOK_CUSTOM_AUDIENCE_FLAGON = exports.CANARY_API_VERSION = exports.API_VERSION = void 0;
|
|
56
4
|
exports.API_VERSION = 'v24.0';
|
|
57
5
|
exports.CANARY_API_VERSION = 'v24.0';
|
|
58
|
-
exports.BASE_URL = 'https://graph.facebook.com';
|
|
59
6
|
exports.FACEBOOK_CUSTOM_AUDIENCE_FLAGON = 'facebook-custom-audience-actions-canary-version';
|
|
7
|
+
exports.BASE_URL = 'https://graph.facebook.com';
|
|
60
8
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/facebook-custom-audiences/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/facebook-custom-audiences/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,OAAO,CAAA;AAErB,QAAA,kBAAkB,GAAG,OAAO,CAAA;AAE5B,QAAA,+BAA+B,GAAG,iDAAiD,CAAA;AAEnF,QAAA,QAAQ,GAAG,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.audienceDescription = exports.adAccountId = void 0;
|
|
4
|
+
exports.adAccountId = {
|
|
5
|
+
type: 'string',
|
|
6
|
+
label: 'Advertiser Account ID',
|
|
7
|
+
description: 'Your advertiser account id. Read [more](https://www.facebook.com/business/help/1492627900875762).',
|
|
8
|
+
required: true
|
|
9
|
+
};
|
|
10
|
+
exports.audienceDescription = {
|
|
11
|
+
type: 'string',
|
|
12
|
+
label: 'Description',
|
|
13
|
+
description: 'A brief description about your audience.',
|
|
14
|
+
required: true
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../src/destinations/facebook-custom-audiences/fields.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAkB;IACxC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EAAE,mGAAmG;IAChH,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,mBAAmB,GAAkB;IAChD,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,0CAA0C;IACvD,QAAQ,EAAE,IAAI;CACf,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestClient, Features } from '@segment/actions-core';
|
|
2
|
+
import { StatsContext } from '@segment/actions-core/destination-kit';
|
|
3
|
+
import { ParsedFacebookError, NonFacebookError, FacebookResponseError } from './types';
|
|
4
|
+
export declare function parseFacebookError(error: FacebookResponseError): ParsedFacebookError;
|
|
5
|
+
export declare function createAudience(request: RequestClient, name: string, adAccountId: string, description?: string, features?: Features, statsContext?: StatsContext): Promise<{
|
|
6
|
+
data?: {
|
|
7
|
+
externalId: string;
|
|
8
|
+
};
|
|
9
|
+
error?: NonFacebookError;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function getAudience(request: RequestClient, externalId: string, features?: Features, statsContext?: StatsContext): Promise<{
|
|
12
|
+
data?: {
|
|
13
|
+
externalId?: string;
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
error?: NonFacebookError;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function getApiVersion(features?: Features, statsContext?: StatsContext): string;
|
|
19
|
+
export declare function normalizeAccountId(adAccountId: string): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFacebookError = parseFacebookError;
|
|
4
|
+
exports.createAudience = createAudience;
|
|
5
|
+
exports.getAudience = getAudience;
|
|
6
|
+
exports.getApiVersion = getApiVersion;
|
|
7
|
+
exports.normalizeAccountId = normalizeAccountId;
|
|
8
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
function parseFacebookError(error) {
|
|
11
|
+
const { response: { status = undefined, data: { error: { message: fbMessage = undefined, type = undefined, code = undefined, error_user_title = undefined, error_user_msg = undefined } = {} } = {} } = {}, message: outerMessage } = (error ?? {});
|
|
12
|
+
const parts = [
|
|
13
|
+
error_user_title && `error_user_title: "${error_user_title}"`,
|
|
14
|
+
error_user_msg && `error_user_msg: "${error_user_msg}"`,
|
|
15
|
+
fbMessage && `fbmessage: "${fbMessage}"`,
|
|
16
|
+
outerMessage && `message: "${outerMessage}"`,
|
|
17
|
+
code && `code: "${code}"`
|
|
18
|
+
];
|
|
19
|
+
const message = parts.filter(Boolean).join('. ').trim() || 'An unknown error occurred while communicating with Facebook API.';
|
|
20
|
+
return {
|
|
21
|
+
message,
|
|
22
|
+
code: type || actions_core_1.ErrorCodes.UNKNOWN_ERROR,
|
|
23
|
+
status: status ?? 400
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function createAudience(request, name, adAccountId, description, features, statsContext) {
|
|
27
|
+
if (!name) {
|
|
28
|
+
return { error: { message: 'Missing audience name value', code: actions_core_1.ErrorCodes.CREATE_AUDIENCE_FAILED } };
|
|
29
|
+
}
|
|
30
|
+
if (!adAccountId) {
|
|
31
|
+
return { error: { message: 'Missing ad account ID value', code: actions_core_1.ErrorCodes.CREATE_AUDIENCE_FAILED } };
|
|
32
|
+
}
|
|
33
|
+
const url = `${constants_1.BASE_URL}/${getApiVersion(features, statsContext)}/${normalizeAccountId(adAccountId)}/customaudiences`;
|
|
34
|
+
const json = {
|
|
35
|
+
name,
|
|
36
|
+
subtype: 'CUSTOM',
|
|
37
|
+
customer_file_source: 'BOTH_USER_AND_PARTNER_PROVIDED',
|
|
38
|
+
...(description ? { description } : {})
|
|
39
|
+
};
|
|
40
|
+
try {
|
|
41
|
+
const response = await request(url, {
|
|
42
|
+
method: 'post',
|
|
43
|
+
json
|
|
44
|
+
});
|
|
45
|
+
const { id } = response.data;
|
|
46
|
+
if (!id) {
|
|
47
|
+
return {
|
|
48
|
+
error: {
|
|
49
|
+
message: 'Invalid response from create audience request',
|
|
50
|
+
code: actions_core_1.ErrorCodes.CREATE_AUDIENCE_FAILED
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return { data: { externalId: id } };
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const { message } = parseFacebookError(error);
|
|
58
|
+
return { error: { message, code: actions_core_1.ErrorCodes.CREATE_AUDIENCE_FAILED } };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function getAudience(request, externalId, features, statsContext) {
|
|
62
|
+
const url = `${constants_1.BASE_URL}/${getApiVersion(features, statsContext)}/${externalId}?fields=id,name`;
|
|
63
|
+
try {
|
|
64
|
+
const response = await request(url, { method: 'GET' });
|
|
65
|
+
const { id, name } = response.data;
|
|
66
|
+
if (!id) {
|
|
67
|
+
return { error: { message: 'Invalid response from get audience request', code: actions_core_1.ErrorCodes.GET_AUDIENCE_FAILED } };
|
|
68
|
+
}
|
|
69
|
+
if (externalId !== id) {
|
|
70
|
+
return { error: { message: `Audience not found. Audience ID mismatch. Expected: ${externalId}, Received: ${id}`, code: actions_core_1.ErrorCodes.GET_AUDIENCE_FAILED } };
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
data: {
|
|
74
|
+
externalId: id,
|
|
75
|
+
name: name || ''
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const { message } = parseFacebookError(error);
|
|
81
|
+
return { error: { message, code: actions_core_1.ErrorCodes.GET_AUDIENCE_FAILED } };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function getApiVersion(features, statsContext) {
|
|
85
|
+
const { statsClient, tags } = statsContext || {};
|
|
86
|
+
const version = features && features[constants_1.FACEBOOK_CUSTOM_AUDIENCE_FLAGON] ? constants_1.CANARY_API_VERSION : constants_1.API_VERSION;
|
|
87
|
+
tags?.push(`version:${version}`);
|
|
88
|
+
statsClient?.incr(`actions_facebook_custom_audience`, 1, tags);
|
|
89
|
+
return version;
|
|
90
|
+
}
|
|
91
|
+
function normalizeAccountId(adAccountId) {
|
|
92
|
+
return `act_${adAccountId.replace(/^act_/, '')}`;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/facebook-custom-audiences/functions.ts"],"names":[],"mappings":";;AAKA,gDAgCC;AAED,wCAuCC;AAED,kCAuBC;AAED,sCAMC;AAED,gDAEC;AAnHD,wDAA2E;AAG3E,2CAAwG;AAExG,SAAgB,kBAAkB,CAAC,KAA4B;IAC7D,MAAM,EACJ,QAAQ,EAAE,EACR,MAAM,GAAG,SAAS,EAClB,IAAI,EAAE,EACJ,KAAK,EAAE,EACL,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,IAAI,GAAG,SAAS,EAChB,IAAI,GAAG,SAAS,EAChB,gBAAgB,GAAG,SAAS,EAC5B,cAAc,GAAG,SAAS,EAC3B,GAAG,EAAE,EACP,GAAG,EAAE,EACP,GAAG,EAAE,EACN,OAAO,EAAE,YAAY,EACtB,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IAEjB,MAAM,KAAK,GAAG;QACZ,gBAAgB,IAAI,sBAAsB,gBAAgB,GAAG;QAC7D,cAAc,IAAI,oBAAoB,cA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AE,yBAAU,CAAC,mBAAmB,EAAE,EAAE,CAAA;QAC3J,CAAC;QACD,OAAO;YACL,IAAI,EAAE;gBACJ,UAAU,EAAE,EAAE;gBACd,IAAI,EAAE,IAAI,IAAI,EAAE;aACjB;SACF,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC,KAA8B,CAAC,CAAA;QACtE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,yBAAU,CAAC,mBAAmB,EAAE,EAAE,CAAA;IACrE,CAAC;AACH,CAAC;AAED,SAAgB,aAAa,CAAC,QAAmB,EAAE,YAA2B;IAC5E,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,YAAY,IAAI,EAAE,CAAA;IAChD,MAAM,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC,2CAA+B,CAAC,CAAC,CAAC,CAAC,8BAAkB,CAAC,CAAC,CAAC,uBAAW,CAAA;IACxG,IAAI,EAAE,IAAI,CAAC,WAAW,OAAO,EAAE,CAAC,CAAA;IAChC,WAAW,EAAE,IAAI,CAAC,kCAAkC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;IAC9D,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,OAAO,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAA;AAClD,CAAC"}
|
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const actions_core_1 = require("@segment/actions-core");
|
|
7
|
-
const
|
|
7
|
+
const fields_1 = require("./fields");
|
|
8
8
|
const sync_1 = __importDefault(require("./sync"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const functions_1 = require("./functions");
|
|
10
|
+
const presets_1 = require("./presets");
|
|
11
11
|
const destination = {
|
|
12
12
|
name: 'Facebook Custom Audiences (Actions)',
|
|
13
13
|
slug: 'actions-facebook-custom-audiences',
|
|
@@ -16,7 +16,10 @@ const destination = {
|
|
|
16
16
|
authentication: {
|
|
17
17
|
scheme: 'oauth2',
|
|
18
18
|
fields: {
|
|
19
|
-
retlAdAccountId:
|
|
19
|
+
retlAdAccountId: {
|
|
20
|
+
...fields_1.adAccountId,
|
|
21
|
+
description: 'Your advertiser account id. Read [more](https://www.facebook.com/business/help/1492627900875762). This is required to set up the connection, but can be overriden using the Engage Audience setting named "Advertiser Account ID".'
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
},
|
|
22
25
|
extendRequest({ auth }) {
|
|
@@ -27,13 +30,12 @@ const destination = {
|
|
|
27
30
|
};
|
|
28
31
|
},
|
|
29
32
|
audienceFields: {
|
|
30
|
-
engageAdAccountId:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
33
|
+
engageAdAccountId: {
|
|
34
|
+
...fields_1.adAccountId,
|
|
35
|
+
description: 'Your advertiser account id. Read [more](https://www.facebook.com/business/help/1492627900875762). This overrides the main Destination settings named "Advertiser Account ID".',
|
|
36
|
+
required: false
|
|
37
|
+
},
|
|
38
|
+
audienceDescription: fields_1.audienceDescription
|
|
37
39
|
},
|
|
38
40
|
audienceConfig: {
|
|
39
41
|
mode: {
|
|
@@ -41,109 +43,27 @@ const destination = {
|
|
|
41
43
|
full_audience_sync: false
|
|
42
44
|
},
|
|
43
45
|
async createAudience(request, createAudienceInput) {
|
|
44
|
-
const audienceName = createAudienceInput
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
throw new actions_core_1.IntegrationError('Missing audience name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
50
|
-
}
|
|
51
|
-
if (!adAccountId) {
|
|
52
|
-
throw new actions_core_1.IntegrationError('Missing ad account ID value', 'MISSING_REQUIRED_FIELD', 400);
|
|
53
|
-
}
|
|
54
|
-
const createAudienceUrl = `https://graph.facebook.com/${(0, fbca_operations_1.getApiVersion)(features, statsContext)}/act_${adAccountId}/customaudiences`;
|
|
55
|
-
const payload = {
|
|
56
|
-
name: audienceName,
|
|
57
|
-
description: audienceDescription || '',
|
|
58
|
-
subtype: 'CUSTOM',
|
|
59
|
-
customer_file_source: 'BOTH_USER_AND_PARTNER_PROVIDED'
|
|
60
|
-
};
|
|
61
|
-
let response;
|
|
62
|
-
try {
|
|
63
|
-
response = await request(createAudienceUrl, {
|
|
64
|
-
method: 'POST',
|
|
65
|
-
headers: {
|
|
66
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
67
|
-
},
|
|
68
|
-
body: new URLSearchParams(payload)
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
catch (err) {
|
|
72
|
-
let message = err.response?.content || err.message;
|
|
73
|
-
let userTitle, userMsg;
|
|
74
|
-
if (typeof message === 'string') {
|
|
75
|
-
try {
|
|
76
|
-
const parsed = JSON.parse(message);
|
|
77
|
-
if (parsed?.error) {
|
|
78
|
-
userTitle = parsed.error.error_user_title;
|
|
79
|
-
userMsg = parsed.error.error_user_msg || parsed.error.error_user_message;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (userTitle || userMsg) {
|
|
86
|
-
message = `${userTitle ? userTitle + ': ' : ''}${userMsg || ''}`.trim();
|
|
87
|
-
}
|
|
88
|
-
throw new actions_core_1.IntegrationError(String(message), 'CREATE_AUDIENCE_FAILED', 400);
|
|
46
|
+
const { audienceName, audienceSettings: { engageAdAccountId, audienceDescription } = {}, settings: { retlAdAccountId } = {}, features, statsContext } = createAudienceInput;
|
|
47
|
+
const addAccountId = (engageAdAccountId ?? retlAdAccountId);
|
|
48
|
+
const { data: { externalId: id } = {}, error } = await (0, functions_1.createAudience)(request, audienceName, addAccountId, audienceDescription, features, statsContext);
|
|
49
|
+
if (error) {
|
|
50
|
+
throw new actions_core_1.IntegrationError(error.message, actions_core_1.ErrorCodes.CREATE_AUDIENCE_FAILED, 400);
|
|
89
51
|
}
|
|
90
|
-
|
|
91
|
-
if (!r[EXTERNAL_ID_KEY]) {
|
|
92
|
-
throw new actions_core_1.IntegrationError('Invalid response from create audience request', 'INVALID_RESPONSE', 400);
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
externalId: r[EXTERNAL_ID_KEY]
|
|
96
|
-
};
|
|
52
|
+
return { externalId: id };
|
|
97
53
|
},
|
|
98
54
|
async getAudience(request, getAudienceInput) {
|
|
99
|
-
const { features, statsContext } = getAudienceInput;
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (!r[EXTERNAL_ID_KEY]) {
|
|
104
|
-
throw new actions_core_1.IntegrationError('Invalid response from get audience request', 'INVALID_RESPONSE', 400);
|
|
105
|
-
}
|
|
106
|
-
if (getAudienceInput.externalId !== r[EXTERNAL_ID_KEY]) {
|
|
107
|
-
throw new actions_core_1.IntegrationError("Couldn't find audience", 'INVALID_RESPONSE', 400);
|
|
55
|
+
const { externalId, features, statsContext } = getAudienceInput;
|
|
56
|
+
const { data: { externalId: id } = {}, error } = await (0, functions_1.getAudience)(request, externalId, features, statsContext);
|
|
57
|
+
if (error) {
|
|
58
|
+
throw new actions_core_1.IntegrationError(error.message, actions_core_1.ErrorCodes.GET_AUDIENCE_FAILED, 400);
|
|
108
59
|
}
|
|
109
|
-
return {
|
|
110
|
-
externalId: r[EXTERNAL_ID_KEY]
|
|
111
|
-
};
|
|
60
|
+
return { externalId: id };
|
|
112
61
|
}
|
|
113
62
|
},
|
|
114
63
|
actions: {
|
|
115
64
|
sync: sync_1.default
|
|
116
65
|
},
|
|
117
|
-
presets:
|
|
118
|
-
{
|
|
119
|
-
name: 'Entities Audience Membership Changed',
|
|
120
|
-
partnerAction: 'sync',
|
|
121
|
-
mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
|
|
122
|
-
type: 'specificEvent',
|
|
123
|
-
eventSlug: 'warehouse_audience_membership_changed_identify'
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: 'Associated Entity Added',
|
|
127
|
-
partnerAction: 'sync',
|
|
128
|
-
mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
|
|
129
|
-
type: 'specificEvent',
|
|
130
|
-
eventSlug: 'warehouse_entity_added_track'
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: 'Associated Entity Removed',
|
|
134
|
-
partnerAction: 'sync',
|
|
135
|
-
mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
|
|
136
|
-
type: 'specificEvent',
|
|
137
|
-
eventSlug: 'warehouse_entity_removed_track'
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: 'Journeys Step Entered',
|
|
141
|
-
partnerAction: 'sync',
|
|
142
|
-
mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
|
|
143
|
-
type: 'specificEvent',
|
|
144
|
-
eventSlug: 'journeys_step_entered_track'
|
|
145
|
-
}
|
|
146
|
-
]
|
|
66
|
+
presets: presets_1.presets
|
|
147
67
|
};
|
|
148
68
|
exports.default = destination;
|
|
149
69
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/facebook-custom-audiences/index.ts"],"names":[],"mappings":";;;;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/facebook-custom-audiences/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAoE;AAEpE,qCAA2D;AAC3D,kDAAyB;AACzB,2CAAyD;AACzD,uCAAmC;AAEnC,MAAM,WAAW,GAA8D;IAC7E,IAAI,EAAE,qCAAqC;IAC3C,IAAI,EAAE,mCAAmC;IACzC,IAAI,EAAE,OAAO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AE,CAAA;QACrC,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,gBAAgB;YACzC,MAAM,EACJ,UAAU,EACV,QAAQ,EACR,YAAY,EACb,GAAG,gBAAgB,CAAA;YACpB,MAAM,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,uBAAW,EAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;YAC/G,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,IAAI,+BAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,yBAAU,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAA;YAChF,CAAC;YACD,OAAO,EAAE,UAAU,EAAE,EAAY,EAAE,CAAA;QACrC,CAAC;KACF;IACD,OAAO,EAAE;QACP,IAAI,EAAJ,cAAI;KACL;IACD,OAAO,EAAP,iBAAO;CACR,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.presets = void 0;
|
|
7
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
+
const sync_1 = __importDefault(require("./sync"));
|
|
9
|
+
exports.presets = [
|
|
10
|
+
{
|
|
11
|
+
name: 'Entities Audience Membership Changed',
|
|
12
|
+
partnerAction: 'sync',
|
|
13
|
+
mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
|
|
14
|
+
type: 'specificEvent',
|
|
15
|
+
eventSlug: 'warehouse_audience_membership_changed_identify'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'Associated Entity Added',
|
|
19
|
+
partnerAction: 'sync',
|
|
20
|
+
mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
|
|
21
|
+
type: 'specificEvent',
|
|
22
|
+
eventSlug: 'warehouse_entity_added_track'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Associated Entity Removed',
|
|
26
|
+
partnerAction: 'sync',
|
|
27
|
+
mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
|
|
28
|
+
type: 'specificEvent',
|
|
29
|
+
eventSlug: 'warehouse_entity_removed_track'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Journeys Step Entered',
|
|
33
|
+
partnerAction: 'sync',
|
|
34
|
+
mapping: (0, actions_core_1.defaultValues)(sync_1.default.fields),
|
|
35
|
+
type: 'specificEvent',
|
|
36
|
+
eventSlug: 'journeys_step_entered_track'
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../../src/destinations/facebook-custom-audiences/presets.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAqD;AAErD,kDAAyB;AAEZ,QAAA,OAAO,GAAa;IAC/B;QACE,IAAI,EAAE,sCAAsC;QAC5C,aAAa,EAAE,MAAM;QACrB,OAAO,EAAE,IAAA,4BAAa,EAAC,cAAI,CAAC,MAAM,CAAC;QACnC,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,gDAAgD;KAC5D;IACD;QACE,IAAI,EAAE,yBAAyB;QAC/B,aAAa,EAAE,MAAM;QACrB,OAAO,EAAE,IAAA,4BAAa,EAAC,cAAI,CAAC,MAAM,CAAC;QACnC,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,8BAA8B;KAC1C;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,aAAa,EAAE,MAAM;QACrB,OAAO,EAAE,IAAA,4BAAa,EAAC,cAAI,CAAC,MAAM,CAAC;QACnC,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,gCAAgC;KAC5C;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,aAAa,EAAE,MAAM;QACrB,OAAO,EAAE,IAAA,4BAAa,EAAC,cAAI,CAAC,MAAM,CAAC;QACnC,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,6BAA6B;KACzC;CACF,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const US_STATE_CODES: Map<string, string>;
|
|
2
|
+
export declare const SCHEMA_PROPERTIES: readonly ["EXTERN_ID", "EMAIL", "PHONE", "DOBY", "DOBM", "DOBD", "LN", "FN", "FI", "GEN", "CT", "ST", "ZIP", "COUNTRY", "MADID"];
|
|
3
|
+
export declare const SEGMENT_SCHEMA_PROPERTIES: string[];
|