@adobe/spacecat-shared-rum-api-client 2.15.7 → 2.16.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-rum-api-client-v2.16.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.15.7...@adobe/spacecat-shared-rum-api-client-v2.16.0) (2024-12-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * support site metrics overview ([99a7c66](https://github.com/adobe/spacecat-shared/commit/99a7c66f18ff1ba869ffdb07b17b9505d1f00069))
7
+
1
8
  # [@adobe/spacecat-shared-rum-api-client-v2.15.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.15.6...@adobe/spacecat-shared-rum-api-client-v2.15.7) (2024-12-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-rum-api-client",
3
- "version": "2.15.7",
3
+ "version": "2.16.0",
4
4
  "description": "Shared modules of the Spacecat Services - Rum API client",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=20.0.0 <23.0.0",
8
- "npm": ">=10.0.0 <11.0.0"
8
+ "npm": ">=10.0.0 <12.0.0"
9
9
  },
10
10
  "main": "src/index.js",
11
11
  "types": "src/index.d.ts",
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright 2024 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
+ import { DataChunks, series } from '@adobe/rum-distiller';
14
+ import { loadBundles } from '../utils.js';
15
+
16
+ function handler(bundles) {
17
+ const dataChunks = new DataChunks();
18
+ loadBundles(bundles, dataChunks);
19
+ dataChunks.addSeries('traffic_domain', series.pageViews);
20
+ dataChunks.addSeries('ctr', (bundle) => (bundle.events.some((e) => e.checkpoint === 'click')
21
+ ? bundle.weight
22
+ : 0));
23
+ const totalPageViews = dataChunks?.totals?.traffic_domain?.weight;
24
+ const sum = dataChunks?.totals?.ctr?.sum ?? 0;
25
+ const weight = dataChunks?.totals?.ctr?.weight ?? 0;
26
+ const totalCTR = weight !== 0 ? sum / weight : 0;
27
+ return {
28
+ totalPageViews,
29
+ totalCTR,
30
+ };
31
+ }
32
+
33
+ export default {
34
+ handler,
35
+ checkpoints: ['click'],
36
+ };
package/src/index.js CHANGED
@@ -16,6 +16,7 @@ import cwv from './functions/cwv.js';
16
16
  import formVitals from './functions/form-vitals.js';
17
17
  import experiment from './functions/experiment.js';
18
18
  import trafficAcquisition from './functions/traffic-acquisition.js';
19
+ import totalMetrics from './functions/total-metrics.js';
19
20
  import variant from './functions/variant.js';
20
21
  import rageclick from './functions/opportunities/rageclick.js';
21
22
  import highInorganicHighBounceRate from './functions/opportunities/high-inorganic-high-bounce-rate.js';
@@ -30,6 +31,7 @@ const HANDLERS = {
30
31
  'traffic-acquisition': trafficAcquisition,
31
32
  variant,
32
33
  rageclick,
34
+ totalMetrics,
33
35
  'high-inorganic-high-bounce-rate': highInorganicHighBounceRate,
34
36
  'high-organic-low-ctr': highOrganicLowCtr,
35
37
  };