@adobe/spacecat-shared-rum-api-client 2.43.0 → 2.44.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 +12 -0
- package/package.json +1 -1
- package/src/client.js +12 -4
- package/src/functions/total-metrics.js +26 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [@adobe/spacecat-shared-rum-api-client-v2.44.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.43.1...@adobe/spacecat-shared-rum-api-client-v2.44.0) (2026-06-26)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **rum:** scope latest-metrics RUM to locale path prefix ([#1707](https://github.com/adobe/spacecat-shared/issues/1707)) ([77cdb33](https://github.com/adobe/spacecat-shared/commit/77cdb33d7f55a9bff795b768621ec70830b2cba3))
|
|
6
|
+
|
|
7
|
+
## [@adobe/spacecat-shared-rum-api-client-v2.43.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.43.0...@adobe/spacecat-shared-rum-api-client-v2.43.1) (2026-06-15)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* downgrade expected RUM domainkey 404s from error to debug ([#1678](https://github.com/adobe/spacecat-shared/issues/1678)) ([86c7fdd](https://github.com/adobe/spacecat-shared/commit/86c7fdd5333e8c40b45f7375bc4321e6c36135de))
|
|
12
|
+
|
|
1
13
|
## [@adobe/spacecat-shared-rum-api-client-v2.43.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.42.0...@adobe/spacecat-shared-rum-api-client-v2.43.0) (2026-06-15)
|
|
2
14
|
|
|
3
15
|
### Features
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -92,7 +92,9 @@ export default class RUMAPIClient {
|
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
if (!resp.ok) {
|
|
95
|
-
|
|
95
|
+
const error = new Error(`Error during fetching domainkey for domain '${domain} using admin key. Status: ${resp.status}`);
|
|
96
|
+
error.status = resp.status;
|
|
97
|
+
throw error;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
try {
|
|
@@ -143,7 +145,9 @@ export default class RUMAPIClient {
|
|
|
143
145
|
this.log.debug(`Query "${query}" fetched ${bundles.length} bundles`); // maybe even remove?
|
|
144
146
|
return handler(bundles, opts);
|
|
145
147
|
} catch (e) {
|
|
146
|
-
|
|
148
|
+
const error = new Error(`Query '${query}' failed. Opts: ${JSON.stringify(sanitize(opts))}. Reason: ${e.message}`, { cause: e });
|
|
149
|
+
error.status = e.status;
|
|
150
|
+
throw error;
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
|
|
@@ -184,7 +188,9 @@ export default class RUMAPIClient {
|
|
|
184
188
|
|
|
185
189
|
return results;
|
|
186
190
|
} catch (e) {
|
|
187
|
-
|
|
191
|
+
const error = new Error(`Multi query failed. Queries: ${JSON.stringify(queries)}, Opts: ${JSON.stringify(sanitize(opts))}. Reason: ${e.message}`, { cause: e });
|
|
192
|
+
error.status = e.status;
|
|
193
|
+
throw error;
|
|
188
194
|
}
|
|
189
195
|
}
|
|
190
196
|
|
|
@@ -203,7 +209,9 @@ export default class RUMAPIClient {
|
|
|
203
209
|
handler,
|
|
204
210
|
}, this.log);
|
|
205
211
|
} catch (e) {
|
|
206
|
-
|
|
212
|
+
const error = new Error(`Query stream '${query}' failed. Opts: ${JSON.stringify(sanitize(opts))}. Reason: ${e.message}`, { cause: e });
|
|
213
|
+
error.status = e.status;
|
|
214
|
+
throw error;
|
|
207
215
|
}
|
|
208
216
|
}
|
|
209
217
|
}
|
|
@@ -13,9 +13,33 @@
|
|
|
13
13
|
import { DataChunks, series } from '@adobe/rum-distiller';
|
|
14
14
|
import { loadBundles } from '../utils.js';
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Checks whether a bundle URL falls under a given path prefix.
|
|
18
|
+
* Boundary-safe: prefix '/de' matches '/de' and '/de/...' but NOT '/design'.
|
|
19
|
+
* @param {string} url - Bundle URL.
|
|
20
|
+
* @param {string} prefix - Normalized path prefix (e.g. '/de').
|
|
21
|
+
* @returns {boolean} True if the URL's path is at or under the prefix.
|
|
22
|
+
*/
|
|
23
|
+
function matchesPathPrefix(url, prefix) {
|
|
24
|
+
try {
|
|
25
|
+
const { pathname } = new URL(url);
|
|
26
|
+
const path = pathname !== '/' ? pathname.replace(/\/+$/, '') : '/';
|
|
27
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function handler(bundles, opts = {}) {
|
|
34
|
+
// Locale-specific sites (e.g. https://example.com/de) have no domain key of their
|
|
35
|
+
// own — RUM is fetched for the main domain, then narrowed to the locale subtree here.
|
|
36
|
+
const { pathPrefix } = opts;
|
|
37
|
+
const scopedBundles = pathPrefix
|
|
38
|
+
? bundles.filter((b) => b?.url && matchesPathPrefix(b.url, pathPrefix))
|
|
39
|
+
: bundles;
|
|
40
|
+
|
|
17
41
|
const dataChunks = new DataChunks();
|
|
18
|
-
loadBundles(
|
|
42
|
+
loadBundles(scopedBundles, dataChunks);
|
|
19
43
|
dataChunks.addSeries('traffic_domain', series.pageViews);
|
|
20
44
|
dataChunks.addSeries('clicks', (bundle) => (bundle.events.some((e) => e.checkpoint === 'click')
|
|
21
45
|
? bundle.weight
|