@adobe/spacecat-shared-rum-api-client 2.17.2 → 2.18.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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-rum-api-client-v2.18.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.17.2...@adobe/spacecat-shared-rum-api-client-v2.18.0) (2025-01-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **rum-api-client:** log fetches bundles length ([#530](https://github.com/adobe/spacecat-shared/issues/530)) ([b7011d9](https://github.com/adobe/spacecat-shared/commit/b7011d99da894fe340d4abcd26aec64c0faeb1c5))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-rum-api-client-v2.17.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.17.1...@adobe/spacecat-shared-rum-api-client-v2.17.2) (2024-12-31)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -38,13 +38,19 @@ const HANDLERS = {
|
|
|
38
38
|
|
|
39
39
|
export default class RUMAPIClient {
|
|
40
40
|
static createFrom(context) {
|
|
41
|
+
const { log = console } = context;
|
|
42
|
+
|
|
41
43
|
if (context.rumApiClient) return context.rumApiClient;
|
|
42
44
|
|
|
43
|
-
const client = new RUMAPIClient();
|
|
45
|
+
const client = new RUMAPIClient(log);
|
|
44
46
|
context.rumApiClient = client;
|
|
45
47
|
return client;
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
constructor(log) {
|
|
51
|
+
this.log = log;
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
// eslint-disable-next-line class-methods-use-this
|
|
49
55
|
async query(query, opts) {
|
|
50
56
|
const { handler, checkpoints } = HANDLERS[query] || {};
|
|
@@ -56,6 +62,8 @@ export default class RUMAPIClient {
|
|
|
56
62
|
checkpoints,
|
|
57
63
|
});
|
|
58
64
|
|
|
65
|
+
this.log.info(`Query "${query}" fetched ${bundles.length} bundles`);
|
|
66
|
+
|
|
59
67
|
return handler(bundles, opts);
|
|
60
68
|
} catch (e) {
|
|
61
69
|
throw new Error(`Query '${query}' failed. Opts: ${JSON.stringify(opts)}. Reason: ${e.message}`);
|
|
@@ -87,6 +95,8 @@ export default class RUMAPIClient {
|
|
|
87
95
|
|
|
88
96
|
const results = {};
|
|
89
97
|
|
|
98
|
+
this.log.info(`Multi query ${JSON.stringify(queries.join(', '))} fetched ${bundles.length} bundles`);
|
|
99
|
+
|
|
90
100
|
// Execute each query handler sequentially
|
|
91
101
|
for (const { query, handler } of queryHandlers) {
|
|
92
102
|
// eslint-disable-next-line no-await-in-loop
|