@segment/action-destinations 3.267.1-staging.1 → 3.268.0-staging-4cdde7a9f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/amazon-ads/generated-types.d.ts +9 -0
- package/dist/destinations/amazon-ads/index.d.ts +2 -2
- package/dist/destinations/amazon-ads/index.js +172 -6
- package/dist/destinations/amazon-ads/index.js.map +1 -1
- package/dist/destinations/amazon-ads/syncAudiences/generated-types.d.ts +13 -0
- package/dist/destinations/amazon-ads/syncAudiences/index.js +201 -7
- package/dist/destinations/amazon-ads/syncAudiences/index.js.map +1 -1
- package/dist/destinations/amazon-ads/types.d.ts +25 -0
- package/dist/destinations/amazon-ads/utils.d.ts +31 -0
- package/dist/destinations/amazon-ads/utils.js +18 -0
- package/dist/destinations/amazon-ads/utils.js.map +1 -0
- package/dist/destinations/amplitude/user-agent.d.ts +1 -0
- package/dist/destinations/amplitude/user-agent.js +2 -1
- package/dist/destinations/amplitude/user-agent.js.map +1 -1
- package/dist/destinations/contentstack/constants.d.ts +3 -0
- package/dist/destinations/contentstack/constants.js +7 -0
- package/dist/destinations/contentstack/constants.js.map +1 -0
- package/dist/destinations/contentstack/customAttributesSync/generated-types.d.ts +6 -0
- package/dist/destinations/contentstack/customAttributesSync/generated-types.js +3 -0
- package/dist/destinations/contentstack/customAttributesSync/generated-types.js.map +1 -0
- package/dist/destinations/contentstack/customAttributesSync/index.d.ts +5 -0
- package/dist/destinations/contentstack/customAttributesSync/index.js +45 -0
- package/dist/destinations/contentstack/customAttributesSync/index.js.map +1 -0
- package/dist/destinations/contentstack/customAttributesSync/types.d.ts +14 -0
- package/dist/destinations/contentstack/customAttributesSync/types.js +3 -0
- package/dist/destinations/contentstack/customAttributesSync/types.js.map +1 -0
- package/dist/destinations/contentstack/customAttributesSync/utils.d.ts +4 -0
- package/dist/destinations/contentstack/customAttributesSync/utils.js +21 -0
- package/dist/destinations/contentstack/customAttributesSync/utils.js.map +1 -0
- package/dist/destinations/contentstack/generated-types.d.ts +4 -0
- package/dist/destinations/contentstack/generated-types.js +3 -0
- package/dist/destinations/contentstack/generated-types.js.map +1 -0
- package/dist/destinations/contentstack/index.d.ts +4 -0
- package/dist/destinations/contentstack/index.js +58 -0
- package/dist/destinations/contentstack/index.js.map +1 -0
- package/dist/destinations/contentstack/types.d.ts +12 -0
- package/dist/destinations/contentstack/types.js +3 -0
- package/dist/destinations/contentstack/types.js.map +1 -0
- package/dist/destinations/engage/utils/track.d.ts +17 -17
- package/dist/destinations/engage-messaging-sendgrid/index.d.ts +4 -3
- package/dist/destinations/engage-messaging-sendgrid/index.js +68 -16
- package/dist/destinations/engage-messaging-sendgrid/index.js.map +1 -1
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.d.ts +22 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js +189 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.d.ts +16 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js +29 -0
- package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.d.ts +43 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js +419 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.d.ts +12 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.js +3 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +56 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +258 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.d.ts +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.js +23 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.js.map +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.d.ts +1 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.js +14 -0
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/index.d.ts +4 -3
- package/dist/destinations/engage-messaging-twilio/index.js +169 -15
- package/dist/destinations/engage-messaging-twilio/index.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.d.ts +29 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.js +169 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.d.ts +39 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js +251 -0
- package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.d.ts +9 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.js +72 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.d.ts +27 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js +163 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.d.ts +9 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.js +89 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.d.ts +25 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js +3 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.d.ts +5 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +137 -0
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.d.ts +16 -0
- package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.js +71 -0
- package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.d.ts +16 -0
- package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.js +115 -0
- package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.d.ts +2 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.js +15 -0
- package/dist/destinations/engage-messaging-twilio/utils/index.js.map +1 -0
- package/dist/destinations/engage-messaging-twilio/utils/types.d.ts +23 -0
- package/dist/destinations/engage-messaging-twilio/utils/types.js +3 -0
- package/dist/destinations/engage-messaging-twilio/utils/types.js.map +1 -0
- package/dist/destinations/facebook-conversions-api/fb-capi-properties.js +3 -1
- package/dist/destinations/facebook-conversions-api/fb-capi-properties.js.map +1 -1
- package/dist/destinations/index.js +2 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/insider/index.js +5 -1
- package/dist/destinations/insider/index.js.map +1 -1
- package/dist/destinations/klaviyo/functions.d.ts +18 -1
- package/dist/destinations/klaviyo/functions.js +75 -2
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +4 -0
- package/dist/destinations/klaviyo/types.js.map +1 -1
- package/dist/destinations/klaviyo/upsertProfile/generated-types.d.ts +1 -0
- package/dist/destinations/klaviyo/upsertProfile/index.js +15 -7
- package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
- package/dist/destinations/mixpanel/mixpanel-properties.js +1 -0
- package/dist/destinations/mixpanel/mixpanel-properties.js.map +1 -1
- package/dist/destinations/moloco-rmp/common/convert.js +29 -17
- package/dist/destinations/moloco-rmp/common/convert.js.map +1 -1
- package/dist/destinations/ripe/group/generated-types.d.ts +3 -0
- package/dist/destinations/ripe/group/index.js +9 -1
- package/dist/destinations/ripe/group/index.js.map +1 -1
- package/dist/destinations/ripe/identify/generated-types.d.ts +3 -1
- package/dist/destinations/ripe/identify/index.js +7 -9
- package/dist/destinations/ripe/identify/index.js.map +1 -1
- package/dist/destinations/ripe/page/generated-types.d.ts +3 -1
- package/dist/destinations/ripe/page/index.js +7 -7
- package/dist/destinations/ripe/page/index.js.map +1 -1
- package/dist/destinations/ripe/track/generated-types.d.ts +3 -1
- package/dist/destinations/ripe/track/index.js +8 -10
- package/dist/destinations/ripe/track/index.js.map +1 -1
- package/dist/destinations/salesforce/account/index.js +21 -5
- package/dist/destinations/salesforce/account/index.js.map +1 -1
- package/dist/destinations/salesforce/cases/index.js +21 -5
- package/dist/destinations/salesforce/cases/index.js.map +1 -1
- package/dist/destinations/salesforce/contact/index.js +21 -5
- package/dist/destinations/salesforce/contact/index.js.map +1 -1
- package/dist/destinations/salesforce/customObject/index.js +22 -6
- package/dist/destinations/salesforce/customObject/index.js.map +1 -1
- package/dist/destinations/salesforce/generated-types.d.ts +3 -0
- package/dist/destinations/salesforce/index.d.ts +1 -1
- package/dist/destinations/salesforce/index.js +20 -0
- package/dist/destinations/salesforce/index.js.map +1 -1
- package/dist/destinations/salesforce/lead/index.js +21 -5
- package/dist/destinations/salesforce/lead/index.js.map +1 -1
- package/dist/destinations/salesforce/opportunity/index.js +21 -5
- package/dist/destinations/salesforce/opportunity/index.js.map +1 -1
- package/dist/destinations/salesforce/sf-operations.d.ts +4 -1
- package/dist/destinations/salesforce/sf-operations.js +47 -1
- package/dist/destinations/salesforce/sf-operations.js.map +1 -1
- package/dist/destinations/the-trade-desk-crm/index.js +6 -1
- package/dist/destinations/the-trade-desk-crm/index.js.map +1 -1
- package/dist/destinations/trubrics/generated-types.d.ts +4 -0
- package/dist/destinations/trubrics/generated-types.js +3 -0
- package/dist/destinations/trubrics/generated-types.js.map +1 -0
- package/dist/destinations/trubrics/index.d.ts +4 -0
- package/dist/destinations/trubrics/index.js +34 -0
- package/dist/destinations/trubrics/index.js.map +1 -0
- package/dist/destinations/trubrics/track/generated-types.d.ts +15 -0
- package/dist/destinations/trubrics/track/generated-types.js +3 -0
- package/dist/destinations/trubrics/track/generated-types.js.map +1 -0
- package/dist/destinations/trubrics/track/index.d.ts +5 -0
- package/dist/destinations/trubrics/track/index.js +83 -0
- package/dist/destinations/trubrics/track/index.js.map +1 -0
- package/dist/destinations/usermotion/group/generated-types.d.ts +2 -1
- package/dist/destinations/usermotion/group/index.js +17 -14
- package/dist/destinations/usermotion/group/index.js.map +1 -1
- package/dist/destinations/usermotion/identify/index.js +2 -2
- package/dist/destinations/usermotion/identify/index.js.map +1 -1
- package/dist/destinations/usermotion/index.js +5 -1
- package/dist/destinations/usermotion/index.js.map +1 -1
- package/dist/destinations/usermotion/track/generated-types.d.ts +4 -2
- package/dist/destinations/usermotion/track/index.js +12 -16
- package/dist/destinations/usermotion/track/index.js.map +1 -1
- package/dist/destinations/xtremepush/identify/index.js +2 -2
- package/dist/destinations/xtremepush/identify/index.js.map +1 -1
- package/dist/destinations/xtremepush/index.js.map +1 -1
- package/dist/destinations/xtremepush/track/index.js +2 -2
- package/dist/destinations/xtremepush/track/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AudienceDestinationDefinition } from '@segment/actions-core';
|
|
2
|
-
import type { Settings } from './generated-types';
|
|
3
|
-
declare const destination: AudienceDestinationDefinition<Settings>;
|
|
2
|
+
import type { Settings, AudienceSettings } from './generated-types';
|
|
3
|
+
declare const destination: AudienceDestinationDefinition<Settings, AudienceSettings>;
|
|
4
4
|
export default destination;
|
|
@@ -4,6 +4,7 @@ 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 utils_1 = require("./utils");
|
|
7
8
|
const syncAudiences_1 = __importDefault(require("./syncAudiences"));
|
|
8
9
|
const destination = {
|
|
9
10
|
name: 'Amazon Ads',
|
|
@@ -20,17 +21,17 @@ const destination = {
|
|
|
20
21
|
{ label: 'Europe (EU)', value: 'https://advertising-api-eu.amazon.com' },
|
|
21
22
|
{ label: 'Far East (FE)', value: 'https://advertising-api-fe.amazon.com' }
|
|
22
23
|
],
|
|
23
|
-
default: '
|
|
24
|
+
default: 'https://advertising-api.amazon.com',
|
|
24
25
|
type: 'string',
|
|
25
26
|
required: true
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
|
-
testAuthentication: async (request, { auth }) => {
|
|
29
|
+
testAuthentication: async (request, { auth, settings }) => {
|
|
29
30
|
if (!auth?.accessToken) {
|
|
30
31
|
throw new actions_core_1.InvalidAuthenticationError('Please authenticate via Oauth before enabling the destination.');
|
|
31
32
|
}
|
|
32
33
|
try {
|
|
33
|
-
await request(
|
|
34
|
+
await request(`${settings.region}/v2/profiles`, {
|
|
34
35
|
method: 'GET'
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -42,11 +43,16 @@ const destination = {
|
|
|
42
43
|
throw e;
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
|
-
refreshAccessToken: async (request, { auth }) => {
|
|
46
|
+
refreshAccessToken: async (request, { auth, settings }) => {
|
|
47
|
+
const endpoint = utils_1.AUTHORIZATION_URL[`${settings.region}`];
|
|
46
48
|
let res;
|
|
49
|
+
console.log(settings.region, auth, endpoint);
|
|
47
50
|
try {
|
|
48
51
|
res = await request('https://api.amazon.com/auth/o2/token', {
|
|
49
52
|
method: 'POST',
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
|
55
|
+
},
|
|
50
56
|
body: new URLSearchParams({
|
|
51
57
|
refresh_token: auth.refreshToken,
|
|
52
58
|
client_id: auth.clientId,
|
|
@@ -56,6 +62,7 @@ const destination = {
|
|
|
56
62
|
});
|
|
57
63
|
}
|
|
58
64
|
catch (e) {
|
|
65
|
+
console.log(e);
|
|
59
66
|
const error = e;
|
|
60
67
|
if (error.response?.data?.error === 'invalid_grant') {
|
|
61
68
|
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);
|
|
@@ -68,15 +75,174 @@ const destination = {
|
|
|
68
75
|
extendRequest({ auth }) {
|
|
69
76
|
return {
|
|
70
77
|
headers: {
|
|
71
|
-
authorization: `Bearer ${auth?.accessToken}
|
|
78
|
+
authorization: `Bearer ${auth?.accessToken}`,
|
|
79
|
+
'Amazon-Advertising-API-ClientID': process.env.ACTIONS_AMAZON_ADS_CLIENT_ID || ''
|
|
72
80
|
}
|
|
73
81
|
};
|
|
74
82
|
},
|
|
75
|
-
audienceFields: {
|
|
83
|
+
audienceFields: {
|
|
84
|
+
description: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
label: 'Description',
|
|
87
|
+
required: true,
|
|
88
|
+
description: 'The audience description. Must be an alphanumeric, non-null string between 0 to 1000 characters in length.'
|
|
89
|
+
},
|
|
90
|
+
countryCode: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
label: 'Country Code',
|
|
93
|
+
required: true,
|
|
94
|
+
description: 'A String value representing ISO 3166-1 alpha-2 country code for the members in this audience.'
|
|
95
|
+
},
|
|
96
|
+
externalAudienceId: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
label: 'External Audience Id',
|
|
99
|
+
required: true,
|
|
100
|
+
description: 'The user-defined audience identifier.'
|
|
101
|
+
},
|
|
102
|
+
cpmCents: {
|
|
103
|
+
label: 'CPM Cents',
|
|
104
|
+
type: 'string',
|
|
105
|
+
description: `Cost per thousand impressions (CPM) in cents. For example, $1.00 = 100 cents.`
|
|
106
|
+
},
|
|
107
|
+
currency: {
|
|
108
|
+
label: 'Currency',
|
|
109
|
+
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).Refer [Aamzon Ads Documentation](https://advertising.amazon.com/API/docs/en-us/amc-advertiser-audience#tag/Audience-Metadata/operation/CreateAudienceMetadataV2) to view supported Currency`
|
|
111
|
+
},
|
|
112
|
+
ttl: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
label: 'Time-to-live',
|
|
115
|
+
required: false,
|
|
116
|
+
description: 'Time-to-live in seconds. The amount of time the record is associated with the audience.'
|
|
117
|
+
},
|
|
118
|
+
advertiserId: {
|
|
119
|
+
label: 'Advertiser ID',
|
|
120
|
+
description: 'Advertiser Id',
|
|
121
|
+
type: 'string',
|
|
122
|
+
required: true
|
|
123
|
+
}
|
|
124
|
+
},
|
|
76
125
|
audienceConfig: {
|
|
77
126
|
mode: {
|
|
78
127
|
type: 'synced',
|
|
79
128
|
full_audience_sync: false
|
|
129
|
+
},
|
|
130
|
+
async createAudience(request, createAudienceInput) {
|
|
131
|
+
const { audienceName, statsContext, audienceSettings } = createAudienceInput;
|
|
132
|
+
const { statsClient, tags: statsTags } = statsContext || {};
|
|
133
|
+
const statsName = 'createAmazonAudience';
|
|
134
|
+
statsTags?.push(`slug:${destination.slug}`);
|
|
135
|
+
statsClient?.incr(`${statsName}.intialise`, 1, statsTags);
|
|
136
|
+
const endpoint = createAudienceInput.settings.region;
|
|
137
|
+
const description = audienceSettings?.description;
|
|
138
|
+
const advertiser_id = audienceSettings?.advertiserId;
|
|
139
|
+
const external_audience_id = audienceSettings?.externalAudienceId;
|
|
140
|
+
const country_code = audienceSettings?.countryCode;
|
|
141
|
+
const ttl = audienceSettings?.ttl;
|
|
142
|
+
const currency = audienceSettings?.currency;
|
|
143
|
+
const cpm_cents = audienceSettings?.cpmCents;
|
|
144
|
+
if (!advertiser_id) {
|
|
145
|
+
throw new actions_core_1.IntegrationError('Missing advertiserId Value', 'MISSING_REQUIRED_FIELD', 400);
|
|
146
|
+
}
|
|
147
|
+
if (!description) {
|
|
148
|
+
throw new actions_core_1.IntegrationError('Missing description Value', 'MISSING_REQUIRED_FIELD', 400);
|
|
149
|
+
}
|
|
150
|
+
if (!external_audience_id) {
|
|
151
|
+
throw new actions_core_1.IntegrationError('Missing externalAudienceId Value', 'MISSING_REQUIRED_FIELD', 400);
|
|
152
|
+
}
|
|
153
|
+
if (!audienceName) {
|
|
154
|
+
throw new actions_core_1.IntegrationError('Missing audienceName Value', 'MISSING_REQUIRED_FIELD', 400);
|
|
155
|
+
}
|
|
156
|
+
if (!country_code) {
|
|
157
|
+
throw new actions_core_1.IntegrationError('Missing countryCode Value', 'MISSING_REQUIRED_FIELD', 400);
|
|
158
|
+
}
|
|
159
|
+
const payload = {
|
|
160
|
+
name: audienceName,
|
|
161
|
+
description: description,
|
|
162
|
+
targetResource: {
|
|
163
|
+
advertiserId: advertiser_id
|
|
164
|
+
},
|
|
165
|
+
metadata: {
|
|
166
|
+
externalAudienceId: external_audience_id
|
|
167
|
+
},
|
|
168
|
+
countryCode: country_code
|
|
169
|
+
};
|
|
170
|
+
if (ttl) {
|
|
171
|
+
const timeToLive = Number(ttl);
|
|
172
|
+
if (!timeToLive) {
|
|
173
|
+
throw new actions_core_1.IntegrationError('TTL:-String can not be converted to Number', 'INVALID_TTL_VALUE', 400);
|
|
174
|
+
}
|
|
175
|
+
payload.metadata.ttl = timeToLive;
|
|
176
|
+
}
|
|
177
|
+
if (cpm_cents && currency) {
|
|
178
|
+
if (!utils_1.CURRENCY.includes(currency)) {
|
|
179
|
+
throw new actions_core_1.IntegrationError('Invalid Currency Value', 'INVALID_CURRENCY_VALUE', 400);
|
|
180
|
+
}
|
|
181
|
+
const cpmCents = Number(cpm_cents);
|
|
182
|
+
if (!cpmCents) {
|
|
183
|
+
throw new actions_core_1.IntegrationError('CPM_CENTS:-String can not be converted to Number', 'INVALID_CPMCENTS_VALUE', 400);
|
|
184
|
+
}
|
|
185
|
+
payload.metadata.audienceFees = [];
|
|
186
|
+
payload.metadata?.audienceFees.push({
|
|
187
|
+
currency,
|
|
188
|
+
cpmCents: cpmCents
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
statsTags?.push(`slug:${destination.slug}`);
|
|
192
|
+
statsClient?.incr(`${statsName}.call`, 1, statsTags);
|
|
193
|
+
try {
|
|
194
|
+
let payloadString = JSON.stringify(payload);
|
|
195
|
+
const regex = /"advertiserId":"(\d+)"/;
|
|
196
|
+
payloadString = payloadString.replace(regex, '"advertiserId":$1');
|
|
197
|
+
const response = await request(`${endpoint}/amc/audiences/metadata`, {
|
|
198
|
+
method: 'POST',
|
|
199
|
+
body: payloadString,
|
|
200
|
+
headers: {
|
|
201
|
+
'Content-Type': 'application/vnd.amcaudiences.v1+json'
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
const res = await response.text();
|
|
205
|
+
const resString = res.replace(/"audienceId":(\d+)/, '"audienceId":"$1"');
|
|
206
|
+
const externalId = JSON.parse(resString)['audienceId'];
|
|
207
|
+
statsClient?.incr(`${statsName}.success`, 1, statsTags);
|
|
208
|
+
return {
|
|
209
|
+
externalId
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
statsTags?.push(`error:${e}`);
|
|
214
|
+
statsClient?.incr(`${statsName}.error`, 1, statsTags);
|
|
215
|
+
throw e;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
async getAudience(request, getAudienceInput) {
|
|
219
|
+
const { statsContext } = getAudienceInput;
|
|
220
|
+
const audience_id = getAudienceInput.externalId;
|
|
221
|
+
const endpoint = getAudienceInput.settings.region;
|
|
222
|
+
const { statsClient, tags: statsTags } = statsContext || {};
|
|
223
|
+
const statsName = 'getAudience';
|
|
224
|
+
statsTags?.push(`slug:${destination.slug}`);
|
|
225
|
+
statsClient?.incr(`${statsName}.call`, 1, statsTags);
|
|
226
|
+
if (!audience_id) {
|
|
227
|
+
throw new actions_core_1.IntegrationError('Missing audienceId value', 'MISSING_REQUIRED_FIELD', 400);
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const response = await request(`${endpoint}/amc/audiences/metadata/${audience_id}`, {
|
|
231
|
+
method: 'GET'
|
|
232
|
+
});
|
|
233
|
+
const res = await response.text();
|
|
234
|
+
const resString = res.replace(/"audienceId":(\d+)/, '"audienceId":"$1"');
|
|
235
|
+
const externalId = JSON.parse(resString)['audienceId'];
|
|
236
|
+
statsClient?.incr(`${statsName}.success`, 1, statsTags);
|
|
237
|
+
return {
|
|
238
|
+
externalId
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
statsTags?.push(`error:${e}`);
|
|
243
|
+
statsClient?.incr(`${statsName}.error`, 1, statsTags);
|
|
244
|
+
throw e;
|
|
245
|
+
}
|
|
80
246
|
}
|
|
81
247
|
},
|
|
82
248
|
actions: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/amazon-ads/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAgG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/amazon-ads/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAgG;AAGhG,mCAAsE;AAEtE,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,KAAK,EAAE,uCAAuC,EAAE;oBACxE,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,uCAAuC,EAAE;iBAC3E;gBACD,OAAO,EAAE,oCAAoC;gBAC7C,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;YACxD,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;gBACtB,MAAM,IAAI,yCAA0B,CAAC,gEAAgE,CAAC,CAAA;aACv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AAE,IAAI,CAAC,GAAG,SAAS,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,CAAA;gBACrD,MAAM,CAAC,CAAA;aACR;QACH,CAAC;KACF;IACD,OAAO,EAAE;QACP,aAAa,EAAb,uBAAa;KACd;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
export interface Payload {
|
|
2
|
+
event_name?: string;
|
|
3
|
+
externalUserId: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
firstName?: string;
|
|
6
|
+
lastName?: string;
|
|
7
|
+
phone?: string;
|
|
8
|
+
postal?: string;
|
|
9
|
+
state?: string;
|
|
10
|
+
city?: string;
|
|
11
|
+
address?: string;
|
|
12
|
+
audienceId: string;
|
|
13
|
+
enable_batching: boolean;
|
|
14
|
+
batch_size?: number;
|
|
2
15
|
}
|
|
@@ -1,15 +1,209 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
3
6
|
const action = {
|
|
4
|
-
title: 'Sync
|
|
7
|
+
title: 'Sync Audience',
|
|
5
8
|
description: 'Sync audiences from Segment to Amazon Ads Audience.',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
defaultSubscription: 'event = "Audience Entered" or event = "Audience Exited"',
|
|
10
|
+
fields: {
|
|
11
|
+
event_name: {
|
|
12
|
+
label: 'Event Name',
|
|
13
|
+
description: 'The name of the current Segment event.',
|
|
14
|
+
type: 'string',
|
|
15
|
+
unsafe_hidden: true,
|
|
16
|
+
default: {
|
|
17
|
+
'@path': '$.event'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
externalUserId: {
|
|
21
|
+
label: 'External User ID',
|
|
22
|
+
description: 'This is an external user identifier defined by data providers.',
|
|
23
|
+
type: 'string',
|
|
24
|
+
required: true,
|
|
25
|
+
default: { '@path': '$.userId' }
|
|
26
|
+
},
|
|
27
|
+
email: {
|
|
28
|
+
label: 'Email',
|
|
29
|
+
description: 'User email address. Vaule will be hashed before sending to Amazon.',
|
|
30
|
+
type: 'string',
|
|
31
|
+
required: false,
|
|
32
|
+
default: { '@path': '$.properties.email' }
|
|
33
|
+
},
|
|
34
|
+
firstName: {
|
|
35
|
+
label: 'First name',
|
|
36
|
+
description: 'User first name. Vaue will be hashed before sending to Amazon.',
|
|
37
|
+
type: 'string',
|
|
38
|
+
required: false,
|
|
39
|
+
default: { '@path': '$.properties.first_name' }
|
|
40
|
+
},
|
|
41
|
+
lastName: {
|
|
42
|
+
label: 'Last name',
|
|
43
|
+
description: 'User Last name. Vaue will be hashed before sending to Amazon.',
|
|
44
|
+
type: 'string',
|
|
45
|
+
required: false,
|
|
46
|
+
default: { '@path': '$.properties.last_name' }
|
|
47
|
+
},
|
|
48
|
+
phone: {
|
|
49
|
+
label: 'Phone',
|
|
50
|
+
description: 'Phone Number. Vaue will be hashed before sending to Amazon.',
|
|
51
|
+
type: 'string',
|
|
52
|
+
required: false,
|
|
53
|
+
default: { '@path': '$.properties.phone' }
|
|
54
|
+
},
|
|
55
|
+
postal: {
|
|
56
|
+
label: 'Postal',
|
|
57
|
+
description: 'POstal Code. Vaue will be hashed before sending to Amazon.',
|
|
58
|
+
type: 'string',
|
|
59
|
+
required: false,
|
|
60
|
+
default: { '@path': '$.properties.postal' }
|
|
61
|
+
},
|
|
62
|
+
state: {
|
|
63
|
+
label: 'Postal',
|
|
64
|
+
description: 'State Code. Vaue will be hashed before sending to Amazon.',
|
|
65
|
+
type: 'string',
|
|
66
|
+
required: false,
|
|
67
|
+
default: { '@path': '$.properties.state' }
|
|
68
|
+
},
|
|
69
|
+
city: {
|
|
70
|
+
label: 'City',
|
|
71
|
+
description: 'City name. Vaue will be hashed before sending to Amazon.',
|
|
72
|
+
type: 'string',
|
|
73
|
+
required: false,
|
|
74
|
+
default: { '@path': '$.properties.city' }
|
|
75
|
+
},
|
|
76
|
+
address: {
|
|
77
|
+
label: 'Address',
|
|
78
|
+
description: 'Address Code. Value will be hashed before sending to Amazon.',
|
|
79
|
+
type: 'string',
|
|
80
|
+
required: false,
|
|
81
|
+
default: { '@path': '$.properties.address' }
|
|
82
|
+
},
|
|
83
|
+
audienceId: {
|
|
84
|
+
label: 'Audience ID',
|
|
85
|
+
type: 'string',
|
|
86
|
+
required: true,
|
|
87
|
+
unsafe_hidden: true,
|
|
88
|
+
description: 'An number value representing the Amazon audience identifier. This is the identifier that is returned during audience creation.',
|
|
89
|
+
default: {
|
|
90
|
+
'@path': '$.context.personas.external_audience_id'
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
enable_batching: {
|
|
94
|
+
label: 'Enable Batching',
|
|
95
|
+
description: 'When enabled,segment will send data in batching',
|
|
96
|
+
type: 'boolean',
|
|
97
|
+
required: true,
|
|
98
|
+
default: true
|
|
99
|
+
},
|
|
100
|
+
batch_size: {
|
|
101
|
+
label: 'Batch Size',
|
|
102
|
+
description: 'Maximum number of events to include in each batch. Actual batch sizes may be lower.',
|
|
103
|
+
type: 'number',
|
|
104
|
+
unsafe_hidden: true,
|
|
105
|
+
required: false,
|
|
106
|
+
default: 10000
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
perform: (request, { settings, payload, statsContext, audienceSettings }) => {
|
|
110
|
+
return processPayload(request, settings, [payload], statsContext, audienceSettings);
|
|
111
|
+
},
|
|
112
|
+
performBatch: (request, { settings, payload: payloads, statsContext, audienceSettings }) => {
|
|
113
|
+
return processPayload(request, settings, payloads, statsContext, audienceSettings);
|
|
12
114
|
}
|
|
13
115
|
};
|
|
116
|
+
async function processPayload(request, settings, payload, statsContext, audienceSettings) {
|
|
117
|
+
const { statsClient, tags: statsTags } = statsContext || {};
|
|
118
|
+
const statsName = 'syncAmazonAdsAudience';
|
|
119
|
+
statsClient?.incr(`${statsName}.intialise`, 1, statsTags);
|
|
120
|
+
try {
|
|
121
|
+
const payloadRecord = createPayloadToUploadRecords(payload, audienceSettings);
|
|
122
|
+
const payloadString = JSON.stringify(payloadRecord).replace(/"audienceId":"(\d+)"/, '"audienceId":$1');
|
|
123
|
+
const response = await request(`${settings.region}/amc/audiences/records`, {
|
|
124
|
+
method: 'POST',
|
|
125
|
+
body: payloadString,
|
|
126
|
+
headers: {
|
|
127
|
+
'Content-Type': 'application/vnd.amcaudiences.v1+json'
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const result = await response.json();
|
|
131
|
+
const jobRequestId = result?.jobRequestId;
|
|
132
|
+
statsTags?.push(`jobRequestId:${jobRequestId}`);
|
|
133
|
+
statsClient?.incr(`${statsName}.success`, 1, statsTags);
|
|
134
|
+
if (!jobRequestId) {
|
|
135
|
+
throw new actions_core_1.IntegrationError('Invalid response from upload audinece record call', 'INVALID_RESPONSE', 400);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
result
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
if (e instanceof utils_1.AmazonAdsError) {
|
|
143
|
+
const message = JSON.parse(e.response?.data?.message || '');
|
|
144
|
+
statsTags?.push(`error:${message}`);
|
|
145
|
+
statsClient?.incr(`${statsName}.error`, 1, statsTags);
|
|
146
|
+
throw new actions_core_1.APIError(message, e.response?.status);
|
|
147
|
+
}
|
|
148
|
+
else if (e instanceof actions_core_1.IntegrationError) {
|
|
149
|
+
statsTags?.push(`error:${e.message}`);
|
|
150
|
+
statsClient?.incr(`${statsName}.error`, 1, statsTags);
|
|
151
|
+
throw new actions_core_1.APIError(e.message, 400);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
statsTags?.push(`error:${e}`);
|
|
155
|
+
statsClient?.incr(`${statsName}.error`, 1, statsTags);
|
|
156
|
+
throw e;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function createPayloadToUploadRecords(payloads, audienceSettings) {
|
|
161
|
+
const records = [];
|
|
162
|
+
const { audienceId } = payloads[0];
|
|
163
|
+
payloads.forEach((payload) => {
|
|
164
|
+
const hashedPII = {};
|
|
165
|
+
if (payload.firstName) {
|
|
166
|
+
hashedPII.firstname = normalizeAndHash(payload.firstName);
|
|
167
|
+
}
|
|
168
|
+
if (payload.lastName) {
|
|
169
|
+
hashedPII.lastname = normalizeAndHash(payload.lastName);
|
|
170
|
+
}
|
|
171
|
+
if (payload.address) {
|
|
172
|
+
hashedPII.address = normalizeAndHash(payload.address);
|
|
173
|
+
}
|
|
174
|
+
if (payload.postal) {
|
|
175
|
+
hashedPII.postal = normalizeAndHash(payload.postal);
|
|
176
|
+
}
|
|
177
|
+
if (payload.phone) {
|
|
178
|
+
hashedPII.phone = normalizeAndHash(payload.phone);
|
|
179
|
+
}
|
|
180
|
+
if (payload.city) {
|
|
181
|
+
hashedPII.city = normalizeAndHash(payload.city);
|
|
182
|
+
}
|
|
183
|
+
if (payload.state) {
|
|
184
|
+
hashedPII.state = normalizeAndHash(payload.state);
|
|
185
|
+
}
|
|
186
|
+
if (payload.email) {
|
|
187
|
+
hashedPII.email = normalizeAndHash(payload.email);
|
|
188
|
+
}
|
|
189
|
+
const payloadRecord = {
|
|
190
|
+
externalUserId: payload.externalUserId,
|
|
191
|
+
countryCode: audienceSettings.countryCode,
|
|
192
|
+
action: payload.event_name == 'Audience Entered' ? utils_1.CONSTANTS.CREATE : utils_1.CONSTANTS.DELETE,
|
|
193
|
+
hashedPII: [hashedPII]
|
|
194
|
+
};
|
|
195
|
+
records.push(payloadRecord);
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
records: records,
|
|
199
|
+
audienceId: audienceId
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function normalizeAndHash(data) {
|
|
203
|
+
const normalizedData = data.toLowerCase().trim();
|
|
204
|
+
const hash = crypto_1.createHash('sha256');
|
|
205
|
+
hash.update(normalizedData);
|
|
206
|
+
return hash.digest('hex');
|
|
207
|
+
}
|
|
14
208
|
exports.default = action;
|
|
15
209
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/amazon-ads/syncAudiences/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/amazon-ads/syncAudiences/index.ts"],"names":[],"mappings":";;AACA,wDAAkE;AAGlE,oCAAoD;AACpD,mCAAmC;AAGnC,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,qDAAqD;IAClE,mBAAmB,EAAE,yDAAyD;IAC9E,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,wCAAwC;YACrD,IAAI,EAAE,QAAQ;YACd,aAAa,EAAE,IAAI;YACnB,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;SACF;QACD,cAAc,EAAE;YACd,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,gEAAgE;YAC7E,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;SACjC;QACD,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,oEAAoE;YACjF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;SAC3C;QACD,SAAS,EAAE;YACT,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,gEAAgE;YAC7E,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE;SAChD;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,WAAW;YAClB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AAK,EAAE;YACjB,SAAS,CAAC,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SAClD;QACD,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,SAAS,CAAC,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SAClD;QAED,MAAM,aAAa,GAAmB;YACpC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,WAAW,EAAE,gBAAgB,CAAC,WAAW;YACzC,MAAM,EAAE,OAAO,CAAC,UAAU,IAAI,kBAAkB,CAAC,CAAC,CAAC,iBAAS,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAS,CAAC,MAAM;YACtF,SAAS,EAAE,CAAC,SAAS,CAAC;SACvB,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,UAAU;KACvB,CAAA;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IAEpC,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAA;IAEhD,MAAM,IAAI,GAAG,mBAAU,CAAC,QAAQ,CAAC,CAAA;IACjC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;IAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -20,3 +20,28 @@ export declare class AmazonRefreshTokenError extends HTTPError {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
export interface HashedPIIObject {
|
|
24
|
+
firstname?: string;
|
|
25
|
+
lastname?: string;
|
|
26
|
+
phone?: string;
|
|
27
|
+
city?: string;
|
|
28
|
+
state?: string;
|
|
29
|
+
postal?: string;
|
|
30
|
+
email?: string;
|
|
31
|
+
address?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AudienceRecord {
|
|
34
|
+
hashedPII?: HashedPIIObject[];
|
|
35
|
+
externalUserId: string;
|
|
36
|
+
countryCode: string;
|
|
37
|
+
action: string;
|
|
38
|
+
}
|
|
39
|
+
export interface TargetResourceRecords {
|
|
40
|
+
connectionId: string;
|
|
41
|
+
targetTypes: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface AudienceRecordPayload {
|
|
44
|
+
records: AudienceRecord[];
|
|
45
|
+
targetResource: TargetResourceRecords;
|
|
46
|
+
audienceId: number;
|
|
47
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HTTPError } from '@segment/actions-core';
|
|
2
|
+
export declare class AmazonAdsError extends HTTPError {
|
|
3
|
+
response: Response & {
|
|
4
|
+
data: {
|
|
5
|
+
status: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface AudiencePayload {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
countryCode: string;
|
|
14
|
+
targetResource: {
|
|
15
|
+
advertiserId: string;
|
|
16
|
+
};
|
|
17
|
+
metadata: {
|
|
18
|
+
externalAudienceId: string;
|
|
19
|
+
ttl?: number;
|
|
20
|
+
audienceFees?: {
|
|
21
|
+
cpmCents: number;
|
|
22
|
+
currency: string;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare const AUTHORIZATION_URL: any;
|
|
27
|
+
export declare const CONSTANTS: {
|
|
28
|
+
CREATE: string;
|
|
29
|
+
DELETE: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const CURRENCY: string[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CURRENCY = exports.CONSTANTS = exports.AUTHORIZATION_URL = exports.AmazonAdsError = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
class AmazonAdsError extends actions_core_1.HTTPError {
|
|
6
|
+
}
|
|
7
|
+
exports.AmazonAdsError = AmazonAdsError;
|
|
8
|
+
exports.AUTHORIZATION_URL = {
|
|
9
|
+
'https://advertising-api.amazon.com': 'https://api.amazon.com/auth/o2/token',
|
|
10
|
+
'https://advertising-api-eu.amazon.com': 'https://api.amazon.co.uk/auth/o2/token',
|
|
11
|
+
'https://advertising-api-fe.amazon.com': 'https://api.amazon.co.jp/auth/o2/token'
|
|
12
|
+
};
|
|
13
|
+
exports.CONSTANTS = {
|
|
14
|
+
CREATE: 'CREATE',
|
|
15
|
+
DELETE: 'DELETE'
|
|
16
|
+
};
|
|
17
|
+
exports.CURRENCY = ['USD', 'CAD', 'JPY', 'GBP', 'EUR', 'SAR', 'AUD', 'AED', 'CNY', 'MXN', 'INR', 'SEK', 'TRY'];
|
|
18
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/destinations/amazon-ads/utils.ts"],"names":[],"mappings":";;;AAAA,wDAAiD;AAEjD,MAAa,cAAe,SAAQ,wBAAS;CAO5C;AAPD,wCAOC;AAmBY,QAAA,iBAAiB,GAAQ;IACpC,oCAAoC,EAAE,sCAAsC;IAC5E,uCAAuC,EAAE,wCAAwC;IACjF,uCAAuC,EAAE,wCAAwC;CAClF,CAAA;AACY,QAAA,SAAS,GAAG;IACvB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACjB,CAAA;AACY,QAAA,QAAQ,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA"}
|
|
@@ -16,7 +16,8 @@ function parseUserAgentProperties(userAgent, userAgentData) {
|
|
|
16
16
|
return {
|
|
17
17
|
os_name: os.name ?? browser.name,
|
|
18
18
|
os_version: userAgentData?.platformVersion ?? browser.major,
|
|
19
|
-
|
|
19
|
+
device_manufacturer: device.vendor,
|
|
20
|
+
device_model: userAgentData?.model ?? device.model ?? os.name,
|
|
20
21
|
device_type: device.type
|
|
21
22
|
};
|
|
22
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../../../src/destinations/amplitude/user-agent.ts"],"names":[],"mappings":";;;;;;AAAA,2EAA8C;
|
|
1
|
+
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../../../src/destinations/amplitude/user-agent.ts"],"names":[],"mappings":";;;;;;AAAA,2EAA8C;AAe9C,SAAgB,wBAAwB,CAAC,SAAkB,EAAE,aAA6B;IACxF,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,EAAE,CAAA;KACV;IAGD,MAAM,MAAM,GAAG,IAAI,sBAAQ,CAAC,SAAS,CAAC,CAAA;IAEtC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;IAEjC,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,CAAA;IAEzB,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;IAEnC,OAAO;QACL,OAAO,EAAE,EAAE,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI;QAChC,UAAU,EAAE,aAAa,EAAE,eAAe,IAAI,OAAO,CAAC,KAAK;QAC3D,mBAAmB,EAAE,MAAM,CAAC,MAAM;QAClC,YAAY,EAAE,aAAa,EAAE,KAAK,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI;QAC7D,WAAW,EAAE,MAAM,CAAC,IAAI;KACzB,CAAA;AACH,CAAC;AArBD,4DAqBC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const PERSONALIZE_API_BASE_URL = "https://personalization-api.contentstack.com";
|
|
2
|
+
export declare const PERSONALIZE_EDGE_API_URL = "https://personalization-edge.contentstack.com";
|
|
3
|
+
export declare const ACCESS_TOKEN_URL = "https://developerhub-api.contentstack.com/apps/token";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ACCESS_TOKEN_URL = exports.PERSONALIZE_EDGE_API_URL = exports.PERSONALIZE_API_BASE_URL = void 0;
|
|
4
|
+
exports.PERSONALIZE_API_BASE_URL = 'https://personalization-api.contentstack.com';
|
|
5
|
+
exports.PERSONALIZE_EDGE_API_URL = 'https://personalization-edge.contentstack.com';
|
|
6
|
+
exports.ACCESS_TOKEN_URL = 'https://developerhub-api.contentstack.com/apps/token';
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/contentstack/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,8CAA8C,CAAA;AACzE,QAAA,wBAAwB,GAAG,+CAA+C,CAAA;AAC1E,QAAA,gBAAgB,GAAG,sDAAsD,CAAA"}
|