@adobe/spacecat-shared-rum-api-client 2.37.8 → 2.38.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/CHANGELOG.md +14 -0
- package/README.md +22 -0
- package/package.json +2 -2
- package/src/functions/user-engagement.js +60 -0
- package/src/index.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-rum-api-client-v2.38.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.38.0...@adobe/spacecat-shared-rum-api-client-v2.38.1) (2025-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/rum-distiller to v1.20.0 ([#1013](https://github.com/adobe/spacecat-shared/issues/1013)) ([1a18158](https://github.com/adobe/spacecat-shared/commit/1a1815832eb6a27dbb9b879626b52d2a86e6d56f)), closes [#8203](https://github.com/adobe/spacecat-shared/issues/8203)
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-rum-api-client-v2.38.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.37.8...@adobe/spacecat-shared-rum-api-client-v2.38.0) (2025-10-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add query for fetching RUM engagement metrics ([#985](https://github.com/adobe/spacecat-shared/issues/985)) ([0eb8881](https://github.com/adobe/spacecat-shared/commit/0eb88818af000076ea663b2e08ab1fb2b1957510))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-rum-api-client-v2.37.8](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.37.7...@adobe/spacecat-shared-rum-api-client-v2.37.8) (2025-10-07)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -437,6 +437,28 @@ An example response:
|
|
|
437
437
|
]
|
|
438
438
|
```
|
|
439
439
|
|
|
440
|
+
### User engagement
|
|
441
|
+
|
|
442
|
+
Calculates user engagement metrics for all pages from RUM data. A page view is considered engaged if there has been at least some user interaction (click events) or significant content has been viewed (4 or more viewmedia or viewblock events).
|
|
443
|
+
Ref. - https://github.com/adobe/rum-distiller/blob/22f8b3caa6d700f4d1cbe29a94b7da34b9d50764/series.js#L89
|
|
444
|
+
|
|
445
|
+
An example response:
|
|
446
|
+
|
|
447
|
+
```json
|
|
448
|
+
[
|
|
449
|
+
{
|
|
450
|
+
"url": "https://www.example.com/home",
|
|
451
|
+
"totalTraffic": 5000,
|
|
452
|
+
"engagementPercentage": 50
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"url": "https://www.example.com/about",
|
|
456
|
+
"totalTraffic": 2000,
|
|
457
|
+
"engagementPercentage": 40
|
|
458
|
+
}
|
|
459
|
+
]
|
|
460
|
+
```
|
|
461
|
+
|
|
440
462
|
## Linting
|
|
441
463
|
Lint the codebase using:
|
|
442
464
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-rum-api-client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.38.1",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Rum API client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@adobe/fetch": "4.2.3",
|
|
39
39
|
"@adobe/helix-shared-wrap": "2.0.2",
|
|
40
40
|
"@adobe/helix-universal": "5.2.3",
|
|
41
|
-
"@adobe/rum-distiller": "1.
|
|
41
|
+
"@adobe/rum-distiller": "1.20.0",
|
|
42
42
|
"@adobe/spacecat-shared-utils": "1.48.0",
|
|
43
43
|
"aws4": "1.13.2",
|
|
44
44
|
"urijs": "1.19.11"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const evaluateEngagement = (bundle) => {
|
|
14
|
+
const clickEngagement = bundle.events.filter((evt) => evt.checkpoint === 'click').length > 0
|
|
15
|
+
? bundle.weight
|
|
16
|
+
: 0;
|
|
17
|
+
const contentEngagement = bundle.events
|
|
18
|
+
.filter((evt) => evt.checkpoint === 'viewmedia' || evt.checkpoint === 'viewblock')
|
|
19
|
+
.length > 3
|
|
20
|
+
? bundle.weight
|
|
21
|
+
: 0;
|
|
22
|
+
return clickEngagement || contentEngagement;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Calculates engagement metrics for all pages from RUM data.
|
|
27
|
+
* A page view is considered engaged if there has been at least some user interaction (click events)
|
|
28
|
+
* or significant content has been viewed (4 or more viewmedia or viewblock events).
|
|
29
|
+
* Ref. - https://github.com/adobe/rum-distiller/blob/22f8b3caa6d700f4d1cbe29a94b7da34b9d50764/series.js#L89
|
|
30
|
+
*
|
|
31
|
+
* @param {Array} bundles - The RUM bundles to calculate engagement metrics for.
|
|
32
|
+
* @returns {Array} An array of engagement metrics for each page.
|
|
33
|
+
*/
|
|
34
|
+
function handler(bundles) {
|
|
35
|
+
const urlsData = {};
|
|
36
|
+
bundles.forEach((bundle) => {
|
|
37
|
+
const engagementTraffic = evaluateEngagement(bundle);
|
|
38
|
+
if (!urlsData[bundle.url]) {
|
|
39
|
+
urlsData[bundle.url] = {
|
|
40
|
+
url: bundle.url,
|
|
41
|
+
totalTraffic: bundle.weight,
|
|
42
|
+
engagementTraffic,
|
|
43
|
+
engagementPercentage: (engagementTraffic / bundle.weight) * 100,
|
|
44
|
+
};
|
|
45
|
+
} else {
|
|
46
|
+
urlsData[bundle.url].totalTraffic += bundle.weight;
|
|
47
|
+
urlsData[bundle.url].engagementTraffic += engagementTraffic;
|
|
48
|
+
urlsData[bundle.url].engagementPercentage = Math.round(
|
|
49
|
+
(urlsData[bundle.url].engagementTraffic / urlsData[bundle.url].totalTraffic) * 100,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return Object.values(urlsData);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
handler,
|
|
59
|
+
checkpoints: ['click', 'viewmedia', 'viewblock'],
|
|
60
|
+
};
|
package/src/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import highOrganicLowCtr from './functions/opportunities/high-organic-low-ctr.js
|
|
|
27
27
|
import trafficAnalysis from './functions/traffic-analysis.js';
|
|
28
28
|
import optimizationReportMetrics from './functions/reports/optimization/metrics.js';
|
|
29
29
|
import optimizationReportGraph from './functions/reports/optimization/graph.js';
|
|
30
|
+
import userEngagement from './functions/user-engagement.js';
|
|
30
31
|
|
|
31
32
|
// exported for tests
|
|
32
33
|
export const RUM_BUNDLER_API_HOST = 'https://bundles.aem.page';
|
|
@@ -48,6 +49,7 @@ const HANDLERS = {
|
|
|
48
49
|
'traffic-analysis': trafficAnalysis,
|
|
49
50
|
'optimization-report-metrics': optimizationReportMetrics,
|
|
50
51
|
'optimization-report-graph': optimizationReportGraph,
|
|
52
|
+
'user-engagement': userEngagement,
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
function sanitize(opts) {
|