@prismatic-io/components-adobe-analytics 0.0.0-stage → 0.0.1
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/README.md +64 -2
- package/dist/icon.png +0 -0
- package/dist/index.js +218 -0
- package/npm-dist/icon.png +0 -0
- package/npm-dist/index.cjs +751 -0
- package/npm-dist/index.d.cts +636 -0
- package/package.json +49 -4
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
let _prismatic_io_spectral = require("@prismatic-io/spectral");
|
|
2
|
+
let _prismatic_io_spectral_http = require("@prismatic-io/spectral/http");
|
|
3
|
+
//#region src/client.ts
|
|
4
|
+
const createClient = (connection, debug) => {
|
|
5
|
+
return (0, _prismatic_io_spectral_http.createClient)({
|
|
6
|
+
baseUrl: "https://analytics.adobe.io",
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: `Bearer ${connection.token?.access_token}`,
|
|
9
|
+
"x-api-key": _prismatic_io_spectral.util.types.toString(connection.fields.clientId)
|
|
10
|
+
},
|
|
11
|
+
debug
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/examplePayloads.ts
|
|
16
|
+
const getCurrentUserExamplePayload = { data: {
|
|
17
|
+
imsUserId: "1B2A3C4D5E6F7A8B9C0D1E2F@AdobeID",
|
|
18
|
+
imsOrgs: [{
|
|
19
|
+
imsOrgId: "EA1234567890ABCDEF1234@AdobeOrg",
|
|
20
|
+
companies: [{
|
|
21
|
+
globalCompanyId: "testco0",
|
|
22
|
+
companyName: "Test Company",
|
|
23
|
+
apiRateLimitPolicy: "aa_api_tier10_tp"
|
|
24
|
+
}, {
|
|
25
|
+
globalCompanyId: "anothe0",
|
|
26
|
+
companyName: "Another Test Company",
|
|
27
|
+
apiRateLimitPolicy: "aa_api_tier10_tp"
|
|
28
|
+
}]
|
|
29
|
+
}]
|
|
30
|
+
} };
|
|
31
|
+
const listCompaniesExamplePayload = { data: [{
|
|
32
|
+
globalCompanyId: "testco0",
|
|
33
|
+
companyName: "Test Company",
|
|
34
|
+
apiRateLimitPolicy: "aa_api_tier10_tp"
|
|
35
|
+
}, {
|
|
36
|
+
globalCompanyId: "anothe0",
|
|
37
|
+
companyName: "Another Test Company",
|
|
38
|
+
apiRateLimitPolicy: "aa_api_tier10_tp"
|
|
39
|
+
}] };
|
|
40
|
+
const getReportSuiteExamplePayload = { data: {
|
|
41
|
+
collectionItemType: "reportsuite",
|
|
42
|
+
id: "examplersid",
|
|
43
|
+
rsid: "examplersid",
|
|
44
|
+
name: "Example Suite"
|
|
45
|
+
} };
|
|
46
|
+
const listReportSuitesExamplePayload = { data: [{
|
|
47
|
+
collectionItemType: "reportsuite",
|
|
48
|
+
id: "examplersid",
|
|
49
|
+
rsid: "examplersid",
|
|
50
|
+
name: "Example Suite"
|
|
51
|
+
}] };
|
|
52
|
+
const listVirtualReportSuitesExamplePayload = { data: [{
|
|
53
|
+
collectionItemType: "reportsuite",
|
|
54
|
+
id: "vrs_example01",
|
|
55
|
+
rsid: "vrs_example01",
|
|
56
|
+
name: "Example Virtual Report Suite"
|
|
57
|
+
}] };
|
|
58
|
+
const listReportSuiteMetricsExamplePayload = { data: [{
|
|
59
|
+
id: "metrics/campaigninstances",
|
|
60
|
+
title: "Campaign Click-throughs",
|
|
61
|
+
name: "Campaign Click-throughs",
|
|
62
|
+
type: "int",
|
|
63
|
+
category: "Traffic Sources",
|
|
64
|
+
support: ["oberon", "dataWarehouse"],
|
|
65
|
+
allocation: true,
|
|
66
|
+
precision: 0,
|
|
67
|
+
calculated: false,
|
|
68
|
+
segmentable: true,
|
|
69
|
+
supportsDataGovernance: false,
|
|
70
|
+
polarity: "positive",
|
|
71
|
+
standardComponent: true
|
|
72
|
+
}] };
|
|
73
|
+
const listReportSuiteDimensionsExamplePayload = { data: [{
|
|
74
|
+
id: "variables/campaign",
|
|
75
|
+
title: "Tracking Code",
|
|
76
|
+
name: "Tracking Code",
|
|
77
|
+
type: "string",
|
|
78
|
+
category: "Traffic Sources",
|
|
79
|
+
support: ["dataWarehouse", "oberon"],
|
|
80
|
+
pathable: false,
|
|
81
|
+
segmentable: true,
|
|
82
|
+
reportable: ["oberon"],
|
|
83
|
+
supportsDataGovernance: true,
|
|
84
|
+
description: "Displays the Tracking Codes that are generated from Campaign tracking on the site.",
|
|
85
|
+
multiValued: false,
|
|
86
|
+
standardComponent: true
|
|
87
|
+
}] };
|
|
88
|
+
const runReportExamplePayload = { data: {
|
|
89
|
+
totalPages: 1,
|
|
90
|
+
firstPage: true,
|
|
91
|
+
lastPage: true,
|
|
92
|
+
numberOfElements: 3,
|
|
93
|
+
number: 0,
|
|
94
|
+
totalElements: 3,
|
|
95
|
+
columns: {
|
|
96
|
+
dimension: {
|
|
97
|
+
id: "variables/evar2",
|
|
98
|
+
type: "string"
|
|
99
|
+
},
|
|
100
|
+
columnIds: ["0"]
|
|
101
|
+
},
|
|
102
|
+
rows: [
|
|
103
|
+
{
|
|
104
|
+
itemId: "1132341824",
|
|
105
|
+
value: "red t-shirt",
|
|
106
|
+
data: [1515]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
itemId: "2400044733",
|
|
110
|
+
value: "digital watches",
|
|
111
|
+
data: [1]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
itemId: "3614317595",
|
|
115
|
+
value: "running shoes",
|
|
116
|
+
data: [16]
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
summaryData: { totals: [1532] }
|
|
120
|
+
} };
|
|
121
|
+
const rawRequestExamplePayload = { data: {
|
|
122
|
+
data: {},
|
|
123
|
+
headers: {}
|
|
124
|
+
} };
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/inputs/common.ts
|
|
127
|
+
const connectionInput = (0, _prismatic_io_spectral.input)({
|
|
128
|
+
label: "Connection",
|
|
129
|
+
required: true,
|
|
130
|
+
type: "connection",
|
|
131
|
+
comments: "The Adobe Analytics connection to use."
|
|
132
|
+
});
|
|
133
|
+
const globalCompanyIdInput = (0, _prismatic_io_spectral.input)({
|
|
134
|
+
label: "Global Company ID",
|
|
135
|
+
type: "string",
|
|
136
|
+
required: true,
|
|
137
|
+
comments: "The unique identifier for the analytics company.",
|
|
138
|
+
placeholder: "Enter global company ID",
|
|
139
|
+
example: "exampl123",
|
|
140
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
141
|
+
});
|
|
142
|
+
const reportSuiteIdInput = (0, _prismatic_io_spectral.input)({
|
|
143
|
+
label: "Report Suite ID",
|
|
144
|
+
type: "string",
|
|
145
|
+
required: true,
|
|
146
|
+
comments: "The unique identifier for the report suite to query.",
|
|
147
|
+
placeholder: "Enter report suite ID",
|
|
148
|
+
example: "exampletest",
|
|
149
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
150
|
+
});
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/inputs/companies/listCompanies.ts
|
|
153
|
+
const listCompaniesInputs = { connection: connectionInput };
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/inputs/dataSources/company/selectCompany.ts
|
|
156
|
+
const selectCompanyInputs = { connection: connectionInput };
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/inputs/dataSources/dimension/selectReportSuiteDimension.ts
|
|
159
|
+
const selectReportSuiteDimensionInputs = {
|
|
160
|
+
connection: connectionInput,
|
|
161
|
+
globalCompanyId: globalCompanyIdInput,
|
|
162
|
+
reportSuiteId: reportSuiteIdInput
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/inputs/dataSources/metric/selectReportSuiteMetric.ts
|
|
166
|
+
const selectReportSuiteMetricInputs = {
|
|
167
|
+
connection: connectionInput,
|
|
168
|
+
globalCompanyId: globalCompanyIdInput,
|
|
169
|
+
reportSuiteId: reportSuiteIdInput
|
|
170
|
+
};
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/inputs/dataSources/reportSuite/selectReportSuite.ts
|
|
173
|
+
const selectReportSuiteInputs = {
|
|
174
|
+
connection: connectionInput,
|
|
175
|
+
globalCompanyId: globalCompanyIdInput
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/inputs/dataSources/reportSuite/selectVirtualReportSuite.ts
|
|
179
|
+
const selectVirtualReportSuiteInputs = {
|
|
180
|
+
connection: connectionInput,
|
|
181
|
+
globalCompanyId: globalCompanyIdInput
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/inputs/dimensions/listReportSuiteDimensions.ts
|
|
185
|
+
const listReportSuiteDimensionsInputs = {
|
|
186
|
+
connection: connectionInput,
|
|
187
|
+
globalCompanyId: globalCompanyIdInput,
|
|
188
|
+
reportSuiteId: reportSuiteIdInput
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/inputs/metrics/listReportSuiteMetrics.ts
|
|
192
|
+
const listReportSuiteMetricsInputs = {
|
|
193
|
+
connection: connectionInput,
|
|
194
|
+
globalCompanyId: globalCompanyIdInput,
|
|
195
|
+
reportSuiteId: reportSuiteIdInput
|
|
196
|
+
};
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/inputs/reportSuites/common.ts
|
|
199
|
+
const dimensionInput = (0, _prismatic_io_spectral.input)({
|
|
200
|
+
label: "Dimension",
|
|
201
|
+
type: "string",
|
|
202
|
+
required: true,
|
|
203
|
+
comments: "The analytics dimension to break down the report by. Use the format variables/dimensionname.",
|
|
204
|
+
placeholder: "Enter dimension",
|
|
205
|
+
example: "variables/daterangeday",
|
|
206
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
207
|
+
});
|
|
208
|
+
const reportRequestBodyInput = (0, _prismatic_io_spectral.input)({
|
|
209
|
+
label: "Report Request Body",
|
|
210
|
+
type: "code",
|
|
211
|
+
required: true,
|
|
212
|
+
comments: "The JSON request body for the report. Specify all fields besides dimension and report suite ID here, including filters, metrics, and settings.",
|
|
213
|
+
placeholder: "Enter report request body",
|
|
214
|
+
language: "json",
|
|
215
|
+
clean: _prismatic_io_spectral.util.types.toObject,
|
|
216
|
+
default: JSON.stringify({
|
|
217
|
+
globalFilters: [{
|
|
218
|
+
type: "dateRange",
|
|
219
|
+
dateRange: "YYYY-12-31T00:00:00.000/YYYY-01-31T23:59:59.999"
|
|
220
|
+
}],
|
|
221
|
+
metricContainer: {
|
|
222
|
+
metrics: [{
|
|
223
|
+
columnId: "0",
|
|
224
|
+
id: "metrics/pageviews",
|
|
225
|
+
filters: ["0"]
|
|
226
|
+
}],
|
|
227
|
+
metricFilters: [{
|
|
228
|
+
id: "0",
|
|
229
|
+
type: "dateRange",
|
|
230
|
+
dateRange: "YYYY-12-31T00:00:00.000/YYYY-01-31T23:59:59.999"
|
|
231
|
+
}]
|
|
232
|
+
},
|
|
233
|
+
settings: {
|
|
234
|
+
dimensionSort: "asc",
|
|
235
|
+
limit: "10",
|
|
236
|
+
page: "2"
|
|
237
|
+
}
|
|
238
|
+
}, null, 2)
|
|
239
|
+
});
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/inputs/reportSuites/getReportSuite.ts
|
|
242
|
+
const getReportSuiteInputs = {
|
|
243
|
+
connection: connectionInput,
|
|
244
|
+
globalCompanyId: globalCompanyIdInput,
|
|
245
|
+
reportSuiteId: reportSuiteIdInput
|
|
246
|
+
};
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/inputs/reportSuites/listReportSuites.ts
|
|
249
|
+
const listReportSuitesInputs = {
|
|
250
|
+
connection: connectionInput,
|
|
251
|
+
globalCompanyId: globalCompanyIdInput
|
|
252
|
+
};
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/inputs/reportSuites/listVirtualReportSuites.ts
|
|
255
|
+
const listVirtualReportSuitesInputs = {
|
|
256
|
+
connection: connectionInput,
|
|
257
|
+
globalCompanyId: globalCompanyIdInput
|
|
258
|
+
};
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/inputs/reportSuites/runReport.ts
|
|
261
|
+
const runReportInputs = {
|
|
262
|
+
connection: connectionInput,
|
|
263
|
+
globalCompanyId: globalCompanyIdInput,
|
|
264
|
+
reportSuiteId: reportSuiteIdInput,
|
|
265
|
+
dimension: dimensionInput,
|
|
266
|
+
reportRequestBody: reportRequestBodyInput
|
|
267
|
+
};
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/constants.ts
|
|
270
|
+
const PollResource = {
|
|
271
|
+
REPORT_SUITES: "reportSuites",
|
|
272
|
+
COMPANIES: "companies"
|
|
273
|
+
};
|
|
274
|
+
const POLL_RESOURCE_CONFIG = {
|
|
275
|
+
[PollResource.REPORT_SUITES]: { label: "Report Suites" },
|
|
276
|
+
[PollResource.COMPANIES]: { label: "Companies" }
|
|
277
|
+
};
|
|
278
|
+
const pollResourceModel = Object.entries(POLL_RESOURCE_CONFIG).map(([value, { label }]) => ({
|
|
279
|
+
label,
|
|
280
|
+
value
|
|
281
|
+
}));
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/inputs/triggers.ts
|
|
284
|
+
const pollResourceType = (0, _prismatic_io_spectral.input)({
|
|
285
|
+
label: "Resource Type",
|
|
286
|
+
type: "string",
|
|
287
|
+
required: true,
|
|
288
|
+
comments: "The type of resource to poll for new records.",
|
|
289
|
+
model: pollResourceModel,
|
|
290
|
+
clean: _prismatic_io_spectral.util.types.toString
|
|
291
|
+
});
|
|
292
|
+
const showNewRecords = (0, _prismatic_io_spectral.input)({
|
|
293
|
+
label: "Show New Records",
|
|
294
|
+
type: "boolean",
|
|
295
|
+
required: true,
|
|
296
|
+
default: "true",
|
|
297
|
+
comments: "Include newly created records in trigger results.",
|
|
298
|
+
clean: _prismatic_io_spectral.util.types.toBool
|
|
299
|
+
});
|
|
300
|
+
const pollChangesTriggerInputs = {
|
|
301
|
+
connection: connectionInput,
|
|
302
|
+
globalCompanyId: {
|
|
303
|
+
...globalCompanyIdInput,
|
|
304
|
+
required: false
|
|
305
|
+
},
|
|
306
|
+
resourceType: pollResourceType,
|
|
307
|
+
showNewRecords
|
|
308
|
+
};
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/inputs/users/getCurrentUser.ts
|
|
311
|
+
const getCurrentUserInputs = { connection: connectionInput };
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/actions/companies/listCompanies.ts
|
|
314
|
+
const listCompanies = (0, _prismatic_io_spectral.action)({
|
|
315
|
+
display: {
|
|
316
|
+
label: "List Companies",
|
|
317
|
+
description: "Lists all companies the authenticated user can access."
|
|
318
|
+
},
|
|
319
|
+
inputs: listCompaniesInputs,
|
|
320
|
+
perform: async (context, params) => {
|
|
321
|
+
const { data } = await createClient(params.connection, context.debug.enabled).get("/discovery/me");
|
|
322
|
+
return { data: data.imsOrgs.flatMap((org) => org.companies) };
|
|
323
|
+
},
|
|
324
|
+
examplePayload: listCompaniesExamplePayload
|
|
325
|
+
});
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/actions/dimensions/listReportSuiteDimensions.ts
|
|
328
|
+
const listReportSuiteDimensions = (0, _prismatic_io_spectral.action)({
|
|
329
|
+
display: {
|
|
330
|
+
label: "List Dimensions for Report Suite",
|
|
331
|
+
description: "Retrieves a list of dimensions for a given report suite."
|
|
332
|
+
},
|
|
333
|
+
inputs: listReportSuiteDimensionsInputs,
|
|
334
|
+
perform: async (context, params) => {
|
|
335
|
+
const { data } = await createClient(params.connection, context.debug.enabled).get(`https://analytics.adobe.io/api/${params.globalCompanyId}/dimensions`, { params: { rsid: params.reportSuiteId } });
|
|
336
|
+
return { data };
|
|
337
|
+
},
|
|
338
|
+
examplePayload: listReportSuiteDimensionsExamplePayload
|
|
339
|
+
});
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/actions/metrics/listReportSuiteMetrics.ts
|
|
342
|
+
const listReportSuiteMetrics = (0, _prismatic_io_spectral.action)({
|
|
343
|
+
display: {
|
|
344
|
+
label: "List Metrics for Report Suite",
|
|
345
|
+
description: "Retrieves a list of metrics for a given report suite."
|
|
346
|
+
},
|
|
347
|
+
inputs: listReportSuiteMetricsInputs,
|
|
348
|
+
perform: async (context, params) => {
|
|
349
|
+
const { data } = await createClient(params.connection, context.debug.enabled).get(`https://analytics.adobe.io/api/${params.globalCompanyId}/metrics`, { params: { rsid: params.reportSuiteId } });
|
|
350
|
+
return { data };
|
|
351
|
+
},
|
|
352
|
+
examplePayload: listReportSuiteMetricsExamplePayload
|
|
353
|
+
});
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/actions/misc/rawRequest.ts
|
|
356
|
+
const { debugRequest: _, ...rawRequestInputs } = _prismatic_io_spectral_http.inputs;
|
|
357
|
+
const rawRequest = (0, _prismatic_io_spectral.action)({
|
|
358
|
+
display: {
|
|
359
|
+
label: "Raw Request",
|
|
360
|
+
description: "Sends a raw HTTP request to Adobe Analytics."
|
|
361
|
+
},
|
|
362
|
+
inputs: {
|
|
363
|
+
connection: connectionInput,
|
|
364
|
+
...rawRequestInputs,
|
|
365
|
+
url: {
|
|
366
|
+
...rawRequestInputs.url,
|
|
367
|
+
comments: "Input the path only (/discovery/me), The base URL is already included (https://analytics.adobe.io). For example, to connect to https://analytics.adobe.io/discovery/me, only /discovery/me is entered in this field.",
|
|
368
|
+
example: "/discovery/me"
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
perform: async (context, { connection, ...rawRequestInputs }) => {
|
|
372
|
+
const { data, headers } = await (0, _prismatic_io_spectral_http.sendRawRequest)("https://analytics.adobe.io", {
|
|
373
|
+
...rawRequestInputs,
|
|
374
|
+
debugRequest: context.debug.enabled
|
|
375
|
+
}, {
|
|
376
|
+
"x-api-key": _prismatic_io_spectral.util.types.toString(connection.fields.clientId),
|
|
377
|
+
Authorization: `Bearer ${connection.token?.access_token}`
|
|
378
|
+
});
|
|
379
|
+
return { data: {
|
|
380
|
+
data,
|
|
381
|
+
headers
|
|
382
|
+
} };
|
|
383
|
+
},
|
|
384
|
+
examplePayload: rawRequestExamplePayload
|
|
385
|
+
});
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region src/actions/index.ts
|
|
388
|
+
var actions_default = {
|
|
389
|
+
listCompanies,
|
|
390
|
+
listReportSuiteDimensions,
|
|
391
|
+
listReportSuiteMetrics,
|
|
392
|
+
getReportSuite: (0, _prismatic_io_spectral.action)({
|
|
393
|
+
display: {
|
|
394
|
+
label: "Get Report Suite",
|
|
395
|
+
description: "Retrieves a report suite by ID."
|
|
396
|
+
},
|
|
397
|
+
inputs: getReportSuiteInputs,
|
|
398
|
+
perform: async (context, params) => {
|
|
399
|
+
const { data } = await createClient(params.connection, context.debug.enabled).get(`/api/${params.globalCompanyId}/reportsuites/collections/suites/${params.reportSuiteId}`);
|
|
400
|
+
return { data };
|
|
401
|
+
},
|
|
402
|
+
examplePayload: getReportSuiteExamplePayload
|
|
403
|
+
}),
|
|
404
|
+
listReportSuites: (0, _prismatic_io_spectral.action)({
|
|
405
|
+
display: {
|
|
406
|
+
label: "List Report Suites",
|
|
407
|
+
description: "Retrieves a list of report suites."
|
|
408
|
+
},
|
|
409
|
+
inputs: listReportSuitesInputs,
|
|
410
|
+
perform: async (context, params) => {
|
|
411
|
+
const client = createClient(params.connection, context.debug.enabled);
|
|
412
|
+
let reportSuites = [];
|
|
413
|
+
let nextPage = false;
|
|
414
|
+
let page = 0;
|
|
415
|
+
do {
|
|
416
|
+
const { data } = await client.get(`/api/${params.globalCompanyId}/reportsuites/collections/suites`, { params: {
|
|
417
|
+
limit: 1e3,
|
|
418
|
+
page
|
|
419
|
+
} });
|
|
420
|
+
reportSuites = [...reportSuites, ...data.content];
|
|
421
|
+
nextPage = data.nextPage;
|
|
422
|
+
page += 1;
|
|
423
|
+
} while (nextPage);
|
|
424
|
+
return { data: reportSuites };
|
|
425
|
+
},
|
|
426
|
+
examplePayload: listReportSuitesExamplePayload
|
|
427
|
+
}),
|
|
428
|
+
listVirtualReportSuites: (0, _prismatic_io_spectral.action)({
|
|
429
|
+
display: {
|
|
430
|
+
label: "List Virtual Report Suites",
|
|
431
|
+
description: "Retrieves a list of virtual report suites."
|
|
432
|
+
},
|
|
433
|
+
inputs: listVirtualReportSuitesInputs,
|
|
434
|
+
perform: async (context, params) => {
|
|
435
|
+
const client = createClient(params.connection, context.debug.enabled);
|
|
436
|
+
let virtualReportSuites = [];
|
|
437
|
+
let nextPage = false;
|
|
438
|
+
let page = 0;
|
|
439
|
+
do {
|
|
440
|
+
const { data } = await client.get(`/api/${params.globalCompanyId}/reportsuites/virtualreportsuites`, { params: {
|
|
441
|
+
limit: 1e3,
|
|
442
|
+
page
|
|
443
|
+
} });
|
|
444
|
+
virtualReportSuites = [...virtualReportSuites, ...data.content];
|
|
445
|
+
nextPage = data.nextPage;
|
|
446
|
+
page += 1;
|
|
447
|
+
} while (nextPage);
|
|
448
|
+
return { data: virtualReportSuites };
|
|
449
|
+
},
|
|
450
|
+
examplePayload: listVirtualReportSuitesExamplePayload
|
|
451
|
+
}),
|
|
452
|
+
runReport: (0, _prismatic_io_spectral.action)({
|
|
453
|
+
display: {
|
|
454
|
+
label: "Run Report",
|
|
455
|
+
description: "Runs a report against a specified report suite."
|
|
456
|
+
},
|
|
457
|
+
inputs: runReportInputs,
|
|
458
|
+
perform: async (context, params) => {
|
|
459
|
+
const client = createClient(params.connection, context.debug.enabled);
|
|
460
|
+
const payload = {
|
|
461
|
+
rsid: params.reportSuiteId,
|
|
462
|
+
dimension: params.dimension,
|
|
463
|
+
...params.reportRequestBody
|
|
464
|
+
};
|
|
465
|
+
const { data } = await client.post(`/api/${params.globalCompanyId}/reports`, payload);
|
|
466
|
+
return { data };
|
|
467
|
+
},
|
|
468
|
+
examplePayload: runReportExamplePayload
|
|
469
|
+
}),
|
|
470
|
+
getCurrentUser: (0, _prismatic_io_spectral.action)({
|
|
471
|
+
display: {
|
|
472
|
+
label: "Get Current User",
|
|
473
|
+
description: "Retrieves the authenticated user and associated organizations and companies."
|
|
474
|
+
},
|
|
475
|
+
inputs: getCurrentUserInputs,
|
|
476
|
+
perform: async (context, params) => {
|
|
477
|
+
const { data } = await createClient(params.connection, context.debug.enabled).get("/discovery/me");
|
|
478
|
+
return { data };
|
|
479
|
+
},
|
|
480
|
+
examplePayload: getCurrentUserExamplePayload
|
|
481
|
+
}),
|
|
482
|
+
rawRequest
|
|
483
|
+
};
|
|
484
|
+
var connections_default = [(0, _prismatic_io_spectral.oauth2Connection)({
|
|
485
|
+
key: "adobeAnalyticsOauth",
|
|
486
|
+
display: {
|
|
487
|
+
label: "OAuth 2.0",
|
|
488
|
+
description: "Authenticate using OAuth 2.0."
|
|
489
|
+
},
|
|
490
|
+
oauth2Type: _prismatic_io_spectral.OAuth2Type.AuthorizationCode,
|
|
491
|
+
inputs: {
|
|
492
|
+
authorizeUrl: {
|
|
493
|
+
label: "Authorize URL",
|
|
494
|
+
placeholder: "Enter authorize URL",
|
|
495
|
+
type: "string",
|
|
496
|
+
required: true,
|
|
497
|
+
shown: true,
|
|
498
|
+
default: "https://ims-na1.adobelogin.com/ims/authorize/v2",
|
|
499
|
+
comments: "The OAuth 2.0 authorization URL for Adobe."
|
|
500
|
+
},
|
|
501
|
+
tokenUrl: {
|
|
502
|
+
label: "Token URL",
|
|
503
|
+
placeholder: "Enter token URL",
|
|
504
|
+
type: "string",
|
|
505
|
+
required: true,
|
|
506
|
+
shown: true,
|
|
507
|
+
default: "https://ims-na1.adobelogin.com/ims/token/v3",
|
|
508
|
+
comments: "The OAuth 2.0 token URL for Adobe."
|
|
509
|
+
},
|
|
510
|
+
scopes: {
|
|
511
|
+
label: "Scopes",
|
|
512
|
+
placeholder: "Enter scopes",
|
|
513
|
+
type: "string",
|
|
514
|
+
required: true,
|
|
515
|
+
shown: true,
|
|
516
|
+
comments: "The space-delimited OAuth scopes required for API access.",
|
|
517
|
+
default: "openid AdobeID read_organizations additional_info.projectedProductContext additional_info.job_function"
|
|
518
|
+
},
|
|
519
|
+
clientId: {
|
|
520
|
+
label: "Client ID",
|
|
521
|
+
placeholder: "Enter client ID",
|
|
522
|
+
type: "string",
|
|
523
|
+
required: true,
|
|
524
|
+
shown: true,
|
|
525
|
+
comments: "The client ID for the Adobe Developer Console project."
|
|
526
|
+
},
|
|
527
|
+
clientSecret: {
|
|
528
|
+
label: "Client Secret",
|
|
529
|
+
placeholder: "Enter client secret",
|
|
530
|
+
type: "password",
|
|
531
|
+
required: true,
|
|
532
|
+
shown: true,
|
|
533
|
+
comments: "The client secret for the Adobe Developer Console project."
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
})];
|
|
537
|
+
var companies_default = { selectCompany: (0, _prismatic_io_spectral.dataSource)({
|
|
538
|
+
display: {
|
|
539
|
+
label: "Select Company",
|
|
540
|
+
description: "Select a company from a picklist."
|
|
541
|
+
},
|
|
542
|
+
dataSourceType: "picklist",
|
|
543
|
+
inputs: selectCompanyInputs,
|
|
544
|
+
perform: async (_context, params) => {
|
|
545
|
+
const { data } = await createClient(params.connection, false).get("/discovery/me");
|
|
546
|
+
return { result: data.imsOrgs.flatMap((org) => org.companies).map((company) => ({
|
|
547
|
+
key: company.globalCompanyId,
|
|
548
|
+
label: company.companyName
|
|
549
|
+
})) };
|
|
550
|
+
}
|
|
551
|
+
}) };
|
|
552
|
+
var dimensions_default = { selectReportSuiteDimension: (0, _prismatic_io_spectral.dataSource)({
|
|
553
|
+
display: {
|
|
554
|
+
label: "Select Report Suite Dimension",
|
|
555
|
+
description: "Select a dimension from a picklist."
|
|
556
|
+
},
|
|
557
|
+
inputs: selectReportSuiteDimensionInputs,
|
|
558
|
+
dataSourceType: "picklist",
|
|
559
|
+
perform: async (_context, params) => {
|
|
560
|
+
const { data } = await createClient(params.connection, false).get(`https://analytics.adobe.io/api/${params.globalCompanyId}/dimensions`, { params: { rsid: params.reportSuiteId } });
|
|
561
|
+
return { result: data.map((dimension) => ({
|
|
562
|
+
key: dimension.id,
|
|
563
|
+
label: dimension.name
|
|
564
|
+
})).sort((a, b) => a.label < b.label ? -1 : 1) };
|
|
565
|
+
}
|
|
566
|
+
}) };
|
|
567
|
+
var metrics_default = { selectReportSuiteMetric: (0, _prismatic_io_spectral.dataSource)({
|
|
568
|
+
display: {
|
|
569
|
+
label: "Select Report Suite Metric",
|
|
570
|
+
description: "Select a metric from a picklist."
|
|
571
|
+
},
|
|
572
|
+
inputs: selectReportSuiteMetricInputs,
|
|
573
|
+
dataSourceType: "picklist",
|
|
574
|
+
perform: async (_context, params) => {
|
|
575
|
+
const { data } = await createClient(params.connection, false).get(`https://analytics.adobe.io/api/${params.globalCompanyId}/metrics`, { params: { rsid: params.reportSuiteId } });
|
|
576
|
+
return { result: data.map((metric) => ({
|
|
577
|
+
key: metric.id,
|
|
578
|
+
label: metric.name
|
|
579
|
+
})).sort((a, b) => a.label < b.label ? -1 : 1) };
|
|
580
|
+
}
|
|
581
|
+
}) };
|
|
582
|
+
var reportSuites_default = {
|
|
583
|
+
selectReportSuite: (0, _prismatic_io_spectral.dataSource)({
|
|
584
|
+
display: {
|
|
585
|
+
label: "Select Report Suite",
|
|
586
|
+
description: "Select a report suite from a picklist."
|
|
587
|
+
},
|
|
588
|
+
inputs: selectReportSuiteInputs,
|
|
589
|
+
dataSourceType: "picklist",
|
|
590
|
+
perform: async (_context, params) => {
|
|
591
|
+
const client = createClient(params.connection, false);
|
|
592
|
+
let reportSuites = [];
|
|
593
|
+
let nextPage = false;
|
|
594
|
+
let page = 0;
|
|
595
|
+
do {
|
|
596
|
+
const { data } = await client.get(`/api/${params.globalCompanyId}/reportsuites/collections/suites`, { params: {
|
|
597
|
+
limit: 1e3,
|
|
598
|
+
page
|
|
599
|
+
} });
|
|
600
|
+
reportSuites = [...reportSuites, ...data.content];
|
|
601
|
+
nextPage = data.nextPage;
|
|
602
|
+
page += 1;
|
|
603
|
+
} while (nextPage);
|
|
604
|
+
return { result: reportSuites.map((reportSuite) => ({
|
|
605
|
+
key: reportSuite.id,
|
|
606
|
+
label: reportSuite.name
|
|
607
|
+
})) };
|
|
608
|
+
}
|
|
609
|
+
}),
|
|
610
|
+
selectVirtualReportSuite: (0, _prismatic_io_spectral.dataSource)({
|
|
611
|
+
display: {
|
|
612
|
+
label: "Select Virtual Report Suite",
|
|
613
|
+
description: "Select a virtual report suite from a picklist."
|
|
614
|
+
},
|
|
615
|
+
inputs: selectVirtualReportSuiteInputs,
|
|
616
|
+
dataSourceType: "picklist",
|
|
617
|
+
perform: async (_context, params) => {
|
|
618
|
+
const client = createClient(params.connection, false);
|
|
619
|
+
let reportSuites = [];
|
|
620
|
+
let nextPage = false;
|
|
621
|
+
let page = 0;
|
|
622
|
+
do {
|
|
623
|
+
const { data } = await client.get(`/api/${params.globalCompanyId}/reportsuites/virtualreportsuites`, { params: {
|
|
624
|
+
limit: 1e3,
|
|
625
|
+
page
|
|
626
|
+
} });
|
|
627
|
+
reportSuites = [...reportSuites, ...data.content];
|
|
628
|
+
nextPage = data.nextPage;
|
|
629
|
+
page += 1;
|
|
630
|
+
} while (nextPage);
|
|
631
|
+
return { result: reportSuites.map((reportSuite) => ({
|
|
632
|
+
key: reportSuite.id,
|
|
633
|
+
label: reportSuite.name
|
|
634
|
+
})) };
|
|
635
|
+
}
|
|
636
|
+
})
|
|
637
|
+
};
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/dataSources/index.ts
|
|
640
|
+
var dataSources_default = {
|
|
641
|
+
...companies_default,
|
|
642
|
+
...dimensions_default,
|
|
643
|
+
...metrics_default,
|
|
644
|
+
...reportSuites_default
|
|
645
|
+
};
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/util.ts
|
|
648
|
+
const resolvePollingRecordChanges = (data) => {
|
|
649
|
+
const changesObject = data ?? {};
|
|
650
|
+
return [...(changesObject.created ?? []).map((record) => ({
|
|
651
|
+
changeType: "created",
|
|
652
|
+
record
|
|
653
|
+
})), ...(changesObject.updated ?? []).map((record) => ({
|
|
654
|
+
changeType: "updated",
|
|
655
|
+
record
|
|
656
|
+
}))];
|
|
657
|
+
};
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region src/triggers/pollChangesTrigger.ts
|
|
660
|
+
const getRecordId = (record, resourceType) => {
|
|
661
|
+
if (resourceType === PollResource.REPORT_SUITES) return record.rsid ?? record.id ?? "";
|
|
662
|
+
return record.globalCompanyId ?? record.id ?? "";
|
|
663
|
+
};
|
|
664
|
+
//#endregion
|
|
665
|
+
//#region src/triggers/index.ts
|
|
666
|
+
var triggers_default = { pollChangesTrigger: (0, _prismatic_io_spectral.pollingTrigger)({
|
|
667
|
+
display: {
|
|
668
|
+
label: "New Records",
|
|
669
|
+
description: "Checks for new report suites or companies in Adobe Analytics on a configured schedule."
|
|
670
|
+
},
|
|
671
|
+
inputs: pollChangesTriggerInputs,
|
|
672
|
+
triggerResolverSupport: "valid",
|
|
673
|
+
batchConfig: { batchSize: 50 },
|
|
674
|
+
triggerResolver: { resolveItems: (_context, { payload }) => resolvePollingRecordChanges(payload.body.data) },
|
|
675
|
+
perform: async (context, payload, { connection, globalCompanyId, resourceType, showNewRecords }) => {
|
|
676
|
+
const client = createClient(connection, context.debug.enabled);
|
|
677
|
+
const lastState = context.polling.getState();
|
|
678
|
+
let records;
|
|
679
|
+
if (resourceType === PollResource.REPORT_SUITES) {
|
|
680
|
+
if (!globalCompanyId) throw new Error("Global Company ID is required when polling report suites.");
|
|
681
|
+
let reportSuites = [];
|
|
682
|
+
let nextPage = false;
|
|
683
|
+
let page = 0;
|
|
684
|
+
do {
|
|
685
|
+
const { data } = await client.get(`/api/${globalCompanyId}/reportsuites/collections/suites`, { params: {
|
|
686
|
+
limit: 1e3,
|
|
687
|
+
page
|
|
688
|
+
} });
|
|
689
|
+
reportSuites = [...reportSuites, ...data.content];
|
|
690
|
+
nextPage = data.nextPage;
|
|
691
|
+
page += 1;
|
|
692
|
+
} while (nextPage);
|
|
693
|
+
records = reportSuites;
|
|
694
|
+
} else {
|
|
695
|
+
const { data } = await client.get("/discovery/me");
|
|
696
|
+
records = data.imsOrgs.flatMap((org) => org.companies);
|
|
697
|
+
}
|
|
698
|
+
const currentIds = records.map((r) => getRecordId(r, resourceType));
|
|
699
|
+
if (lastState?.knownIds === void 0) {
|
|
700
|
+
context.polling.setState({ knownIds: currentIds });
|
|
701
|
+
return {
|
|
702
|
+
payload: {
|
|
703
|
+
...payload,
|
|
704
|
+
body: { data: {
|
|
705
|
+
created: [],
|
|
706
|
+
updated: []
|
|
707
|
+
} }
|
|
708
|
+
},
|
|
709
|
+
polledNoChanges: true
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
const knownSet = new Set(lastState.knownIds);
|
|
713
|
+
const created = records.filter((r) => !knownSet.has(getRecordId(r, resourceType)));
|
|
714
|
+
context.polling.setState({ knownIds: currentIds });
|
|
715
|
+
const filteredCreated = showNewRecords ? created : [];
|
|
716
|
+
if (context.debug.enabled) context.logger.debug(`Polled ${resourceType}: ${records.length} total, ${filteredCreated.length} new`);
|
|
717
|
+
return {
|
|
718
|
+
payload: {
|
|
719
|
+
...payload,
|
|
720
|
+
body: { data: {
|
|
721
|
+
created: filteredCreated,
|
|
722
|
+
updated: []
|
|
723
|
+
} }
|
|
724
|
+
},
|
|
725
|
+
polledNoChanges: filteredCreated.length === 0
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
}) };
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region src/index.ts
|
|
731
|
+
var src_default = (0, _prismatic_io_spectral.component)({
|
|
732
|
+
key: "adobe-analytics",
|
|
733
|
+
public: true,
|
|
734
|
+
documentationUrl: "https://prismatic.io/docs/components/adobe-analytics/",
|
|
735
|
+
display: {
|
|
736
|
+
category: "Application Connectors",
|
|
737
|
+
label: "Adobe Analytics",
|
|
738
|
+
description: "Manage companies, report suites, metrics, dimensions and more within Adobe Analytics.",
|
|
739
|
+
iconPath: "icon.png"
|
|
740
|
+
},
|
|
741
|
+
actions: actions_default,
|
|
742
|
+
triggers: triggers_default,
|
|
743
|
+
connections: connections_default,
|
|
744
|
+
dataSources: dataSources_default,
|
|
745
|
+
hooks: { error: _prismatic_io_spectral_http.handleErrors }
|
|
746
|
+
});
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region npm-dist/.entry.ts
|
|
749
|
+
var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
|
|
750
|
+
//#endregion
|
|
751
|
+
module.exports = _entry_default;
|