@segment/action-destinations 3.437.1-staging-ea6c83c19.0 → 3.439.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/criteo-audiences/addUserToAudience/generated-types.d.ts +1 -0
- package/dist/destinations/criteo-audiences/addUserToAudience/index.js +7 -0
- package/dist/destinations/criteo-audiences/addUserToAudience/index.js.map +1 -1
- package/dist/destinations/criteo-audiences/removeUserFromAudience/generated-types.d.ts +1 -0
- package/dist/destinations/criteo-audiences/removeUserFromAudience/index.js +7 -0
- package/dist/destinations/criteo-audiences/removeUserFromAudience/index.js.map +1 -1
- package/dist/destinations/first-party-dv360/_tests_/index.test.js +2 -2
- package/dist/destinations/first-party-dv360/_tests_/index.test.js.map +1 -1
- package/dist/destinations/first-party-dv360/functions.d.ts +1 -1
- package/dist/destinations/first-party-dv360/generated-types.d.ts +1 -1
- package/dist/destinations/first-party-dv360/index.js +2 -4
- package/dist/destinations/first-party-dv360/index.js.map +1 -1
- package/dist/destinations/first-party-dv360/types.d.ts +2 -2
- package/dist/destinations/kafka/generated-types.d.ts +3 -0
- package/dist/destinations/kafka/index.js +21 -0
- package/dist/destinations/kafka/index.js.map +1 -1
- package/dist/destinations/kafka/send/generated-types.d.ts +0 -1
- package/dist/destinations/kafka/send/index.js +0 -7
- package/dist/destinations/kafka/send/index.js.map +1 -1
- package/dist/destinations/kafka/utils.js +13 -0
- package/dist/destinations/kafka/utils.js.map +1 -1
- package/dist/destinations/linkedin-audiences/updateAudience/fields.js.map +1 -1
- package/dist/destinations/ms-bing-ads-audiences/index.js +1 -1
- package/dist/destinations/ms-bing-ads-audiences/index.js.map +1 -1
- package/dist/destinations/ms-bing-ads-audiences/syncAudiences/fields.js +13 -17
- package/dist/destinations/ms-bing-ads-audiences/syncAudiences/fields.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/index.js +1 -3
- package/dist/destinations/salesforce-marketing-cloud/index.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.d.ts +0 -3
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js +0 -109
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js.map +1 -1
- package/dist/destinations/snap-audiences/constants.d.ts +2 -0
- package/dist/destinations/snap-audiences/constants.js +6 -0
- package/dist/destinations/snap-audiences/constants.js.map +1 -0
- package/dist/destinations/snap-audiences/index.js +24 -40
- package/dist/destinations/snap-audiences/index.js.map +1 -1
- package/dist/destinations/snap-audiences/syncAudience/constants.d.ts +5 -0
- package/dist/destinations/snap-audiences/syncAudience/constants.js +9 -0
- package/dist/destinations/snap-audiences/syncAudience/constants.js.map +1 -0
- package/dist/destinations/snap-audiences/syncAudience/fields.d.ts +2 -0
- package/dist/destinations/snap-audiences/syncAudience/fields.js +90 -0
- package/dist/destinations/snap-audiences/syncAudience/fields.js.map +1 -0
- package/dist/destinations/snap-audiences/syncAudience/functions.d.ts +5 -0
- package/dist/destinations/snap-audiences/syncAudience/functions.js +119 -0
- package/dist/destinations/snap-audiences/syncAudience/functions.js.map +1 -0
- package/dist/destinations/snap-audiences/syncAudience/generated-types.d.ts +2 -1
- package/dist/destinations/snap-audiences/syncAudience/index.js +6 -146
- package/dist/destinations/snap-audiences/syncAudience/index.js.map +1 -1
- package/dist/destinations/snap-audiences/syncAudience/types.d.ts +18 -0
- package/dist/destinations/snap-audiences/syncAudience/types.js.map +1 -0
- package/dist/destinations/snap-audiences/types.d.ts +19 -0
- package/dist/destinations/snap-audiences/types.js.map +1 -0
- package/dist/destinations/stackadapt-audiences/common-constants.d.ts +2 -0
- package/dist/destinations/stackadapt-audiences/common-constants.js +6 -0
- package/dist/destinations/stackadapt-audiences/common-constants.js.map +1 -0
- package/dist/destinations/stackadapt-audiences/common-functions.d.ts +0 -7
- package/dist/destinations/stackadapt-audiences/common-functions.js +0 -193
- package/dist/destinations/stackadapt-audiences/common-functions.js.map +1 -1
- package/dist/destinations/stackadapt-audiences/common-types.d.ts +15 -0
- package/dist/destinations/stackadapt-audiences/{forwardProfile/generated-types.js → common-types.js} +1 -1
- package/dist/destinations/stackadapt-audiences/common-types.js.map +1 -0
- package/dist/destinations/stackadapt-audiences/{constants.js → forwardAudienceEvent/constants.js} +1 -22
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/constants.js.map +1 -0
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/fields.d.ts +1 -0
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/fields.js +184 -1
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/fields.js.map +1 -1
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.d.ts +6 -0
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.js +184 -0
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.js.map +1 -0
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/generated-types.d.ts +0 -3
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/index.js +4 -5
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/index.js.map +1 -1
- package/dist/destinations/stackadapt-audiences/{types.d.ts → forwardAudienceEvent/types.d.ts} +0 -15
- package/dist/destinations/{yonoma/sendEvent/generated-types.js → stackadapt-audiences/forwardAudienceEvent/types.js} +1 -1
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/types.js.map +1 -0
- package/dist/destinations/stackadapt-audiences/index.d.ts +1 -1
- package/dist/destinations/stackadapt-audiences/index.js +5 -7
- package/dist/destinations/stackadapt-audiences/index.js.map +1 -1
- package/dist/destinations/yonoma/index.js +0 -2
- package/dist/destinations/yonoma/index.js.map +1 -1
- package/dist/destinations/yonoma/trackEvent/generated-types.d.ts +24 -3
- package/dist/destinations/yonoma/trackEvent/index.js +140 -16
- package/dist/destinations/yonoma/trackEvent/index.js.map +1 -1
- package/dist/destinations/yonoma/trackEvent/types.d.ts +24 -3
- package/dist/destinations/yonoma/trackPageView/generated-types.d.ts +23 -7
- package/dist/destinations/yonoma/trackPageView/index.js +133 -50
- package/dist/destinations/yonoma/trackPageView/index.js.map +1 -1
- package/dist/destinations/yonoma/trackPageView/types.d.ts +22 -4
- package/dist/destinations/yonoma/upsertContact/generated-types.d.ts +25 -3
- package/dist/destinations/yonoma/upsertContact/index.js +153 -21
- package/dist/destinations/yonoma/upsertContact/index.js.map +1 -1
- package/dist/destinations/yonoma/upsertContact/types.d.ts +26 -4
- package/package.json +4 -4
- package/dist/destinations/salesforce-marketing-cloud/_tests_/asyncDataExtension.test.d.ts +0 -1
- package/dist/destinations/salesforce-marketing-cloud/_tests_/asyncDataExtension.test.js +0 -96
- package/dist/destinations/salesforce-marketing-cloud/_tests_/asyncDataExtension.test.js.map +0 -1
- package/dist/destinations/salesforce-marketing-cloud/asyncDataExtension/generated-types.d.ts +0 -58
- package/dist/destinations/salesforce-marketing-cloud/asyncDataExtension/generated-types.js +0 -3
- package/dist/destinations/salesforce-marketing-cloud/asyncDataExtension/generated-types.js.map +0 -1
- package/dist/destinations/salesforce-marketing-cloud/asyncDataExtension/index.d.ts +0 -5
- package/dist/destinations/salesforce-marketing-cloud/asyncDataExtension/index.js +0 -61
- package/dist/destinations/salesforce-marketing-cloud/asyncDataExtension/index.js.map +0 -1
- package/dist/destinations/snap-audiences/syncAudience/utils.d.ts +0 -8
- package/dist/destinations/snap-audiences/syncAudience/utils.js +0 -61
- package/dist/destinations/snap-audiences/syncAudience/utils.js.map +0 -1
- package/dist/destinations/stackadapt-audiences/common-fields.d.ts +0 -2
- package/dist/destinations/stackadapt-audiences/common-fields.js +0 -227
- package/dist/destinations/stackadapt-audiences/common-fields.js.map +0 -1
- package/dist/destinations/stackadapt-audiences/constants.js.map +0 -1
- package/dist/destinations/stackadapt-audiences/forwardProfile/generated-types.d.ts +0 -26
- package/dist/destinations/stackadapt-audiences/forwardProfile/generated-types.js.map +0 -1
- package/dist/destinations/stackadapt-audiences/forwardProfile/index.d.ts +0 -5
- package/dist/destinations/stackadapt-audiences/forwardProfile/index.js +0 -140
- package/dist/destinations/stackadapt-audiences/forwardProfile/index.js.map +0 -1
- package/dist/destinations/stackadapt-audiences/types.js.map +0 -1
- package/dist/destinations/yonoma/sendEvent/constants.d.ts +0 -1
- package/dist/destinations/yonoma/sendEvent/constants.js +0 -5
- package/dist/destinations/yonoma/sendEvent/constants.js.map +0 -1
- package/dist/destinations/yonoma/sendEvent/functions.d.ts +0 -1
- package/dist/destinations/yonoma/sendEvent/functions.js +0 -19
- package/dist/destinations/yonoma/sendEvent/functions.js.map +0 -1
- package/dist/destinations/yonoma/sendEvent/generated-types.d.ts +0 -13
- package/dist/destinations/yonoma/sendEvent/generated-types.js.map +0 -1
- package/dist/destinations/yonoma/sendEvent/index.d.ts +0 -5
- package/dist/destinations/yonoma/sendEvent/index.js +0 -103
- package/dist/destinations/yonoma/sendEvent/index.js.map +0 -1
- package/dist/destinations/yonoma/sendEvent/types.d.ts +0 -10
- package/dist/destinations/yonoma/sendEvent/types.js.map +0 -1
- /package/dist/destinations/{stackadapt-audiences → snap-audiences/syncAudience}/types.js +0 -0
- /package/dist/destinations/{yonoma/sendEvent → snap-audiences}/types.js +0 -0
- /package/dist/destinations/stackadapt-audiences/{constants.d.ts → forwardAudienceEvent/constants.d.ts} +0 -0
|
@@ -1,158 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const fields_1 = require("./fields");
|
|
4
|
+
const functions_1 = require("./functions");
|
|
5
5
|
const action = {
|
|
6
6
|
title: 'Sync Audience',
|
|
7
|
-
description: 'Sync
|
|
7
|
+
description: 'Sync Engage Audiences to Snap',
|
|
8
8
|
defaultSubscription: 'type = "track"',
|
|
9
|
-
fields:
|
|
10
|
-
external_audience_id: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
label: 'External Audience ID',
|
|
13
|
-
description: 'Unique Audience Identifier returned by the createAudience() function call.',
|
|
14
|
-
required: true,
|
|
15
|
-
unsafe_hidden: true,
|
|
16
|
-
default: {
|
|
17
|
-
'@path': '$.context.personas.external_audience_id'
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
audienceKey: {
|
|
21
|
-
type: 'string',
|
|
22
|
-
label: 'Audience Key',
|
|
23
|
-
description: 'Audience key.',
|
|
24
|
-
required: true,
|
|
25
|
-
unsafe_hidden: true,
|
|
26
|
-
default: {
|
|
27
|
-
'@path': '$.context.personas.computation_key'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
props: {
|
|
31
|
-
label: 'Properties object',
|
|
32
|
-
description: 'A computed object for track events.',
|
|
33
|
-
type: 'object',
|
|
34
|
-
required: true,
|
|
35
|
-
unsafe_hidden: true,
|
|
36
|
-
default: { '@path': '$.properties' }
|
|
37
|
-
},
|
|
38
|
-
schema_type: {
|
|
39
|
-
type: 'string',
|
|
40
|
-
choices: [
|
|
41
|
-
{ value: 'MOBILE_AD_ID_SHA256', label: 'Mobile ID' },
|
|
42
|
-
{ value: 'PHONE_SHA256', label: 'Phone' },
|
|
43
|
-
{ value: 'EMAIL_SHA256', label: 'Email' }
|
|
44
|
-
],
|
|
45
|
-
label: 'External ID Type',
|
|
46
|
-
required: true,
|
|
47
|
-
description: 'Choose the type of identifier to use when adding users to Snap.',
|
|
48
|
-
default: 'EMAIL_SHA256',
|
|
49
|
-
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment']
|
|
50
|
-
},
|
|
51
|
-
phone: {
|
|
52
|
-
label: 'Phone',
|
|
53
|
-
description: "If using phone as the identifier, an additional setup step is required when connecting the Destination to the Audience. Please ensure that 'phone' is configured as an additional identifier in the Audience settings tab.",
|
|
54
|
-
type: 'string',
|
|
55
|
-
required: false,
|
|
56
|
-
default: { '@path': '$.properties.phone' },
|
|
57
|
-
depends_on: {
|
|
58
|
-
match: 'all',
|
|
59
|
-
conditions: [
|
|
60
|
-
{
|
|
61
|
-
fieldKey: 'schema_type',
|
|
62
|
-
operator: 'is',
|
|
63
|
-
value: 'PHONE_SHA256'
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
category: 'hashedPII'
|
|
68
|
-
},
|
|
69
|
-
email: {
|
|
70
|
-
label: 'Email',
|
|
71
|
-
description: "The user's email address.",
|
|
72
|
-
type: 'string',
|
|
73
|
-
required: false,
|
|
74
|
-
default: { '@path': '$.context.traits.email' },
|
|
75
|
-
depends_on: {
|
|
76
|
-
match: 'all',
|
|
77
|
-
conditions: [
|
|
78
|
-
{
|
|
79
|
-
fieldKey: 'schema_type',
|
|
80
|
-
operator: 'is',
|
|
81
|
-
value: 'EMAIL_SHA256'
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
|
-
category: 'hashedPII'
|
|
86
|
-
},
|
|
87
|
-
advertising_id: {
|
|
88
|
-
label: 'Mobile Advertising ID',
|
|
89
|
-
description: "If using Mobile Ad ID as the identifier, an additional setup step is required when connecting the Destination to the Audience. Please ensure that 'ios.idfa' and 'android.idfa' are configured as an additional identifier in the Audience settings tab.",
|
|
90
|
-
type: 'string',
|
|
91
|
-
required: false,
|
|
92
|
-
default: {
|
|
93
|
-
'@path': '$.context.device.advertisingId'
|
|
94
|
-
},
|
|
95
|
-
depends_on: {
|
|
96
|
-
match: 'all',
|
|
97
|
-
conditions: [
|
|
98
|
-
{
|
|
99
|
-
fieldKey: 'schema_type',
|
|
100
|
-
operator: 'is',
|
|
101
|
-
value: 'MOBILE_AD_ID_SHA256'
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
category: 'hashedPII'
|
|
106
|
-
},
|
|
107
|
-
enable_batching: {
|
|
108
|
-
label: 'Enable Batching',
|
|
109
|
-
description: 'When enabled, events will be batched before being sent to Snap.',
|
|
110
|
-
type: 'boolean',
|
|
111
|
-
required: true,
|
|
112
|
-
default: true
|
|
113
|
-
}
|
|
114
|
-
},
|
|
9
|
+
fields: fields_1.fields,
|
|
115
10
|
perform: async (request, { payload }) => {
|
|
116
|
-
return
|
|
11
|
+
return (0, functions_1.send)(request, [payload]);
|
|
117
12
|
},
|
|
118
13
|
performBatch: async (request, { payload }) => {
|
|
119
|
-
return
|
|
14
|
+
return (0, functions_1.send)(request, payload);
|
|
120
15
|
}
|
|
121
16
|
};
|
|
122
17
|
exports.default = action;
|
|
123
|
-
const processPayload = async (request, payload) => {
|
|
124
|
-
const { external_audience_id, schema_type } = payload[0];
|
|
125
|
-
const { enteredAudience, exitedAudience } = (0, utils_1.sortPayload)(payload);
|
|
126
|
-
if (enteredAudience.length === 0 && exitedAudience.length === 0) {
|
|
127
|
-
throw new actions_core_1.PayloadValidationError(`No ${(0, utils_1.validationError)(schema_type)} identifier present in payload(s)`);
|
|
128
|
-
}
|
|
129
|
-
const requests = [];
|
|
130
|
-
if (enteredAudience.length > 0) {
|
|
131
|
-
requests.push(request(`https://adsapi.snapchat.com/v1/segments/${external_audience_id}/users`, {
|
|
132
|
-
method: 'post',
|
|
133
|
-
json: {
|
|
134
|
-
users: [
|
|
135
|
-
{
|
|
136
|
-
schema: [`${schema_type}`],
|
|
137
|
-
data: enteredAudience
|
|
138
|
-
}
|
|
139
|
-
]
|
|
140
|
-
}
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
if (exitedAudience.length > 0) {
|
|
144
|
-
requests.push(request(`https://adsapi.snapchat.com/v1/segments/${external_audience_id}/users`, {
|
|
145
|
-
method: 'delete',
|
|
146
|
-
json: {
|
|
147
|
-
users: [
|
|
148
|
-
{
|
|
149
|
-
schema: [`${schema_type}`],
|
|
150
|
-
data: exitedAudience
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
}
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
return await Promise.all(requests);
|
|
157
|
-
};
|
|
158
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/snap-audiences/syncAudience/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/snap-audiences/syncAudience/index.ts"],"names":[],"mappings":";;AAGA,qCAAiC;AACjC,2CAAkC;AAElC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,+BAA+B;IAC5C,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAN,eAAM;IACN,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACtC,OAAO,IAAA,gBAAI,EAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IACjC,CAAC;IACD,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC3C,OAAO,IAAA,gBAAI,EAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/B,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Payload } from './generated-types';
|
|
2
|
+
import { SCHEMA_TYPES } from './constants';
|
|
3
|
+
export interface PayloadWithIndex extends Payload {
|
|
4
|
+
index: number;
|
|
5
|
+
}
|
|
6
|
+
export interface OperationType {
|
|
7
|
+
method: 'POST' | 'DELETE';
|
|
8
|
+
type: SchemaType;
|
|
9
|
+
}
|
|
10
|
+
export interface AddRemoveUsersJSON {
|
|
11
|
+
users: [
|
|
12
|
+
{
|
|
13
|
+
schema: ["EMAIL_SHA256"] | ["PHONE_SHA256"] | ["MOBILE_AD_ID_SHA256"];
|
|
14
|
+
data: [string][];
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
export type SchemaType = typeof SCHEMA_TYPES[keyof typeof SCHEMA_TYPES];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/snap-audiences/syncAudience/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface RefreshTokenResponse {
|
|
2
|
+
access_token: string;
|
|
3
|
+
}
|
|
4
|
+
export interface SnapAudienceResponse {
|
|
5
|
+
segments: {
|
|
6
|
+
segment: {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
export interface CreateAudienceReq {
|
|
12
|
+
segments: {
|
|
13
|
+
name: string;
|
|
14
|
+
source_type: string;
|
|
15
|
+
ad_account_id: string;
|
|
16
|
+
description: string;
|
|
17
|
+
retention_in_days: number;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/destinations/snap-audiences/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GQL_ENDPOINT = exports.EXTERNAL_PROVIDER = void 0;
|
|
4
|
+
exports.EXTERNAL_PROVIDER = 'segment_io';
|
|
5
|
+
exports.GQL_ENDPOINT = 'https://api.stackadapt.com/graphql';
|
|
6
|
+
//# sourceMappingURL=common-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-constants.js","sourceRoot":"","sources":["../../../src/destinations/stackadapt-audiences/common-constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,YAAY,CAAA;AAEhC,QAAA,YAAY,GAAG,oCAAoC,CAAA"}
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import { RequestClient } from '@segment/actions-core';
|
|
2
|
-
import { Settings } from './generated-types';
|
|
3
|
-
import type { Payload as AudiencePayload } from './forwardAudienceEvent/generated-types';
|
|
4
|
-
import type { Payload as RegularPayload } from './forwardProfile/generated-types';
|
|
5
|
-
export declare function send(request: RequestClient, payloads: RegularPayload[] | AudiencePayload[], settings: Settings, isAudience: boolean): Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
6
1
|
export declare function sha256hash(data: string): string;
|
|
7
|
-
export declare function stringifyJsonWithEscapedQuotes(value: unknown): string;
|
|
8
|
-
export declare function stringifyMappingSchemaForGraphQL(value: unknown): string;
|
|
@@ -1,203 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.send = send;
|
|
4
3
|
exports.sha256hash = sha256hash;
|
|
5
|
-
exports.stringifyJsonWithEscapedQuotes = stringifyJsonWithEscapedQuotes;
|
|
6
|
-
exports.stringifyMappingSchemaForGraphQL = stringifyMappingSchemaForGraphQL;
|
|
7
|
-
const constants_1 = require("./constants");
|
|
8
4
|
const crypto_1 = require("crypto");
|
|
9
|
-
async function send(request, payloads, settings, isAudience) {
|
|
10
|
-
const fieldTypes = getDefaultFieldTypes();
|
|
11
|
-
const fieldsToMap = getDefaultFieldsToMap();
|
|
12
|
-
const advertiserId = settings.advertiser_id;
|
|
13
|
-
const marketingStatus = payloads[0].marketing_status;
|
|
14
|
-
const profileUpdates = payloads.map((p) => {
|
|
15
|
-
const { user_id, standard_traits: { birth_date, birth_day, birth_month, birth_year, ...restStandardTraits } = {}, custom_traits, email } = p;
|
|
16
|
-
const segment_computation_key = isAudience ? p.segment_computation_key : undefined;
|
|
17
|
-
const segment_computation_id = isAudience ? p.segment_computation_id : undefined;
|
|
18
|
-
const traits_or_props = isAudience ? p.traits_or_props : undefined;
|
|
19
|
-
if (isAudience && custom_traits) {
|
|
20
|
-
delete custom_traits[segment_computation_key];
|
|
21
|
-
delete custom_traits[segment_computation_id];
|
|
22
|
-
}
|
|
23
|
-
let date;
|
|
24
|
-
if (birth_date) {
|
|
25
|
-
date = new Date(birth_date);
|
|
26
|
-
}
|
|
27
|
-
const profile = {
|
|
28
|
-
userId: user_id,
|
|
29
|
-
email,
|
|
30
|
-
...restStandardTraits,
|
|
31
|
-
birth_day: (date ? date.getDate() : birth_day) ?? undefined,
|
|
32
|
-
birth_month: (date ? date.getMonth() + 1 : birth_month) ?? undefined,
|
|
33
|
-
birth_year: (date ? date.getFullYear() : birth_year) ?? undefined,
|
|
34
|
-
...custom_traits
|
|
35
|
-
};
|
|
36
|
-
if (isAudience && traits_or_props && segment_computation_key && segment_computation_id) {
|
|
37
|
-
profile.audienceId = segment_computation_id;
|
|
38
|
-
profile.audienceName = segment_computation_key;
|
|
39
|
-
profile.action = traits_or_props[segment_computation_key] ? 'enter' : 'exit';
|
|
40
|
-
}
|
|
41
|
-
if (!isAudience && p.previous_id) {
|
|
42
|
-
profile.previous_id = p.previous_id;
|
|
43
|
-
}
|
|
44
|
-
updateFieldsToMapAndFieldTypes(fieldsToMap, fieldTypes, custom_traits);
|
|
45
|
-
return profile;
|
|
46
|
-
});
|
|
47
|
-
const mappings = getProfileMappings(Array.from(fieldsToMap), fieldTypes);
|
|
48
|
-
const profiles = stringifyJsonWithEscapedQuotes(profileUpdates);
|
|
49
|
-
const mutation = `mutation {
|
|
50
|
-
upsertProfiles(
|
|
51
|
-
input: {
|
|
52
|
-
advertiserId: ${advertiserId},
|
|
53
|
-
externalProvider: "${constants_1.EXTERNAL_PROVIDER}",
|
|
54
|
-
syncId: "${sha256hash(profiles)}",
|
|
55
|
-
profiles: "${profiles}"
|
|
56
|
-
}
|
|
57
|
-
) {
|
|
58
|
-
userErrors {
|
|
59
|
-
message
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
upsertProfileMapping(
|
|
63
|
-
input: {
|
|
64
|
-
advertiserId: ${advertiserId},
|
|
65
|
-
mappingSchemaV2: ${mappings},
|
|
66
|
-
isOptedIn: ${marketingStatus === constants_1.MarketingStatus.OPT_IN},
|
|
67
|
-
mappableType: "${constants_1.EXTERNAL_PROVIDER}"
|
|
68
|
-
}
|
|
69
|
-
) {
|
|
70
|
-
userErrors {
|
|
71
|
-
message
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
${isAudience ? audienceMutation(advertiserId, stringifyMappingSchemaForGraphQL(constants_1.MAPPING_SCHEMA)) : ""}
|
|
75
|
-
}`;
|
|
76
|
-
return await request(constants_1.GQL_ENDPOINT, {
|
|
77
|
-
body: JSON.stringify({ query: mutation })
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
5
|
function sha256hash(data) {
|
|
81
6
|
const hash = (0, crypto_1.createHash)('sha256');
|
|
82
7
|
hash.update(data);
|
|
83
8
|
return hash.digest('hex');
|
|
84
9
|
}
|
|
85
|
-
function audienceMutation(advertiserId, audienceMapping) {
|
|
86
|
-
return `upsertExternalAudienceMapping(
|
|
87
|
-
input: {
|
|
88
|
-
advertiserId: ${advertiserId},
|
|
89
|
-
mappingSchema: ${audienceMapping},
|
|
90
|
-
mappableType: "${constants_1.EXTERNAL_PROVIDER}"
|
|
91
|
-
}
|
|
92
|
-
) {
|
|
93
|
-
userErrors {
|
|
94
|
-
message
|
|
95
|
-
}
|
|
96
|
-
}`;
|
|
97
|
-
}
|
|
98
|
-
function updateFieldsToMapAndFieldTypes(fieldsToMap, fieldTypes, customTraits = {}) {
|
|
99
|
-
return Object.keys(customTraits).reduce((acc, key) => {
|
|
100
|
-
const value = customTraits[key];
|
|
101
|
-
if (key === '' || value === '') {
|
|
102
|
-
return acc;
|
|
103
|
-
}
|
|
104
|
-
acc[key] = value;
|
|
105
|
-
const standardFields = getDefaultFieldsToMap();
|
|
106
|
-
if (!standardFields.has(key)) {
|
|
107
|
-
fieldsToMap.add(key);
|
|
108
|
-
if (value || value === 0) {
|
|
109
|
-
const type = getType(value);
|
|
110
|
-
if (fieldTypes[key] && fieldTypes[key] !== type) {
|
|
111
|
-
fieldTypes[key] = 'STRING';
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
fieldTypes[key] = type;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return acc;
|
|
119
|
-
}, {});
|
|
120
|
-
}
|
|
121
|
-
function getProfileMappings(customFields, fieldTypes) {
|
|
122
|
-
const mappingSchema = [];
|
|
123
|
-
for (const field of customFields) {
|
|
124
|
-
const fieldConfig = constants_1.PROFILE_DEFAULT_FIELDS.find((f) => f.key === field);
|
|
125
|
-
if (fieldConfig) {
|
|
126
|
-
let destinationKey;
|
|
127
|
-
switch (fieldConfig.key) {
|
|
128
|
-
case 'user_id':
|
|
129
|
-
destinationKey = 'external_id';
|
|
130
|
-
break;
|
|
131
|
-
default:
|
|
132
|
-
destinationKey = fieldConfig.key;
|
|
133
|
-
}
|
|
134
|
-
mappingSchema.push({
|
|
135
|
-
incomingKey: field,
|
|
136
|
-
destinationKey,
|
|
137
|
-
label: fieldConfig.label,
|
|
138
|
-
type: fieldConfig.type.toUpperCase(),
|
|
139
|
-
isPii: fieldConfig.isPii || false
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
mappingSchema.push({
|
|
144
|
-
incomingKey: field,
|
|
145
|
-
destinationKey: field,
|
|
146
|
-
label: generateLabel(field),
|
|
147
|
-
type: fieldTypes[field] ?? 'STRING',
|
|
148
|
-
isPii: false
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return stringifyMappingSchemaForGraphQL(mappingSchema);
|
|
153
|
-
}
|
|
154
|
-
function generateLabel(field) {
|
|
155
|
-
let label = field
|
|
156
|
-
.replace(/_/g, ' ')
|
|
157
|
-
.trim()
|
|
158
|
-
.replace(/\b\w/g, (str) => str.toUpperCase());
|
|
159
|
-
if (field.startsWith('audience')) {
|
|
160
|
-
label = `External ${label}`;
|
|
161
|
-
}
|
|
162
|
-
return label;
|
|
163
|
-
}
|
|
164
|
-
function getType(value) {
|
|
165
|
-
if (isDateStr(value))
|
|
166
|
-
return 'DATE';
|
|
167
|
-
return (typeof value).toUpperCase();
|
|
168
|
-
}
|
|
169
|
-
function isDateStr(value) {
|
|
170
|
-
if (typeof value !== 'string')
|
|
171
|
-
return false;
|
|
172
|
-
const datePatterns = [
|
|
173
|
-
/^\d{4}-\d{2}-\d{2}/,
|
|
174
|
-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
|
|
175
|
-
/^\d{1,2}\/\d{1,2}\/\d{4}/,
|
|
176
|
-
/^\d{1,2}-\d{1,2}-\d{4}/
|
|
177
|
-
];
|
|
178
|
-
const hasDatePattern = datePatterns.some(pattern => pattern.test(value));
|
|
179
|
-
if (!hasDatePattern)
|
|
180
|
-
return false;
|
|
181
|
-
const parsed = Date.parse(value);
|
|
182
|
-
return !isNaN(parsed);
|
|
183
|
-
}
|
|
184
|
-
function stringifyJsonWithEscapedQuotes(value) {
|
|
185
|
-
const jsonString = JSON.stringify(value);
|
|
186
|
-
return jsonString.replace(/"/g, '\\"');
|
|
187
|
-
}
|
|
188
|
-
function stringifyMappingSchemaForGraphQL(value) {
|
|
189
|
-
let jsonString = JSON.stringify(value);
|
|
190
|
-
jsonString = jsonString.replace(/"type":"([^"]+)"/g, (_, typeValue) => `type:${typeValue.toUpperCase()}`);
|
|
191
|
-
jsonString = jsonString.replace(/"([a-zA-Z_][a-zA-Z0-9_]*)"\s*:/g, '$1:');
|
|
192
|
-
return jsonString;
|
|
193
|
-
}
|
|
194
|
-
const getDefaultFieldsToMap = () => {
|
|
195
|
-
return new Set(constants_1.PROFILE_DEFAULT_FIELDS.map(field => field.key));
|
|
196
|
-
};
|
|
197
|
-
const getDefaultFieldTypes = () => {
|
|
198
|
-
return constants_1.PROFILE_DEFAULT_FIELDS.reduce((acc, field) => {
|
|
199
|
-
acc[field.key] = field.type.toUpperCase();
|
|
200
|
-
return acc;
|
|
201
|
-
}, {});
|
|
202
|
-
};
|
|
203
10
|
//# sourceMappingURL=common-functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-functions.js","sourceRoot":"","sources":["../../../src/destinations/stackadapt-audiences/common-functions.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"common-functions.js","sourceRoot":"","sources":["../../../src/destinations/stackadapt-audiences/common-functions.ts"],"names":[],"mappings":";;AAGA,gCAIC;AAND,mCAAmC;AAEnC,SAAgB,UAAU,CAAC,IAAY;IACrC,MAAM,IAAI,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAA;IACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-types.js","sourceRoot":"","sources":["../../../src/destinations/stackadapt-audiences/common-types.ts"],"names":[],"mappings":""}
|
package/dist/destinations/stackadapt-audiences/{constants.js → forwardAudienceEvent/constants.js}
RENAMED
|
@@ -81,31 +81,10 @@ exports.PROFILE_DEFAULT_FIELDS = [
|
|
|
81
81
|
description: 'The timezone of the user',
|
|
82
82
|
isPii: false,
|
|
83
83
|
},
|
|
84
|
-
{
|
|
85
|
-
key: 'birth_day',
|
|
86
|
-
label: 'Birth Day',
|
|
87
|
-
type: 'number',
|
|
88
|
-
description: 'The birth day of the user (1-31)',
|
|
89
|
-
isPii: false,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
key: 'birth_month',
|
|
93
|
-
label: 'Birth Month',
|
|
94
|
-
type: 'number',
|
|
95
|
-
description: 'The birth month of the user (1-12)',
|
|
96
|
-
isPii: false,
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
key: 'birth_year',
|
|
100
|
-
label: 'Birth Year',
|
|
101
|
-
type: 'number',
|
|
102
|
-
description: 'The birth year of the user (YYYY)',
|
|
103
|
-
isPii: false,
|
|
104
|
-
},
|
|
105
84
|
{
|
|
106
85
|
key: 'birth_date',
|
|
107
86
|
label: 'Birth Date',
|
|
108
|
-
type: '
|
|
87
|
+
type: 'date',
|
|
109
88
|
description: 'The birth date of the user',
|
|
110
89
|
isPii: true,
|
|
111
90
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/destinations/stackadapt-audiences/forwardAudienceEvent/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,iBAAiB,GAAG,YAAY,CAAA;AAEhC,QAAA,YAAY,GAAG,oCAAoC,CAAA;AAInD,QAAA,sBAAsB,GAAyB;IAC1D;QACE,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oCAAoC;QACjD,KAAK,EAAE,KAAK;KACb;IACD;QACE,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,+BAA+B;QAC5C,KAAK,EAAE,IAAI;KACZ;IACD;QACE,GAAG,EAAE,YAAY;QACjB,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,uBAAuB;QACpC,KAAK,EAAE,IAAI;KACZ;IACD;QACE,GAAG,EAAE,WAAW;QAChB,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,sBAAsB;QACnC,KAAK,EAAE,IAAI;KACZ;IACD;QACE,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,8BAA8B;QAC3C,KAAK,EAAE,IAAI;KACZ;IACD;QACE,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,yBAAyB;QACtC,KAAK,EAAE,IAAI;KACZ;IACD;QACE,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,sBAAsB;QACnC,KAAK,EAAE,KAAK;KACb;IACD;QACE,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,uBAAuB;QACpC,KAAK,EAAE,KAAK;KACb;IACD;QACE,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,yBAAyB;QACtC,KAAK,EAAE,KAAK;KACb;IACD;QACE,GAAG,EAAE,aAAa;QAClB,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,6BAA6B;QAC1C,KAAK,EAAE,KAAK;KACb;IACD;QACE,GAAG,EAAE,UAAU;QACf,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,0BAA0B;QACvC,KAAK,EAAE,KAAK;KACb;IACD;QACE,GAAG,EAAE,YAAY;QACjB,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,4BAA4B;QACzC,KAAK,EAAE,IAAI;KACZ;CACF,CAAA;AAEY,QAAA,cAAc,GAAG;IAC5B;QACE,WAAW,EAAE,YAAY;QACzB,cAAc,EAAE,aAAa;QAC7B,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,sBAAsB;QAC7B,KAAK,EAAE,KAAK;KACb;IACD;QACE,WAAW,EAAE,cAAc;QAC3B,cAAc,EAAE,MAAM;QACtB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,KAAK;KACb;CACF,CAAA;AAEY,QAAA,eAAe,GAAG;IAC7B,MAAM,EAAE,UAAU;IAClB,aAAa,EAAE,eAAe;CACtB,CAAA"}
|