@segment/action-destinations 3.290.0-staging-3f88702f7 → 3.290.0-staging-041024fe6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/amazon-ads/generated-types.d.ts +1 -1
- package/dist/destinations/amazon-ads/index.js +95 -76
- package/dist/destinations/amazon-ads/index.js.map +1 -1
- package/dist/destinations/amazon-ads/syncAudiences/generated-types.d.ts +19 -13
- package/dist/destinations/amazon-ads/syncAudiences/index.js +140 -155
- package/dist/destinations/amazon-ads/syncAudiences/index.js.map +1 -1
- package/dist/destinations/amazon-ads/types.d.ts +0 -25
- package/dist/destinations/amazon-ads/utils.d.ts +1 -13
- package/dist/destinations/amazon-ads/utils.js +1 -18
- package/dist/destinations/amazon-ads/utils.js.map +1 -1
- package/dist/destinations/blackbaud-raisers-edge-nxt/utils/index.d.ts +1 -1
- package/dist/destinations/customerio/utils.d.ts +1 -1
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.d.ts +2 -5
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js +18 -98
- package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js.map +1 -1
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js +1 -2
- package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js.map +1 -1
- package/dist/destinations/engage/twilio/sendMobilePush/PushSender.d.ts +1 -0
- package/dist/destinations/engage/twilio/sendMobilePush/PushSender.js +20 -2
- package/dist/destinations/engage/twilio/sendMobilePush/PushSender.js.map +1 -1
- package/dist/destinations/engage/utils/EngageActionPerformer.js +17 -2
- package/dist/destinations/engage/utils/EngageActionPerformer.js.map +1 -1
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.d.ts +3 -0
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.js +15 -0
- package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.js.map +1 -1
- package/dist/destinations/engage/utils/track.d.ts +15 -12
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.d.ts +1 -1
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js +8 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js.map +1 -1
- package/dist/destinations/facebook-custom-audiences/fbca-operations.d.ts +32 -0
- package/dist/destinations/facebook-custom-audiences/fbca-operations.js +50 -0
- package/dist/destinations/facebook-custom-audiences/fbca-operations.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/fbca-properties.d.ts +2 -0
- package/dist/destinations/facebook-custom-audiences/fbca-properties.js +10 -0
- package/dist/destinations/facebook-custom-audiences/fbca-properties.js.map +1 -0
- package/dist/destinations/facebook-custom-audiences/generated-types.d.ts +1 -1
- package/dist/destinations/facebook-custom-audiences/index.js +5 -15
- package/dist/destinations/facebook-custom-audiences/index.js.map +1 -1
- package/dist/destinations/facebook-custom-audiences/sync/generated-types.d.ts +14 -0
- package/dist/destinations/facebook-custom-audiences/sync/generated-types.js.map +1 -0
- package/dist/destinations/{movable-ink/productAdded → facebook-custom-audiences/sync}/index.d.ts +1 -1
- package/dist/destinations/facebook-custom-audiences/sync/index.js +87 -0
- package/dist/destinations/facebook-custom-audiences/sync/index.js.map +1 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/generated-types.d.ts +13 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/generated-types.js.map +1 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/index.js +95 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/index.js.map +1 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/s3.d.ts +6 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/s3.js +37 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/s3.js.map +1 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/sftp.d.ts +7 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/sftp.js +52 -0
- package/dist/destinations/liveramp-audiences/audienceEntered/sftp.js.map +1 -0
- package/dist/destinations/taboola-actions/index.js +1 -1
- package/dist/destinations/taboola-actions/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.d.ts +0 -1
- package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js +0 -184
- package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js.map +0 -1
- package/dist/destinations/contentstack/constants.d.ts +0 -3
- package/dist/destinations/contentstack/constants.js +0 -7
- package/dist/destinations/contentstack/constants.js.map +0 -1
- package/dist/destinations/klaviyo/removeProfileToList/generated-types.d.ts +0 -4
- package/dist/destinations/klaviyo/removeProfileToList/generated-types.js.map +0 -1
- package/dist/destinations/klaviyo/removeProfileToList/index.d.ts +0 -5
- package/dist/destinations/klaviyo/removeProfileToList/index.js +0 -43
- package/dist/destinations/klaviyo/removeProfileToList/index.js.map +0 -1
- package/dist/destinations/movable-ink/categoryView/generated-types.d.ts +0 -22
- package/dist/destinations/movable-ink/categoryView/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/categoryView/index.js +0 -43
- package/dist/destinations/movable-ink/categoryView/index.js.map +0 -1
- package/dist/destinations/movable-ink/conversion/generated-types.d.ts +0 -20
- package/dist/destinations/movable-ink/conversion/generated-types.js +0 -3
- package/dist/destinations/movable-ink/conversion/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/conversion/index.d.ts +0 -5
- package/dist/destinations/movable-ink/conversion/index.js +0 -45
- package/dist/destinations/movable-ink/conversion/index.js.map +0 -1
- package/dist/destinations/movable-ink/fields.d.ts +0 -21
- package/dist/destinations/movable-ink/fields.js +0 -236
- package/dist/destinations/movable-ink/fields.js.map +0 -1
- package/dist/destinations/movable-ink/identify/generated-types.d.ts +0 -7
- package/dist/destinations/movable-ink/identify/generated-types.js +0 -3
- package/dist/destinations/movable-ink/identify/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/identify/index.d.ts +0 -5
- package/dist/destinations/movable-ink/identify/index.js +0 -32
- package/dist/destinations/movable-ink/identify/index.js.map +0 -1
- package/dist/destinations/movable-ink/productAdded/generated-types.d.ts +0 -22
- package/dist/destinations/movable-ink/productAdded/generated-types.js +0 -3
- package/dist/destinations/movable-ink/productAdded/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/productAdded/index.js +0 -43
- package/dist/destinations/movable-ink/productAdded/index.js.map +0 -1
- package/dist/destinations/movable-ink/productViewed/generated-types.d.ts +0 -21
- package/dist/destinations/movable-ink/productViewed/generated-types.js +0 -3
- package/dist/destinations/movable-ink/productViewed/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/productViewed/index.d.ts +0 -5
- package/dist/destinations/movable-ink/productViewed/index.js +0 -43
- package/dist/destinations/movable-ink/productViewed/index.js.map +0 -1
- package/dist/destinations/movable-ink/search/generated-types.d.ts +0 -12
- package/dist/destinations/movable-ink/search/generated-types.js +0 -3
- package/dist/destinations/movable-ink/search/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/search/index.d.ts +0 -5
- package/dist/destinations/movable-ink/search/index.js +0 -43
- package/dist/destinations/movable-ink/search/index.js.map +0 -1
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.d.ts +0 -25
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js +0 -3
- package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js.map +0 -1
- package/dist/destinations/movable-ink/sendCustomEvent/index.d.ts +0 -5
- package/dist/destinations/movable-ink/sendCustomEvent/index.js +0 -48
- package/dist/destinations/movable-ink/sendCustomEvent/index.js.map +0 -1
- package/dist/destinations/responsys/asyncMergePetRecords/generated-types.d.ts +0 -14
- package/dist/destinations/responsys/asyncMergePetRecords/generated-types.js +0 -3
- package/dist/destinations/responsys/asyncMergePetRecords/generated-types.js.map +0 -1
- package/dist/destinations/responsys/asyncMergePetRecords/index.d.ts +0 -5
- package/dist/destinations/responsys/asyncMergePetRecords/index.js +0 -113
- package/dist/destinations/responsys/asyncMergePetRecords/index.js.map +0 -1
- package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.d.ts +0 -20
- package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.js +0 -3
- package/dist/destinations/responsys/asyncMergeProfileListMembers/generated-types.js.map +0 -1
- package/dist/destinations/responsys/asyncMergeProfileListMembers/index.d.ts +0 -5
- package/dist/destinations/responsys/asyncMergeProfileListMembers/index.js +0 -174
- package/dist/destinations/responsys/asyncMergeProfileListMembers/index.js.map +0 -1
- package/dist/destinations/responsys/rsp-operations.d.ts +0 -14
- package/dist/destinations/responsys/rsp-operations.js +0 -33
- package/dist/destinations/responsys/rsp-operations.js.map +0 -1
- package/dist/destinations/responsys/rsp-properties.d.ts +0 -4
- package/dist/destinations/responsys/rsp-properties.js +0 -27
- package/dist/destinations/responsys/rsp-properties.js.map +0 -1
- package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.d.ts +0 -1
- package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.js +0 -381
- package/dist/destinations/snap-conversions-api/_tests_/capiV2tests.js.map +0 -1
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.d.ts +0 -1
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.js +0 -581
- package/dist/destinations/snap-conversions-api/_tests_/capiV3tests.js.map +0 -1
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.d.ts +0 -4
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.js +0 -97
- package/dist/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v2.js.map +0 -1
- package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.d.ts +0 -3
- package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.js +0 -43
- package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/formatter.js.map +0 -1
- package/dist/destinations/trackey/group.types.d.ts +0 -11
- package/dist/destinations/trackey/group.types.js +0 -3
- package/dist/destinations/trackey/group.types.js.map +0 -1
- package/dist/destinations/trackey/identify.types.d.ts +0 -11
- package/dist/destinations/trackey/identify.types.js +0 -3
- package/dist/destinations/trackey/identify.types.js.map +0 -1
- package/dist/destinations/trackey/track.types.d.ts +0 -12
- package/dist/destinations/trackey/track.types.js +0 -3
- package/dist/destinations/trackey/track.types.js.map +0 -1
- /package/dist/destinations/{klaviyo/removeProfileToList → facebook-custom-audiences/sync}/generated-types.js +0 -0
- /package/dist/destinations/{movable-ink/categoryView → liveramp-audiences/audienceEntered}/generated-types.js +0 -0
- /package/dist/destinations/{movable-ink/categoryView → liveramp-audiences/audienceEntered}/index.d.ts +0 -0
|
@@ -26,27 +26,28 @@ const destination = {
|
|
|
26
26
|
required: true
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
testAuthentication: async (request, { auth
|
|
29
|
+
testAuthentication: async (request, { auth }) => {
|
|
30
|
+
if (!process.env.ACTIONS_AMAZON_ADS_CLIENT_ID) {
|
|
31
|
+
throw new actions_core_1.IntegrationError('Missing amazon API client ID', 'MISSING_REQUIRED_FIELD', 400);
|
|
32
|
+
}
|
|
30
33
|
if (!auth?.accessToken) {
|
|
31
34
|
throw new actions_core_1.InvalidAuthenticationError('Please authenticate via Oauth before enabling the destination.');
|
|
32
35
|
}
|
|
33
36
|
try {
|
|
34
|
-
await request(
|
|
37
|
+
await request('https://advertising-api.amazon.com/v2/profiles', {
|
|
35
38
|
method: 'GET'
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
catch (e) {
|
|
39
42
|
const error = e;
|
|
40
43
|
if (error.message === 'Unauthorized') {
|
|
41
|
-
throw new
|
|
44
|
+
throw new Error('Invalid Amazon Oauth access token. Please reauthenticate to retrieve a valid access token before enabling the destination.');
|
|
42
45
|
}
|
|
43
46
|
throw e;
|
|
44
47
|
}
|
|
45
48
|
},
|
|
46
|
-
refreshAccessToken: async (request, { auth
|
|
47
|
-
const endpoint = utils_1.AUTHORIZATION_URL[`${settings.region}`];
|
|
49
|
+
refreshAccessToken: async (request, { auth }) => {
|
|
48
50
|
let res;
|
|
49
|
-
console.log(settings.region, auth, endpoint);
|
|
50
51
|
try {
|
|
51
52
|
res = await request('https://api.amazon.com/auth/o2/token', {
|
|
52
53
|
method: 'POST',
|
|
@@ -55,21 +56,17 @@ const destination = {
|
|
|
55
56
|
client_id: auth.clientId,
|
|
56
57
|
client_secret: auth.clientSecret,
|
|
57
58
|
grant_type: 'refresh_token'
|
|
58
|
-
})
|
|
59
|
-
headers: {
|
|
60
|
-
authorization: ''
|
|
61
|
-
}
|
|
59
|
+
})
|
|
62
60
|
});
|
|
63
|
-
return { accessToken: res.data.access_token };
|
|
64
61
|
}
|
|
65
62
|
catch (e) {
|
|
66
|
-
console.log(e);
|
|
67
63
|
const error = e;
|
|
68
64
|
if (error.response?.data?.error === 'invalid_grant') {
|
|
69
|
-
throw new actions_core_1.
|
|
65
|
+
throw new actions_core_1.IntegrationError(`Invalid Authentication: Your refresh token is invalid or expired. Please re-authenticate to fetch a new refresh token.`, actions_core_1.ErrorCodes.REFRESH_TOKEN_EXPIRED, 401);
|
|
70
66
|
}
|
|
71
|
-
throw new actions_core_1.
|
|
67
|
+
throw new actions_core_1.IntegrationError(`Failed to fetch a new access token. Reason: ${error.response?.data?.error}`, actions_core_1.ErrorCodes.OAUTH_REFRESH_FAILED, 401);
|
|
72
68
|
}
|
|
69
|
+
return { accessToken: res?.data?.access_token };
|
|
73
70
|
}
|
|
74
71
|
},
|
|
75
72
|
extendRequest({ auth }) {
|
|
@@ -90,7 +87,7 @@ const destination = {
|
|
|
90
87
|
countryCode: {
|
|
91
88
|
type: 'string',
|
|
92
89
|
label: 'Country Code',
|
|
93
|
-
required:
|
|
90
|
+
required: false,
|
|
94
91
|
description: 'A String value representing ISO 3166-1 alpha-2 country code for the members in this audience.'
|
|
95
92
|
},
|
|
96
93
|
externalAudienceId: {
|
|
@@ -107,7 +104,7 @@ const destination = {
|
|
|
107
104
|
currency: {
|
|
108
105
|
label: 'Currency',
|
|
109
106
|
type: 'string',
|
|
110
|
-
description: `The price paid. Base units depend on the currency. As an example, USD should be reported as Dollars.Cents, whereas JPY should be reported as a whole number of Yen. All provided values will be rounded to two digits with toFixed(2)
|
|
107
|
+
description: `The price paid. Base units depend on the currency. As an example, USD should be reported as Dollars.Cents, whereas JPY should be reported as a whole number of Yen. All provided values will be rounded to two digits with toFixed(2)`
|
|
111
108
|
},
|
|
112
109
|
ttl: {
|
|
113
110
|
type: 'number',
|
|
@@ -128,36 +125,27 @@ const destination = {
|
|
|
128
125
|
full_audience_sync: false
|
|
129
126
|
},
|
|
130
127
|
async createAudience(request, createAudienceInput) {
|
|
131
|
-
const { audienceName, statsContext
|
|
132
|
-
const { statsClient, tags: statsTags } = statsContext || {};
|
|
128
|
+
const { audienceName, statsContext } = createAudienceInput;
|
|
133
129
|
const endpoint = createAudienceInput.settings.region;
|
|
134
|
-
const description = audienceSettings?.description;
|
|
135
|
-
const advertiser_id = audienceSettings?.advertiserId;
|
|
136
|
-
const external_audience_id = audienceSettings?.externalAudienceId;
|
|
137
|
-
const country_code = audienceSettings?.countryCode;
|
|
138
|
-
const ttl = audienceSettings?.ttl;
|
|
139
|
-
const currency = audienceSettings?.currency;
|
|
140
|
-
const cpm_cents = audienceSettings?.cpmCents;
|
|
141
|
-
const
|
|
142
|
-
statsTags?.push(`slug:${destination.slug}`);
|
|
143
|
-
statsTags?.push(`ttl_type:${typeof ttl}_${ttl}`);
|
|
144
|
-
statsTags?.push(`cpmcents_type:${typeof cpm_cents}_${cpm_cents}`);
|
|
145
|
-
statsClient?.incr(`${statsName}.intialise`, 1, statsTags);
|
|
146
|
-
console.log(ttl, cpm_cents);
|
|
130
|
+
const description = createAudienceInput.audienceSettings?.description;
|
|
131
|
+
const advertiser_id = createAudienceInput.audienceSettings?.advertiserId;
|
|
132
|
+
const external_audience_id = createAudienceInput.audienceSettings?.externalAudienceId;
|
|
133
|
+
const country_code = createAudienceInput.audienceSettings?.countryCode;
|
|
134
|
+
const ttl = createAudienceInput.audienceSettings?.ttl;
|
|
135
|
+
const currency = createAudienceInput.audienceSettings?.currency;
|
|
136
|
+
const cpm_cents = createAudienceInput.audienceSettings?.cpmCents;
|
|
137
|
+
const { statsClient, tags: statsTags } = statsContext || {};
|
|
147
138
|
if (!advertiser_id) {
|
|
148
|
-
throw new actions_core_1.IntegrationError('Missing advertiserId
|
|
139
|
+
throw new actions_core_1.IntegrationError('Missing advertiserId value', 'MISSING_REQUIRED_FIELD', 400);
|
|
149
140
|
}
|
|
150
141
|
if (!description) {
|
|
151
|
-
throw new actions_core_1.IntegrationError('Missing
|
|
142
|
+
throw new actions_core_1.IntegrationError('Missing Description value', 'MISSING_REQUIRED_FIELD', 400);
|
|
152
143
|
}
|
|
153
144
|
if (!external_audience_id) {
|
|
154
|
-
throw new actions_core_1.IntegrationError('Missing
|
|
145
|
+
throw new actions_core_1.IntegrationError('Missing External Audience Id value', 'MISSING_REQUIRED_FIELD', 400);
|
|
155
146
|
}
|
|
156
147
|
if (!audienceName) {
|
|
157
|
-
throw new actions_core_1.IntegrationError('Missing
|
|
158
|
-
}
|
|
159
|
-
if (!country_code) {
|
|
160
|
-
throw new actions_core_1.IntegrationError('Missing countryCode Value', 'MISSING_REQUIRED_FIELD', 400);
|
|
148
|
+
throw new actions_core_1.IntegrationError('Missing Audience name value', 'MISSING_REQUIRED_FIELD', 400);
|
|
161
149
|
}
|
|
162
150
|
const payload = {
|
|
163
151
|
name: audienceName,
|
|
@@ -167,46 +155,58 @@ const destination = {
|
|
|
167
155
|
},
|
|
168
156
|
metadata: {
|
|
169
157
|
externalAudienceId: external_audience_id
|
|
170
|
-
}
|
|
171
|
-
countryCode: country_code
|
|
158
|
+
}
|
|
172
159
|
};
|
|
160
|
+
if (country_code) {
|
|
161
|
+
payload.countryCode = country_code;
|
|
162
|
+
}
|
|
173
163
|
if (ttl) {
|
|
174
|
-
|
|
175
|
-
if (!timeToLive) {
|
|
176
|
-
throw new actions_core_1.IntegrationError('TTL:-String can not be converted to Number', 'INVALID_TTL_VALUE', 400);
|
|
177
|
-
}
|
|
178
|
-
payload.metadata.ttl = timeToLive;
|
|
164
|
+
payload.metadata.ttl = ttl;
|
|
179
165
|
}
|
|
180
166
|
if (cpm_cents && currency) {
|
|
181
|
-
if (!utils_1.CURRENCY.includes(currency)) {
|
|
182
|
-
throw new actions_core_1.IntegrationError('Invalid Currency Value', 'INVALID_CURRENCY_VALUE', 400);
|
|
183
|
-
}
|
|
184
|
-
const cpmCents = Number(cpm_cents);
|
|
185
|
-
if (!cpmCents) {
|
|
186
|
-
throw new actions_core_1.IntegrationError('CPM_CENTS:-String can not be converted to Number', 'INVALID_CPMCENTS_VALUE', 400);
|
|
187
|
-
}
|
|
188
167
|
payload.metadata.audienceFees = [];
|
|
189
168
|
payload.metadata?.audienceFees.push({
|
|
190
169
|
currency,
|
|
191
|
-
cpmCents:
|
|
170
|
+
cpmCents: cpm_cents
|
|
192
171
|
});
|
|
193
172
|
}
|
|
173
|
+
const statsName = 'createAudience';
|
|
194
174
|
statsTags?.push(`slug:${destination.slug}`);
|
|
195
175
|
statsClient?.incr(`${statsName}.call`, 1, statsTags);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
176
|
+
try {
|
|
177
|
+
let payloadString = JSON.stringify(payload);
|
|
178
|
+
const regex = /"advertiserId":"(\d+)"/;
|
|
179
|
+
payloadString = payloadString.replace(regex, '"advertiserId":$1');
|
|
180
|
+
const response = await request(`${endpoint}/amc/audiences/metadata`, {
|
|
181
|
+
method: 'POST',
|
|
182
|
+
body: payloadString,
|
|
183
|
+
headers: {
|
|
184
|
+
'Content-Type': 'application/vnd.amcaudiences.v1+json'
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const r = await response.json();
|
|
188
|
+
const externalId = r?.audienceId;
|
|
189
|
+
if (!externalId) {
|
|
190
|
+
statsClient?.incr(`${statsName}.error`, 1, statsTags);
|
|
191
|
+
throw new actions_core_1.IntegrationError('Invalid response from create audience request', 'INVALID_RESPONSE', 400);
|
|
203
192
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
193
|
+
statsClient?.incr(`${statsName}.success`, 1, statsTags);
|
|
194
|
+
return {
|
|
195
|
+
externalId
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
if (e instanceof utils_1.AmazonAdsError) {
|
|
200
|
+
const message = JSON.parse(e.response?.data?.message || '');
|
|
201
|
+
throw new actions_core_1.APIError(message, e.response?.status);
|
|
202
|
+
}
|
|
203
|
+
else if (e instanceof actions_core_1.IntegrationError) {
|
|
204
|
+
throw new actions_core_1.APIError(e.message, 400);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
throw e;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
210
|
},
|
|
211
211
|
async getAudience(request, getAudienceInput) {
|
|
212
212
|
const { statsContext } = getAudienceInput;
|
|
@@ -217,16 +217,35 @@ const destination = {
|
|
|
217
217
|
statsTags?.push(`slug:${destination.slug}`);
|
|
218
218
|
statsClient?.incr(`${statsName}.call`, 1, statsTags);
|
|
219
219
|
if (!audience_id) {
|
|
220
|
-
throw new actions_core_1.IntegrationError('Missing
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
externalId
|
|
229
|
-
|
|
220
|
+
throw new actions_core_1.IntegrationError('Missing audience_id value', 'MISSING_REQUIRED_FIELD', 400);
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const response = await request(`${endpoint}/amc/audiences/metadata/${audience_id}`, {
|
|
224
|
+
method: 'GET'
|
|
225
|
+
});
|
|
226
|
+
const r = await response.json();
|
|
227
|
+
const externalId = r?.audienceId;
|
|
228
|
+
if (externalId != getAudienceInput.externalId) {
|
|
229
|
+
statsClient?.incr(`${statsName}.error`, 1, statsTags);
|
|
230
|
+
throw new actions_core_1.IntegrationError("Unable to verify ownership over audience. Segment Audience ID doesn't match Amazon Ads ID.", 'INVALID_REQUEST_DATA', 400);
|
|
231
|
+
}
|
|
232
|
+
statsClient?.incr(`${statsName}.success`, 1, statsTags);
|
|
233
|
+
return {
|
|
234
|
+
externalId
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
if (e instanceof utils_1.AmazonAdsError) {
|
|
239
|
+
const message = JSON.parse(e.response?.data?.message || '');
|
|
240
|
+
throw new actions_core_1.APIError(message, e.response?.status);
|
|
241
|
+
}
|
|
242
|
+
else if (e instanceof actions_core_1.IntegrationError) {
|
|
243
|
+
throw new actions_core_1.APIError(e.message, 400);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
throw e;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
230
249
|
}
|
|
231
250
|
},
|
|
232
251
|
actions: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/amazon-ads/index.ts"],"names":[],"mappings":";;;;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/amazon-ads/index.ts"],"names":[],"mappings":";;;;;AACA,wDAA0G;AAG1G,mCAAyD;AAEzD,oEAA2C;AAE3C,MAAM,WAAW,GAA8D;IAC7E,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,KAAK,EAAE,QAAQ;gBACf,WAAW,EAAE,6CAA6C;gBAC1D,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,oCAAoC,EAAE;oBAC5E,EAAE,KAAK,EAAE,aAAa,EAAE,KA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CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,CAAA;oBAC3D,MAAM,IAAI,uBAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;iBAChD;qBAAM,IAAI,CAAC,YAAY,+BAAgB,EAAE;oBACxC,MAAM,IAAI,uBAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;iBACnC;qBAAM;oBACL,MAAM,CAAC,CAAA;iBACR;aACF;QACH,CAAC;KACF;IACD,OAAO,EAAE;QACP,aAAa,EAAb,uBAAa;KACd;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
export interface Payload {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
records: {
|
|
3
|
+
externalUserId: string;
|
|
4
|
+
action: string;
|
|
5
|
+
countryCode?: string;
|
|
6
|
+
measurements?: {
|
|
7
|
+
[k: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
hashedPII: {
|
|
10
|
+
firstname?: string;
|
|
11
|
+
address?: string;
|
|
12
|
+
phone?: string;
|
|
13
|
+
city?: string;
|
|
14
|
+
state?: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
lastname?: string;
|
|
17
|
+
postal?: string;
|
|
18
|
+
}[];
|
|
19
|
+
}[];
|
|
20
|
+
audienceId: number;
|
|
15
21
|
}
|