@segment/action-destinations 3.228.0 → 3.228.1-staging.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/blackbaud-raisers-edge-nxt/utils/index.d.ts +1 -1
- package/dist/destinations/braze/trackEvent/index.js +1 -1
- package/dist/destinations/braze/trackEvent/index.js.map +1 -1
- package/dist/destinations/braze/trackPurchase/generated-types.d.ts +1 -0
- package/dist/destinations/braze/trackPurchase/index.js +9 -0
- package/dist/destinations/braze/trackPurchase/index.js.map +1 -1
- package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.d.ts +1 -0
- package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js +184 -0
- package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js.map +1 -0
- package/dist/destinations/braze/updateUserProfile/generated-types.d.ts +1 -0
- package/dist/destinations/braze/updateUserProfile/index.js +11 -88
- package/dist/destinations/braze/updateUserProfile/index.js.map +1 -1
- package/dist/destinations/braze/utils.d.ts +4 -0
- package/dist/destinations/braze/utils.js +171 -1
- package/dist/destinations/braze/utils.js.map +1 -1
- package/dist/destinations/engage/utils/track.d.ts +17 -17
- package/dist/destinations/klaviyo/addProfileToList/generated-types.d.ts +4 -0
- package/dist/destinations/klaviyo/addProfileToList/generated-types.js +3 -0
- package/dist/destinations/klaviyo/addProfileToList/generated-types.js.map +1 -0
- package/dist/destinations/klaviyo/addProfileToList/index.d.ts +5 -0
- package/dist/destinations/klaviyo/addProfileToList/index.js +48 -0
- package/dist/destinations/klaviyo/addProfileToList/index.js.map +1 -0
- package/dist/destinations/klaviyo/functions.d.ts +7 -0
- package/dist/destinations/klaviyo/functions.js +91 -0
- package/dist/destinations/klaviyo/functions.js.map +1 -0
- package/dist/destinations/klaviyo/index.d.ts +2 -2
- package/dist/destinations/klaviyo/index.js +63 -1
- package/dist/destinations/klaviyo/index.js.map +1 -1
- package/dist/destinations/klaviyo/properties.d.ts +3 -0
- package/dist/destinations/klaviyo/properties.js +21 -0
- package/dist/destinations/klaviyo/properties.js.map +1 -0
- package/dist/destinations/klaviyo/removeProfileToList/generated-types.d.ts +4 -0
- package/dist/destinations/klaviyo/removeProfileToList/generated-types.js +3 -0
- package/dist/destinations/klaviyo/removeProfileToList/generated-types.js.map +1 -0
- package/dist/destinations/klaviyo/removeProfileToList/index.d.ts +5 -0
- package/dist/destinations/klaviyo/removeProfileToList/index.js +43 -0
- package/dist/destinations/klaviyo/removeProfileToList/index.js.map +1 -0
- package/dist/destinations/klaviyo/types.d.ts +20 -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 +16 -1
- package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
- package/dist/destinations/linkedin-conversions/api/api.test.d.ts +1 -0
- package/dist/destinations/linkedin-conversions/api/api.test.js +220 -0
- package/dist/destinations/linkedin-conversions/api/api.test.js.map +1 -0
- package/dist/destinations/linkedin-conversions/api/index.d.ts +7 -1
- package/dist/destinations/linkedin-conversions/api/index.js +141 -0
- package/dist/destinations/linkedin-conversions/api/index.js.map +1 -1
- package/dist/destinations/linkedin-conversions/constants.d.ts +1 -0
- package/dist/destinations/linkedin-conversions/constants.js +7 -1
- package/dist/destinations/linkedin-conversions/constants.js.map +1 -1
- package/dist/destinations/linkedin-conversions/streamConversion/generated-types.d.ts +18 -0
- package/dist/destinations/linkedin-conversions/streamConversion/index.js +142 -6
- package/dist/destinations/linkedin-conversions/streamConversion/index.js.map +1 -1
- package/dist/destinations/linkedin-conversions/types.d.ts +50 -0
- package/dist/destinations/marketo-static-lists/addToList/generated-types.d.ts +5 -0
- package/dist/destinations/marketo-static-lists/addToList/index.js +16 -4
- package/dist/destinations/marketo-static-lists/addToList/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/constants.d.ts +38 -2
- package/dist/destinations/marketo-static-lists/constants.js +5 -1
- package/dist/destinations/marketo-static-lists/constants.js.map +1 -1
- package/dist/destinations/marketo-static-lists/functions.d.ts +7 -0
- package/dist/destinations/marketo-static-lists/functions.js +71 -0
- package/dist/destinations/marketo-static-lists/functions.js.map +1 -0
- package/dist/destinations/marketo-static-lists/index.js.map +1 -1
- package/dist/destinations/marketo-static-lists/properties.d.ts +6 -0
- package/dist/destinations/marketo-static-lists/properties.js +49 -0
- package/dist/destinations/marketo-static-lists/properties.js.map +1 -0
- package/dist/destinations/marketo-static-lists/removeFromList/generated-types.d.ts +5 -0
- package/dist/destinations/marketo-static-lists/removeFromList/index.js +17 -5
- package/dist/destinations/marketo-static-lists/removeFromList/index.js.map +1 -1
- package/dist/destinations/mixpanel/utils.d.ts +13 -0
- package/dist/destinations/mixpanel/utils.js +117 -0
- package/dist/destinations/mixpanel/utils.js.map +1 -0
- package/dist/destinations/snap-conversions-api/index.js +7 -0
- package/dist/destinations/snap-conversions-api/index.js.map +1 -1
- package/dist/destinations/webhook-audiences/index.js +2 -1
- package/dist/destinations/webhook-audiences/index.js.map +1 -1
- package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.d.ts +4 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js +3 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js.map +1 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/index.d.ts +5 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/index.js +26 -0
- package/dist/destinations/yahoo-audiences/createCustomerNode/index.js.map +1 -0
- package/dist/destinations/yahoo-audiences/createSegment/generated-types.d.ts +6 -0
- package/dist/destinations/yahoo-audiences/createSegment/generated-types.js +3 -0
- package/dist/destinations/yahoo-audiences/createSegment/generated-types.js.map +1 -0
- package/dist/destinations/yahoo-audiences/createSegment/index.d.ts +5 -0
- package/dist/destinations/yahoo-audiences/createSegment/index.js +38 -0
- package/dist/destinations/yahoo-audiences/createSegment/index.js.map +1 -0
- package/dist/destinations/yahoo-audiences/utils.d.ts +4 -0
- package/dist/destinations/yahoo-audiences/utils.js +30 -0
- package/dist/destinations/yahoo-audiences/utils.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,220 @@
|
|
|
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 create_request_client_1 = __importDefault(require("../../../../../core/src/create-request-client"));
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const requestClient = create_request_client_1.default();
|
|
11
|
+
describe('LinkedIn Conversions', () => {
|
|
12
|
+
describe('dynamicFields', () => {
|
|
13
|
+
const linkedIn = new api_1.LinkedInConversions(requestClient);
|
|
14
|
+
it('should fetch a list of ad accounts, with their names', async () => {
|
|
15
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
16
|
+
.get(`/adAccountUsers`)
|
|
17
|
+
.query({ q: 'authenticatedUser' })
|
|
18
|
+
.reply(200, {
|
|
19
|
+
elements: [
|
|
20
|
+
{
|
|
21
|
+
account: 'urn:li:sponsoredAccount:516413367',
|
|
22
|
+
changeAuditStamps: {
|
|
23
|
+
created: {
|
|
24
|
+
actor: 'urn:li:unknown:0',
|
|
25
|
+
time: 1500331577000
|
|
26
|
+
},
|
|
27
|
+
lastModified: {
|
|
28
|
+
actor: 'urn:li:unknown:0',
|
|
29
|
+
time: 1505328748000
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
role: 'ACCOUNT_BILLING_ADMIN',
|
|
33
|
+
user: 'urn:li:person:K1RwyVNukt',
|
|
34
|
+
version: {
|
|
35
|
+
versionTag: '89'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
account: 'urn:li:sponsoredAccount:516880883',
|
|
40
|
+
changeAuditStamps: {
|
|
41
|
+
created: {
|
|
42
|
+
actor: 'urn:li:unknown:0',
|
|
43
|
+
time: 1505326590000
|
|
44
|
+
},
|
|
45
|
+
lastModified: {
|
|
46
|
+
actor: 'urn:li:unknown:0',
|
|
47
|
+
time: 1505326615000
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
role: 'ACCOUNT_BILLING_ADMIN',
|
|
51
|
+
user: 'urn:li:person:K1RwyVNukt',
|
|
52
|
+
version: {
|
|
53
|
+
versionTag: '3'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
paging: {
|
|
58
|
+
count: 2,
|
|
59
|
+
links: [],
|
|
60
|
+
start: 0,
|
|
61
|
+
total: 2
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const getAdAccountsRes = await linkedIn.getAdAccounts();
|
|
65
|
+
expect(getAdAccountsRes).toEqual({
|
|
66
|
+
choices: [
|
|
67
|
+
{
|
|
68
|
+
label: 'ACCOUNT_BILLING_ADMIN',
|
|
69
|
+
value: 'urn:li:sponsoredAccount:516413367'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: 'ACCOUNT_BILLING_ADMIN',
|
|
73
|
+
value: 'urn:li:sponsoredAccount:516880883'
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it('should fetch a list of conversion rules', async () => {
|
|
79
|
+
const payload = {
|
|
80
|
+
adAccountId: '123456'
|
|
81
|
+
};
|
|
82
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
83
|
+
.get(`/conversions`)
|
|
84
|
+
.query({ q: 'account', account: payload.adAccountId })
|
|
85
|
+
.reply(200, {
|
|
86
|
+
elements: [
|
|
87
|
+
{
|
|
88
|
+
postClickAttributionWindowSize: 30,
|
|
89
|
+
viewThroughAttributionWindowSize: 7,
|
|
90
|
+
created: 1563230311551,
|
|
91
|
+
type: 'LEAD',
|
|
92
|
+
enabled: true,
|
|
93
|
+
name: 'Conversion API Segment 2',
|
|
94
|
+
lastModified: 1563230311551,
|
|
95
|
+
id: 104012,
|
|
96
|
+
attributionType: 'LAST_TOUCH_BY_CAMPAIGN',
|
|
97
|
+
conversionMethod: 'CONVERSIONS_API',
|
|
98
|
+
account: 'urn:li:sponsoredAccount:51234560'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
postClickAttributionWindowSize: 30,
|
|
102
|
+
viewThroughAttributionWindowSize: 7,
|
|
103
|
+
created: 1563230255308,
|
|
104
|
+
type: 'PURCHASE',
|
|
105
|
+
enabled: true,
|
|
106
|
+
name: 'Conversion API Segment 3',
|
|
107
|
+
lastModified: 1563230265652,
|
|
108
|
+
id: 104004,
|
|
109
|
+
attributionType: 'LAST_TOUCH_BY_CAMPAIGN',
|
|
110
|
+
conversionMethod: 'CONVERSIONS_API',
|
|
111
|
+
account: 'urn:li:sponsoredAccount:51234560'
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
const getConversionRulesListRes = await linkedIn.getConversionRulesList(payload.adAccountId);
|
|
116
|
+
expect(getConversionRulesListRes).toEqual({
|
|
117
|
+
choices: [
|
|
118
|
+
{
|
|
119
|
+
label: 'Conversion API Segment 2',
|
|
120
|
+
value: 104012
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: 'Conversion API Segment 3',
|
|
124
|
+
value: 104004
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
it('should fetch a list of campaigns', async () => {
|
|
130
|
+
const payload = {
|
|
131
|
+
adAccountId: '123456'
|
|
132
|
+
};
|
|
133
|
+
nock_1.default(`${constants_1.BASE_URL}`)
|
|
134
|
+
.get(`/adAccounts/${payload.adAccountId}/adCampaigns?q=search&search=(status:(values:List(ACTIVE)))`)
|
|
135
|
+
.reply(200, {
|
|
136
|
+
paging: {
|
|
137
|
+
start: 0,
|
|
138
|
+
count: 10,
|
|
139
|
+
links: [],
|
|
140
|
+
total: 1
|
|
141
|
+
},
|
|
142
|
+
elements: [
|
|
143
|
+
{
|
|
144
|
+
test: false,
|
|
145
|
+
storyDeliveryEnabled: false,
|
|
146
|
+
format: 'TEXT_AD',
|
|
147
|
+
targetingCriteria: {
|
|
148
|
+
include: {
|
|
149
|
+
and: [
|
|
150
|
+
{
|
|
151
|
+
or: {
|
|
152
|
+
'urn:li:adTargetingFacet:locations': ['urn:li:geo:90000084']
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
or: {
|
|
157
|
+
'urn:li:adTargetingFacet:interfaceLocales': ['urn:li:locale:en_US']
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
servingStatuses: ['ACCOUNT_SERVING_HOLD'],
|
|
164
|
+
locale: {
|
|
165
|
+
country: 'US',
|
|
166
|
+
language: 'en'
|
|
167
|
+
},
|
|
168
|
+
type: 'TEXT_AD',
|
|
169
|
+
version: {
|
|
170
|
+
versionTag: '11'
|
|
171
|
+
},
|
|
172
|
+
objectiveType: 'WEBSITE_TRAFFIC',
|
|
173
|
+
associatedEntity: 'urn:li:organization:2425698',
|
|
174
|
+
optimizationTargetType: 'NONE',
|
|
175
|
+
runSchedule: {
|
|
176
|
+
start: 1498178362345
|
|
177
|
+
},
|
|
178
|
+
changeAuditStamps: {
|
|
179
|
+
created: {
|
|
180
|
+
actor: 'urn:li:unknown:0',
|
|
181
|
+
time: 1498178304000
|
|
182
|
+
},
|
|
183
|
+
lastModified: {
|
|
184
|
+
actor: 'urn:li:unknown:0',
|
|
185
|
+
time: 1698494362000
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
campaignGroup: 'urn:li:sponsoredCampaignGroup:600360846',
|
|
189
|
+
dailyBudget: {
|
|
190
|
+
currencyCode: 'USD',
|
|
191
|
+
amount: '25'
|
|
192
|
+
},
|
|
193
|
+
costType: 'CPC',
|
|
194
|
+
creativeSelection: 'OPTIMIZED',
|
|
195
|
+
unitCost: {
|
|
196
|
+
currencyCode: 'USD',
|
|
197
|
+
amount: '8.19'
|
|
198
|
+
},
|
|
199
|
+
name: 'Test',
|
|
200
|
+
offsiteDeliveryEnabled: false,
|
|
201
|
+
id: 125868226,
|
|
202
|
+
audienceExpansionEnabled: true,
|
|
203
|
+
account: 'urn:li:sponsoredAccount:507525021',
|
|
204
|
+
status: 'ACTIVE'
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
const getCampaignsListRes = await linkedIn.getCampaignsList(payload.adAccountId);
|
|
209
|
+
expect(getCampaignsListRes).toEqual({
|
|
210
|
+
choices: [
|
|
211
|
+
{
|
|
212
|
+
label: 'Test',
|
|
213
|
+
value: 125868226
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
//# sourceMappingURL=api.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.test.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/api/api.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,0GAA+E;AAC/E,gCAA4C;AAC5C,4CAAuC;AAEvC,MAAM,aAAa,GAAG,+BAAmB,EAAE,CAAA;AAE3C,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,MAAM,QAAQ,GAAwB,IAAI,yBAAmB,CAAC,aAAa,CAAC,CAAA;QAE5E,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;YACpE,cAAI,CAAC,GAAG,oBAAQ,EAAE,CAAC;iBAChB,GAAG,CAAC,iBAAiB,CAAC;iBACtB,KAAK,CAAC,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC;iBACjC,KAAK,CAAC,GA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,WAAW,EAAE;4BACX,YAAY,EAAE,KAAK;4BACnB,MAAM,EAAE,IAAI;yBACb;wBACD,QAAQ,EAAE,KAAK;wBACf,iBAAiB,EAAE,WAAW;wBAC9B,QAAQ,EAAE;4BACR,YAAY,EAAE,KAAK;4BACnB,MAAM,EAAE,MAAM;yBACf;wBACD,IAAI,EAAE,MAAM;wBACZ,sBAAsB,EAAE,KAAK;wBAC7B,EAAE,EAAE,SAAS;wBACb,wBAAwB,EAAE,IAAI;wBAC9B,OAAO,EAAE,mCAAmC;wBAC5C,MAAM,EAAE,QAAQ;qBACjB;iBACF;aACF,CAAC,CAAA;YAEJ,MAAM,mBAAmB,GAAG,MAAM,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;YAChF,MAAM,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC;gBAClC,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,MAAM;wBACb,KAAK,EAAE,SAAS;qBACjB;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type { RequestClient, ModifiedResponse } from '@segment/actions-core';
|
|
1
|
+
import type { RequestClient, ModifiedResponse, DynamicFieldResponse } from '@segment/actions-core';
|
|
2
2
|
import type { ProfileAPIResponse } from '../types';
|
|
3
|
+
import type { Payload } from '../streamConversion/generated-types';
|
|
3
4
|
export declare class LinkedInConversions {
|
|
4
5
|
request: RequestClient;
|
|
5
6
|
constructor(request: RequestClient);
|
|
6
7
|
getProfile(): Promise<ModifiedResponse<ProfileAPIResponse>>;
|
|
8
|
+
getAdAccounts: () => Promise<DynamicFieldResponse>;
|
|
9
|
+
getConversionRulesList: (adAccountId: string) => Promise<DynamicFieldResponse>;
|
|
10
|
+
getCampaignsList: (adAccountUrn: string) => Promise<DynamicFieldResponse>;
|
|
11
|
+
streamConversionEvent(payload: Payload): Promise<ModifiedResponse>;
|
|
12
|
+
associateCampignToConversion(payload: Payload): Promise<ModifiedResponse>;
|
|
7
13
|
}
|
|
@@ -4,6 +4,123 @@ exports.LinkedInConversions = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
class LinkedInConversions {
|
|
6
6
|
constructor(request) {
|
|
7
|
+
this.getAdAccounts = async () => {
|
|
8
|
+
try {
|
|
9
|
+
const response = [];
|
|
10
|
+
const result = await this.request(`${constants_1.BASE_URL}/adAccountUsers`, {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
searchParams: {
|
|
13
|
+
q: 'authenticatedUser'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
result.data.elements.forEach((item) => {
|
|
17
|
+
response.push(item);
|
|
18
|
+
});
|
|
19
|
+
const choices = response?.map((item) => {
|
|
20
|
+
return {
|
|
21
|
+
label: item.role,
|
|
22
|
+
value: item.account
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
choices: choices
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
return {
|
|
31
|
+
choices: [],
|
|
32
|
+
error: {
|
|
33
|
+
message: err.response?.data?.message ?? 'An error occurred while fetching ad accounts.',
|
|
34
|
+
code: err.response?.data?.code?.toString() ?? 'FETCH_AD_ACCOUNTS_ERROR'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
this.getConversionRulesList = async (adAccountId) => {
|
|
40
|
+
if (!adAccountId || !adAccountId.length) {
|
|
41
|
+
return {
|
|
42
|
+
choices: [],
|
|
43
|
+
error: {
|
|
44
|
+
message: 'Please select Ad Account first to get list of Conversion Rules.',
|
|
45
|
+
code: 'FIELD_NOT_SELECTED'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const response = [];
|
|
51
|
+
const result = await this.request(`${constants_1.BASE_URL}/conversions`, {
|
|
52
|
+
method: 'GET',
|
|
53
|
+
searchParams: {
|
|
54
|
+
q: 'account',
|
|
55
|
+
account: adAccountId
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
result.data.elements.forEach((item) => {
|
|
59
|
+
response.push(item);
|
|
60
|
+
});
|
|
61
|
+
const choices = response?.map((item) => {
|
|
62
|
+
return {
|
|
63
|
+
label: item.name,
|
|
64
|
+
value: item.id
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
choices: choices
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
return {
|
|
73
|
+
choices: [],
|
|
74
|
+
error: {
|
|
75
|
+
message: err.response?.data?.message ?? 'An error occurred while fetching conversion rules.',
|
|
76
|
+
code: err.response?.data?.code?.toString() ?? 'FETCH_CONVERSIONS_ERROR'
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
this.getCampaignsList = async (adAccountUrn) => {
|
|
82
|
+
const parts = adAccountUrn.split(':');
|
|
83
|
+
const adAccountId = parts.pop();
|
|
84
|
+
if (!adAccountId || !adAccountId.length) {
|
|
85
|
+
return {
|
|
86
|
+
choices: [],
|
|
87
|
+
error: {
|
|
88
|
+
message: 'Please select Ad Account first to get list of Conversion Rules.',
|
|
89
|
+
code: 'FIELD_NOT_SELECTED'
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const response = [];
|
|
95
|
+
const result = await this.request(`${constants_1.BASE_URL}/adAccounts/${adAccountId}/adCampaigns?q=search&search=(status:(values:List(ACTIVE)))`, {
|
|
96
|
+
method: 'GET',
|
|
97
|
+
headers: {
|
|
98
|
+
'X-Restli-Protocol-Version': '2.0.0'
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
result.data.elements.forEach((item) => {
|
|
102
|
+
response.push(item);
|
|
103
|
+
});
|
|
104
|
+
const choices = response?.map((item) => {
|
|
105
|
+
return {
|
|
106
|
+
label: item.name,
|
|
107
|
+
value: item.id
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
choices: choices
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
return {
|
|
116
|
+
choices: [],
|
|
117
|
+
error: {
|
|
118
|
+
message: err.response?.data?.message ?? 'An error occurred while fetching conversion rules.',
|
|
119
|
+
code: err.response?.data?.code?.toString() ?? 'FETCH_CONVERSIONS_ERROR'
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
};
|
|
7
124
|
this.request = request;
|
|
8
125
|
}
|
|
9
126
|
async getProfile() {
|
|
@@ -11,6 +128,30 @@ class LinkedInConversions {
|
|
|
11
128
|
method: 'GET'
|
|
12
129
|
});
|
|
13
130
|
}
|
|
131
|
+
async streamConversionEvent(payload) {
|
|
132
|
+
return this.request(`${constants_1.BASE_URL}/conversionEvents`, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
json: {
|
|
135
|
+
conversion: `urn:lla:llaPartnerConversion:${payload.conversionId}`,
|
|
136
|
+
conversionHappenedAt: payload.conversionHappenedAt,
|
|
137
|
+
conversionValue: payload.conversionValue,
|
|
138
|
+
eventId: payload.eventId,
|
|
139
|
+
user: payload.user
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async associateCampignToConversion(payload) {
|
|
144
|
+
return this.request(`https://api.linkedin.com/rest/campaignConversions/(campaign:urn%3Ali%3AsponsoredCampaign%3A${payload.campaignId},conversion:urn%3Alla%3AllaPartnerConversion%3A${payload.conversionId})`, {
|
|
145
|
+
method: 'PUT',
|
|
146
|
+
headers: {
|
|
147
|
+
'X-Restli-Protocol-Version': '2.0.0'
|
|
148
|
+
},
|
|
149
|
+
body: JSON.stringify({
|
|
150
|
+
campaign: `urn:li:sponsoredCampaign:${payload.campaignId}`,
|
|
151
|
+
conversion: `urn:lla:llaPartnerConversion:${payload.conversionId}`
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
}
|
|
14
155
|
}
|
|
15
156
|
exports.LinkedInConversions = LinkedInConversions;
|
|
16
157
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/api/index.ts"],"names":[],"mappings":";;;AACA,4CAAuC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/api/index.ts"],"names":[],"mappings":";;;AACA,4CAAuC;AAYvC,MAAa,mBAAmB;IAG9B,YAAY,OAAsB;QAUlC,kBAAa,GAAG,KAAK,IAAmC,EAAE;YACxD,IAAI;gBACF,MAAM,QAAQ,GAAoB,EAAE,CAAA;gBACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAA2B,GAAG,oBAAQ,iBAAiB,EAAE;oBACxF,MAAM,EAAE,KAAK;oBACb,YAAY,EAAE;wBACZ,CAAC,EAAE,mBAAmB;qBACvB;iBACF,CAAC,CAAA;gBAEF,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBACpC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACrB,CAAC,CAAC,CAAA;gBAEF,MAAM,OAAO,GAAG,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;oBACrC,OAAO;wBACL,KAAK,EAAE,IAAI,CAAC,IAAI;wBAChB,KAAK,EAAE,IAAI,CAAC,OAAO;qBACpB,CAAA;gBACH,CAAC,CAAC,CAAA;gBAEF,OAAO;oBACL,OAAO,EAAE,OAAO;iBACjB,CAAA;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO;oBACL,OAAO,EAAE,EAAE;oBACX,KAAK,EAAE;wBACL,O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IACH,CAAC;CACF;AAhLD,kDAgLC"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LINKEDIN_SOURCE_PLATFORM = exports.BASE_URL = exports.LINKEDIN_API_VERSION = void 0;
|
|
3
|
+
exports.SUPPORTED_ID_TYPE = exports.LINKEDIN_SOURCE_PLATFORM = exports.BASE_URL = exports.LINKEDIN_API_VERSION = void 0;
|
|
4
4
|
exports.LINKEDIN_API_VERSION = '202309';
|
|
5
5
|
exports.BASE_URL = 'https://api.linkedin.com/rest';
|
|
6
6
|
exports.LINKEDIN_SOURCE_PLATFORM = 'SEGMENT';
|
|
7
|
+
exports.SUPPORTED_ID_TYPE = [
|
|
8
|
+
'SHA256_EMAIL',
|
|
9
|
+
'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID',
|
|
10
|
+
'ACXIOM_ID',
|
|
11
|
+
'ORACLE_MOAT_ID'
|
|
12
|
+
];
|
|
7
13
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-conversions/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAC/B,QAAA,QAAQ,GAAG,+BAA+B,CAAA;AAC1C,QAAA,wBAAwB,GAAG,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-conversions/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAC/B,QAAA,QAAQ,GAAG,+BAA+B,CAAA;AAC1C,QAAA,wBAAwB,GAAG,SAAS,CAAA;AAEpC,QAAA,iBAAiB,GAAG;IAC/B,cAAc;IACd,wCAAwC;IACxC,WAAW;IACX,gBAAgB;CACjB,CAAA"}
|
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
export interface Payload {
|
|
2
|
+
adAccountId: string;
|
|
3
|
+
conversionId?: string;
|
|
4
|
+
conversionHappenedAt: number;
|
|
5
|
+
conversionValue?: {
|
|
6
|
+
currencyCode: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
};
|
|
9
|
+
eventId?: string;
|
|
10
|
+
user: {
|
|
11
|
+
userIds: {
|
|
12
|
+
idType: string;
|
|
13
|
+
idValue: string;
|
|
14
|
+
}[];
|
|
15
|
+
userInfo?: {
|
|
16
|
+
[k: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
campaignId: string;
|
|
2
20
|
}
|
|
@@ -1,15 +1,151 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
3
6
|
const action = {
|
|
4
7
|
title: 'Stream Conversion Event',
|
|
5
8
|
description: 'Directly streams conversion events to a specific conversion rule.',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
defaultSubscription: 'type = "track"',
|
|
10
|
+
fields: {
|
|
11
|
+
adAccountId: {
|
|
12
|
+
label: 'Ad Account',
|
|
13
|
+
description: 'A dynamic field dropdown which fetches all adAccounts.',
|
|
14
|
+
type: 'string',
|
|
15
|
+
required: true,
|
|
16
|
+
dynamic: true
|
|
17
|
+
},
|
|
18
|
+
conversionId: {
|
|
19
|
+
label: 'Conversion Rule',
|
|
20
|
+
description: 'Fetches a list of conversion rules given an ad account id.',
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: false,
|
|
23
|
+
dynamic: true
|
|
24
|
+
},
|
|
25
|
+
conversionHappenedAt: {
|
|
26
|
+
label: 'Timestamp',
|
|
27
|
+
description: 'Epoch timestamp in milliseconds at which the conversion event happened. If your source records conversion timestamps in second, insert 000 at the end to transform it to milliseconds.',
|
|
28
|
+
type: 'integer',
|
|
29
|
+
required: true,
|
|
30
|
+
default: {
|
|
31
|
+
'@path': '$.timestamp'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
conversionValue: {
|
|
35
|
+
label: 'Conversion Value',
|
|
36
|
+
description: 'The monetary value for this conversion. Example: [“currencyCode”: “USD”, “amount”: “50.0”].',
|
|
37
|
+
type: 'object',
|
|
38
|
+
required: false,
|
|
39
|
+
properties: {
|
|
40
|
+
currencyCode: {
|
|
41
|
+
label: 'Currency Code',
|
|
42
|
+
type: 'string',
|
|
43
|
+
required: true,
|
|
44
|
+
description: 'ISO format'
|
|
45
|
+
},
|
|
46
|
+
amount: {
|
|
47
|
+
label: 'Amount',
|
|
48
|
+
type: 'string',
|
|
49
|
+
required: true,
|
|
50
|
+
description: 'Value of the conversion in decimal string. Can be dynamically set up or have a fixed value.'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
eventId: {
|
|
55
|
+
label: 'Event ID',
|
|
56
|
+
description: 'Will be used for deduplication in future.',
|
|
57
|
+
type: 'string',
|
|
58
|
+
required: false,
|
|
59
|
+
default: {
|
|
60
|
+
'@path': '$.messageId'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
user: {
|
|
64
|
+
label: 'User',
|
|
65
|
+
description: 'userId or userInfo Combination is REQUIRED.',
|
|
66
|
+
type: 'object',
|
|
67
|
+
required: true,
|
|
68
|
+
properties: {
|
|
69
|
+
userIds: {
|
|
70
|
+
label: 'User Ids',
|
|
71
|
+
type: 'object',
|
|
72
|
+
multiple: true,
|
|
73
|
+
required: true,
|
|
74
|
+
properties: {
|
|
75
|
+
idType: {
|
|
76
|
+
label: 'idType',
|
|
77
|
+
type: 'string',
|
|
78
|
+
required: true
|
|
79
|
+
},
|
|
80
|
+
idValue: {
|
|
81
|
+
label: 'idValue',
|
|
82
|
+
type: 'string',
|
|
83
|
+
required: true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
userInfo: {
|
|
88
|
+
label: 'User Info',
|
|
89
|
+
type: 'object',
|
|
90
|
+
required: false
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
campaignId: {
|
|
95
|
+
label: 'Campaign',
|
|
96
|
+
type: 'string',
|
|
97
|
+
required: true,
|
|
98
|
+
dynamic: true,
|
|
99
|
+
description: 'A dynamic field dropdown which fetches all active campaigns.'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
dynamicFields: {
|
|
103
|
+
adAccountId: async (request) => {
|
|
104
|
+
const linkedIn = new api_1.LinkedInConversions(request);
|
|
105
|
+
return linkedIn.getAdAccounts();
|
|
106
|
+
},
|
|
107
|
+
conversionId: async (request, { payload }) => {
|
|
108
|
+
const linkedIn = new api_1.LinkedInConversions(request);
|
|
109
|
+
return linkedIn.getConversionRulesList(payload.adAccountId);
|
|
110
|
+
},
|
|
111
|
+
campaignId: async (request, { payload }) => {
|
|
112
|
+
const linkedIn = new api_1.LinkedInConversions(request);
|
|
113
|
+
return linkedIn.getCampaignsList(payload.adAccountId);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
perform: async (request, { payload }) => {
|
|
117
|
+
validate(payload);
|
|
118
|
+
const linkedinApiClient = new api_1.LinkedInConversions(request);
|
|
119
|
+
try {
|
|
120
|
+
await linkedinApiClient.associateCampignToConversion(payload);
|
|
121
|
+
return linkedinApiClient.streamConversionEvent(payload);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return error;
|
|
125
|
+
}
|
|
12
126
|
}
|
|
13
127
|
};
|
|
128
|
+
function validate(payload) {
|
|
129
|
+
const dateFromTimestamp = new Date(payload.conversionHappenedAt);
|
|
130
|
+
if (isNaN(dateFromTimestamp.getTime())) {
|
|
131
|
+
throw new actions_core_1.PayloadValidationError('Timestamp field should be valid timestamp.');
|
|
132
|
+
}
|
|
133
|
+
const ninetyDaysAgo = Date.now() - 90 * 24 * 60 * 60 * 1000;
|
|
134
|
+
if (payload.conversionHappenedAt < ninetyDaysAgo) {
|
|
135
|
+
throw new actions_core_1.PayloadValidationError('Timestamp should be within the past 90 days.');
|
|
136
|
+
}
|
|
137
|
+
if (payload.user.userIds.length === 0 &&
|
|
138
|
+
(!payload.user.userInfo || !(payload.user.userInfo.firstName && payload.user.userInfo.lastName))) {
|
|
139
|
+
throw new actions_core_1.PayloadValidationError('Either userIds array or userInfo with firstName and lastName should be present.');
|
|
140
|
+
}
|
|
141
|
+
else if (payload.user.userIds.length !== 0) {
|
|
142
|
+
const isValidUserIds = payload.user.userIds.some((obj) => {
|
|
143
|
+
return constants_1.SUPPORTED_ID_TYPE.includes(obj.idType);
|
|
144
|
+
});
|
|
145
|
+
if (!isValidUserIds) {
|
|
146
|
+
throw new actions_core_1.PayloadValidationError('Invalid idType in userIds field.');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
14
150
|
exports.default = action;
|
|
15
151
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/streamConversion/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/streamConversion/index.ts"],"names":[],"mappings":";;AACA,wDAA8D;AAG9D,gCAA4C;AAC5C,4CAAgD;AAEhD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,mEAAmE;IAChF,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,WAAW,EAAE;YACX,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,wDAAwD;YACrE,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;SACd;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,i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