@segment/action-destinations 3.494.1-staging-82c2f6b1a.0 → 3.494.1-staging-d127e1ea9.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/first-party-dv360/_tests_/index.test.d.ts +0 -1
- package/dist/destinations/first-party-dv360/_tests_/index.test.js +0 -235
- package/dist/destinations/first-party-dv360/_tests_/index.test.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/functions.d.ts +6 -14
- package/dist/destinations/google-enhanced-conversions/functions.js +117 -245
- package/dist/destinations/google-enhanced-conversions/functions.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/index.js +20 -15
- package/dist/destinations/google-enhanced-conversions/index.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/types.d.ts +0 -47
- package/dist/destinations/google-enhanced-conversions/userList/index.js +23 -19
- package/dist/destinations/google-enhanced-conversions/userList/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,237 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const nock_1 = __importDefault(require("nock"));
|
|
7
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
8
|
-
const index_1 = __importDefault(require("../index"));
|
|
9
|
-
const audienceName = 'Test Audience';
|
|
10
|
-
const testDestination = (0, actions_core_1.createTestIntegration)(index_1.default);
|
|
11
|
-
const createAudienceInput = {
|
|
12
|
-
settings: {
|
|
13
|
-
oauth: {
|
|
14
|
-
refresh_token: 'mock-refresh-token'
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
audienceName: audienceName,
|
|
18
|
-
audienceSettings: {
|
|
19
|
-
advertiserId: '12345',
|
|
20
|
-
audienceType: 'CUSTOMER_MATCH_CONTACT_INFO',
|
|
21
|
-
membershipDurationDays: '30',
|
|
22
|
-
description: 'Test description'
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const getAudienceInput = {
|
|
26
|
-
settings: {
|
|
27
|
-
oauth: {
|
|
28
|
-
refresh_token: 'mock-refresh-token'
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
audienceSettings: {
|
|
32
|
-
advertiserId: '12345'
|
|
33
|
-
},
|
|
34
|
-
externalId: 'audience-id-123'
|
|
35
|
-
};
|
|
36
|
-
beforeAll(() => {
|
|
37
|
-
process.env.ACTIONS_FIRST_PARTY_DV360_CLIENT_ID = 'mock-client-id';
|
|
38
|
-
process.env.ACTIONS_FIRST_PARTY_DV360_CLIENT_SECRET = 'mock-client-secret';
|
|
39
|
-
});
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
(0, nock_1.default)('https://www.googleapis.com')
|
|
42
|
-
.post('/oauth2/v4/token', {
|
|
43
|
-
refresh_token: 'mock-refresh-token',
|
|
44
|
-
client_id: 'mock-client-id',
|
|
45
|
-
client_secret: 'mock-client-secret',
|
|
46
|
-
grant_type: 'refresh_token'
|
|
47
|
-
})
|
|
48
|
-
.reply(200, { access_token: 'temp-token' });
|
|
49
|
-
});
|
|
50
|
-
describe('Audience Destination', () => {
|
|
51
|
-
describe('createAudience', () => {
|
|
52
|
-
it('creates an audience successfully with CANARY VERSION', async () => {
|
|
53
|
-
(0, nock_1.default)('https://displayvideo.googleapis.com')
|
|
54
|
-
.post('/v4/firstPartyAndPartnerAudiences?advertiserId=12345', {
|
|
55
|
-
displayName: audienceName,
|
|
56
|
-
audienceType: 'CUSTOMER_MATCH_CONTACT_INFO',
|
|
57
|
-
membershipDurationDays: '30',
|
|
58
|
-
description: 'Test description',
|
|
59
|
-
audienceSource: 'AUDIENCE_SOURCE_UNSPECIFIED',
|
|
60
|
-
firstPartyAndPartnerAudienceType: 'TYPE_FIRST_PARTY'
|
|
61
|
-
})
|
|
62
|
-
.matchHeader('Authorization', 'Bearer temp-token')
|
|
63
|
-
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' });
|
|
64
|
-
const result = await testDestination.createAudience({
|
|
65
|
-
...createAudienceInput,
|
|
66
|
-
features: { 'first-party-dv360-canary-version': true }
|
|
67
|
-
});
|
|
68
|
-
expect(result).toEqual({ externalId: 'audience-id-123' });
|
|
69
|
-
});
|
|
70
|
-
it('errors out when no advertiser ID is provided', async () => {
|
|
71
|
-
createAudienceInput.audienceSettings.advertiserId = '';
|
|
72
|
-
await expect(testDestination.createAudience(createAudienceInput)).rejects.toThrowError(actions_core_1.IntegrationError);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe('getAudience', () => {
|
|
76
|
-
it('should succeed with CANARY VERSION', async () => {
|
|
77
|
-
(0, nock_1.default)('https://displayvideo.googleapis.com')
|
|
78
|
-
.get(`/v4/firstPartyAndPartnerAudiences/audience-id-123?advertiserId=12345`)
|
|
79
|
-
.matchHeader('Authorization', 'Bearer temp-token')
|
|
80
|
-
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' });
|
|
81
|
-
const result = await testDestination.getAudience({
|
|
82
|
-
...getAudienceInput,
|
|
83
|
-
features: { 'first-party-dv360-canary-version': true }
|
|
84
|
-
});
|
|
85
|
-
expect(result).toEqual({ externalId: 'audience-id-123' });
|
|
86
|
-
});
|
|
87
|
-
it('should fail when the audience ID is missing', async () => {
|
|
88
|
-
const missingIdInput = {
|
|
89
|
-
...getAudienceInput,
|
|
90
|
-
externalId: ''
|
|
91
|
-
};
|
|
92
|
-
await expect(testDestination.getAudience(missingIdInput)).rejects.toThrowError(new actions_core_1.IntegrationError('Failed to retrieve audience ID value', 'MISSING_REQUIRED_FIELD', 400));
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe('Edit Customer Match Members - Contact Info List', () => {
|
|
96
|
-
const payloadContactInfo = {
|
|
97
|
-
emails: 'test@gmail.com',
|
|
98
|
-
phoneNumbers: '1234567890',
|
|
99
|
-
zipCodes: '12345',
|
|
100
|
-
firstName: 'John',
|
|
101
|
-
lastName: 'Doe',
|
|
102
|
-
countryCode: '+1'
|
|
103
|
-
};
|
|
104
|
-
const event = (0, actions_core_1.createTestEvent)({
|
|
105
|
-
event: 'Audience Entered',
|
|
106
|
-
type: 'track',
|
|
107
|
-
properties: {},
|
|
108
|
-
context: {
|
|
109
|
-
traits: payloadContactInfo,
|
|
110
|
-
personas: {
|
|
111
|
-
external_audience_id: 'audience-id-123',
|
|
112
|
-
audience_settings: {
|
|
113
|
-
advertiserId: '12345',
|
|
114
|
-
token: 'temp-token'
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
it('should add customer match members successfully with CANARY VERSION', async () => {
|
|
120
|
-
(0, nock_1.default)('https://displayvideo.googleapis.com')
|
|
121
|
-
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers')
|
|
122
|
-
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' });
|
|
123
|
-
const result = await testDestination.testAction('addToAudContactInfo', {
|
|
124
|
-
event,
|
|
125
|
-
useDefaultMappings: true,
|
|
126
|
-
features: { 'first-party-dv360-canary-version': true }
|
|
127
|
-
});
|
|
128
|
-
expect(result).toContainEqual(expect.objectContaining({
|
|
129
|
-
data: expect.objectContaining({
|
|
130
|
-
firstPartyAndPartnerAudienceId: 'audience-id-123'
|
|
131
|
-
})
|
|
132
|
-
}));
|
|
133
|
-
});
|
|
134
|
-
it('should remove customer match members successfully with CANARY VERSION', async () => {
|
|
135
|
-
(0, nock_1.default)('https://displayvideo.googleapis.com')
|
|
136
|
-
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
|
|
137
|
-
advertiserId: '12345',
|
|
138
|
-
removedContactInfoList: {
|
|
139
|
-
contactInfos: [
|
|
140
|
-
{
|
|
141
|
-
hashedEmails: '87924606b4131a8aceeeae8868531fbb9712aaa07a5d3a756b26ce0f5d6ca674',
|
|
142
|
-
hashedPhoneNumbers: 'c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646',
|
|
143
|
-
zipCodes: '12345',
|
|
144
|
-
hashedFirstName: '96d9632f363564cc3032521409cf22a852f2032eec099ed5967c0d000cec607a',
|
|
145
|
-
hashedLastName: '799ef92a11af918e3fb741df42934f3b568ed2d93ac1df74f1b8d41a27932a6f',
|
|
146
|
-
countryCode: '+1'
|
|
147
|
-
}
|
|
148
|
-
],
|
|
149
|
-
consent: {
|
|
150
|
-
adUserData: 'CONSENT_STATUS_GRANTED',
|
|
151
|
-
adPersonalization: 'CONSENT_STATUS_GRANTED'
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' });
|
|
156
|
-
const result = await testDestination.testAction('removeFromAudContactInfo', {
|
|
157
|
-
event,
|
|
158
|
-
useDefaultMappings: true,
|
|
159
|
-
features: { 'first-party-dv360-canary-version': true }
|
|
160
|
-
});
|
|
161
|
-
expect(result).toContainEqual(expect.objectContaining({
|
|
162
|
-
data: expect.objectContaining({
|
|
163
|
-
firstPartyAndPartnerAudienceId: 'audience-id-123'
|
|
164
|
-
})
|
|
165
|
-
}));
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
describe('Edit Customer Match Members - Mobile Device ID List', () => {
|
|
169
|
-
const payloadDeviceId = {
|
|
170
|
-
mobileDeviceIds: '123'
|
|
171
|
-
};
|
|
172
|
-
const event = (0, actions_core_1.createTestEvent)({
|
|
173
|
-
event: 'Audience Entered',
|
|
174
|
-
type: 'track',
|
|
175
|
-
properties: {},
|
|
176
|
-
context: {
|
|
177
|
-
traits: payloadDeviceId,
|
|
178
|
-
personas: {
|
|
179
|
-
external_audience_id: 'audience-id-123',
|
|
180
|
-
audience_settings: {
|
|
181
|
-
advertiserId: '12345',
|
|
182
|
-
token: 'temp-token'
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
it('should add customer match members successfully with CANARY VERSION', async () => {
|
|
188
|
-
(0, nock_1.default)('https://displayvideo.googleapis.com')
|
|
189
|
-
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
|
|
190
|
-
advertiserId: '12345',
|
|
191
|
-
addedMobileDeviceIdList: {
|
|
192
|
-
mobileDeviceIds: ['123'],
|
|
193
|
-
consent: {
|
|
194
|
-
adUserData: 'CONSENT_STATUS_GRANTED',
|
|
195
|
-
adPersonalization: 'CONSENT_STATUS_GRANTED'
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' });
|
|
200
|
-
const result = await testDestination.testAction('addToAudMobileDeviceId', {
|
|
201
|
-
event,
|
|
202
|
-
useDefaultMappings: true,
|
|
203
|
-
features: { 'first-party-dv360-canary-version': true }
|
|
204
|
-
});
|
|
205
|
-
expect(result).toContainEqual(expect.objectContaining({
|
|
206
|
-
data: expect.objectContaining({
|
|
207
|
-
firstPartyAndPartnerAudienceId: 'audience-id-123'
|
|
208
|
-
})
|
|
209
|
-
}));
|
|
210
|
-
});
|
|
211
|
-
it('should remove customer match members successfully with CANARY VERSION', async () => {
|
|
212
|
-
(0, nock_1.default)('https://displayvideo.googleapis.com')
|
|
213
|
-
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
|
|
214
|
-
advertiserId: '12345',
|
|
215
|
-
removedMobileDeviceIdList: {
|
|
216
|
-
mobileDeviceIds: ['123'],
|
|
217
|
-
consent: {
|
|
218
|
-
adUserData: 'CONSENT_STATUS_GRANTED',
|
|
219
|
-
adPersonalization: 'CONSENT_STATUS_GRANTED'
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' });
|
|
224
|
-
const result = await testDestination.testAction('removeFromAudMobileDeviceId', {
|
|
225
|
-
event,
|
|
226
|
-
useDefaultMappings: true,
|
|
227
|
-
features: { 'first-party-dv360-canary-version': true }
|
|
228
|
-
});
|
|
229
|
-
expect(result).toContainEqual(expect.objectContaining({
|
|
230
|
-
data: expect.objectContaining({
|
|
231
|
-
firstPartyAndPartnerAudienceId: 'audience-id-123'
|
|
232
|
-
})
|
|
233
|
-
}));
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
2
|
//# sourceMappingURL=index.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../../src/destinations/first-party-dv360/_tests_/index.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../../src/destinations/first-party-dv360/_tests_/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ConversionCustomVariable, PartialErrorResponse, QueryResponse, CustomVariableInterface, CreateAudienceInput, UserListResponse, KeyValuePairList
|
|
1
|
+
import { ConversionCustomVariable, PartialErrorResponse, QueryResponse, CustomVariableInterface, CreateAudienceInput, UserListResponse, KeyValuePairList } from './types';
|
|
2
2
|
import { ModifiedResponse, RequestClient, DynamicFieldResponse, Features, MultiStatusResponse, AudienceMembership } from '@segment/actions-core';
|
|
3
|
-
import { StatsContext
|
|
3
|
+
import { StatsContext } from '@segment/actions-core/destination-kit';
|
|
4
4
|
import { HTTPError } from '@segment/actions-core';
|
|
5
5
|
import type { Payload as UserListPayload } from './userList/generated-types';
|
|
6
6
|
import type { Payload as ClickConversionPayload } from './uploadClickConversion/generated-types';
|
|
@@ -38,14 +38,6 @@ export declare class GoogleAdsError extends HTTPError {
|
|
|
38
38
|
}
|
|
39
39
|
export declare function formatCustomVariables(customVariables: object, customVariableIdsResults: Array<ConversionCustomVariable>): CustomVariableInterface[];
|
|
40
40
|
export declare const hash: (value: string | undefined) => string | undefined;
|
|
41
|
-
export declare const DATA_MANAGER_BASE_URL = "https://datamanager.googleapis.com/v1";
|
|
42
|
-
export declare function exchangeForAccessToken(request: RequestClient, refreshToken: string): Promise<string>;
|
|
43
|
-
export declare function createDataManagerPartnerLink(request: RequestClient, customerId: string, customerAccessToken: string, loginCustomerId?: string): Promise<PartnerLinkResponse>;
|
|
44
|
-
export declare function createDataManagerUserList(request: RequestClient, customerId: string, listName: string, uploadKeyType: string, segmentAccessToken: string, appId?: string): Promise<DataManagerUserList>;
|
|
45
|
-
export declare function getDataManagerUserList(request: RequestClient, customerId: string, userListId: string, segmentAccessToken: string): Promise<DataManagerUserList>;
|
|
46
|
-
export declare function ingestAudienceMembers(request: RequestClient, customerId: string, userListId: string, members: DataManagerAudienceMember[], loginCustomerId?: string): Promise<DataManagerIngestResponse>;
|
|
47
|
-
export declare function removeAudienceMembers(request: RequestClient, customerId: string, userListId: string, members: DataManagerAudienceMember[], loginCustomerId?: string): Promise<DataManagerIngestResponse>;
|
|
48
|
-
export declare function handleDataManagerUpdate(request: RequestClient, settings: CreateAudienceInput['settings'], audienceSettings: CreateAudienceInput['audienceSettings'], payloads: UserListPayload[], hookListId: string, hookListType: string, syncMode?: string, features?: Features, statsContext?: StatsContext, audienceMembership?: AudienceMembership | AudienceMembership[], personasContext?: Personas): Promise<DataManagerIngestResponse[]>;
|
|
49
41
|
export declare function getCustomVariables(customerId: string, auth: any, request: RequestClient, features: Features | undefined, statsContext: StatsContext | undefined): Promise<ModifiedResponse<QueryResponse[]>>;
|
|
50
42
|
export declare function memoizedGetCustomVariables(): (customerId: string, auth: any, request: RequestClient, features: Features | undefined, statsContext: StatsContext | undefined) => Promise<ModifiedResponse<QueryResponse[]> | undefined>;
|
|
51
43
|
export declare function getConversionActionId(customerId: string | undefined, auth: any, request: RequestClient, features: Features | undefined, statsContext: StatsContext | undefined): Promise<ModifiedResponse<QueryResponse[]>>;
|
|
@@ -71,12 +63,12 @@ export declare function getListIds(request: RequestClient, settings: CreateAudie
|
|
|
71
63
|
code: string;
|
|
72
64
|
};
|
|
73
65
|
}>;
|
|
74
|
-
export declare function createGoogleAudience(request: RequestClient, input: CreateAudienceInput,
|
|
75
|
-
export declare function getGoogleAudience(request: RequestClient, settings: CreateAudienceInput['settings'], externalId: string,
|
|
66
|
+
export declare function createGoogleAudience(request: RequestClient, input: CreateAudienceInput, auth: CreateAudienceInput['settings']['oauth'], features?: Features | undefined, statsContext?: StatsContext): Promise<string>;
|
|
67
|
+
export declare function getGoogleAudience(request: RequestClient, settings: CreateAudienceInput['settings'], externalId: string, auth: CreateAudienceInput['settings']['oauth'], features?: Features | undefined, statsContext?: StatsContext): Promise<UserListResponse>;
|
|
76
68
|
export declare function formatToE164(phoneNumber: string, countryCode: string): string;
|
|
77
69
|
export declare const formatPhone: (phone: string, countryCode?: string, features?: Features, statsContext?: StatsContext) => string;
|
|
78
70
|
export declare const validateAndFormatToE164: (phoneNumber: string, countryCode?: string, statsContext?: StatsContext) => string;
|
|
79
|
-
export declare const handleUpdate: (request: RequestClient, settings: CreateAudienceInput["settings"], audienceSettings: CreateAudienceInput["audienceSettings"], payloads: UserListPayload[], hookListId: string, hookListType: string, syncMode?: string, features?: Features | undefined, statsContext?: StatsContext, audienceMembership?: AudienceMembership
|
|
71
|
+
export declare const handleUpdate: (request: RequestClient, settings: CreateAudienceInput["settings"], audienceSettings: CreateAudienceInput["audienceSettings"], payloads: UserListPayload[], hookListId: string, hookListType: string, syncMode?: string, features?: Features | undefined, statsContext?: StatsContext, audienceMembership?: AudienceMembership) => Promise<unknown>;
|
|
80
72
|
export declare const verifyCustomerId: (customerId: string | undefined) => string;
|
|
81
73
|
export declare const handlePartialFailureResponse: (partialFailureError: any, validPayloadIndicesBitmap: number[], multiStatusResponse: MultiStatusResponse, userIdentifiers: any[], failedPayloadIndices: Set<number>) => void;
|
|
82
74
|
export declare const createIdentifierExtractors: (features?: Features) => {
|
|
@@ -105,7 +97,7 @@ export declare const createIdentifierExtractors: (features?: Features) => {
|
|
|
105
97
|
hashedPhoneNumber?: undefined;
|
|
106
98
|
})[] | null;
|
|
107
99
|
};
|
|
108
|
-
export declare const processBatchPayload: (request: RequestClient, settings: CreateAudienceInput["settings"], audienceSettings: CreateAudienceInput["audienceSettings"], payloads: UserListPayload[], hookListId: string, hookListType: string, syncMode?: string, features?: Features | undefined, statsContext?: StatsContext, audienceMemberships?: AudienceMembership[]
|
|
100
|
+
export declare const processBatchPayload: (request: RequestClient, settings: CreateAudienceInput["settings"], audienceSettings: CreateAudienceInput["audienceSettings"], payloads: UserListPayload[], hookListId: string, hookListType: string, syncMode?: string, features?: Features | undefined, statsContext?: StatsContext, audienceMemberships?: AudienceMembership[]) => Promise<MultiStatusResponse>;
|
|
109
101
|
export declare const handleJobExecutionError: (executedJob: any, validPayloadIndicesBitmap: number[], multiStatusResponse: MultiStatusResponse, sentBody: string, failedPayloadIndices: Set<number>) => void;
|
|
110
102
|
export declare function getSessionAttributesKeyValuePairs(payload: ClickConversionPayload | ClickConversionPayload2): {
|
|
111
103
|
sessionAttributesKeyValuePairs: {
|