@adobe/spacecat-shared-rum-api-client 2.15.6 → 2.15.7

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.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
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @adobe/rum-distiller to v1.13.1 ([#495](https://github.com/adobe/spacecat-shared/issues/495)) ([5f50c2f](https://github.com/adobe/spacecat-shared/commit/5f50c2f2757cbe0c6ec7d46c919b97c0b2ae7193)), closes [#8203](https://github.com/adobe/spacecat-shared/issues/8203)
7
+
1
8
  # [@adobe/spacecat-shared-rum-api-client-v2.15.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.15.5...@adobe/spacecat-shared-rum-api-client-v2.15.6) (2024-12-09)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-rum-api-client",
3
- "version": "2.15.6",
3
+ "version": "2.15.7",
4
4
  "description": "Shared modules of the Spacecat Services - Rum API client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -39,7 +39,7 @@
39
39
  "@adobe/helix-shared-wrap": "2.0.2",
40
40
  "@adobe/helix-universal": "5.0.8",
41
41
  "@adobe/spacecat-shared-utils": "1.22.4",
42
- "@adobe/rum-distiller": "1.13.0",
42
+ "@adobe/rum-distiller": "1.13.1",
43
43
  "aws4": "1.13.2",
44
44
  "urijs": "^1.19.11"
45
45
  },
@@ -0,0 +1,62 @@
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 { DELIMITER, generateKey, loadBundles } from '../utils.js';
15
+ /**
16
+ * Processes RUM data to identify broken internal links associated views.
17
+ * Uses the 404 and navigate checkpoints to identify broken internal links.
18
+ * The handler function:
19
+ * 1. Loads RUM bundles into data chunks
20
+ * 2. Groups data by unique URL combinations (404 target URL + source URL)
21
+ * 3. Calculates pageviews for each broken link. Duplicate combinations will have
22
+ * their views summed.
23
+ * 4. Returns array of broken link objects with:
24
+ * - url_to: The 404 target URL that is broken
25
+ * - url_from: The source URL containing the broken link
26
+ * - traffic_domain: Number of pageviews to the broken URL
27
+ * @param {Array} bundles - Array of RUM data bundles
28
+ * @returns {Array} Array of broken internal link objects with views
29
+ */
30
+
31
+ function handler(bundles) {
32
+ const dataChunks = new DataChunks();
33
+ loadBundles(bundles, dataChunks);
34
+
35
+ // groups by combination of url and 404 source
36
+ dataChunks.addFacet('uniqueUrlCombinations', (bundle) => {
37
+ const eventNavigate = bundle.events.find((e) => e.checkpoint === 'navigate');
38
+ const event404 = bundle.events.find((e) => e.checkpoint === '404');
39
+ if (eventNavigate && event404) {
40
+ return generateKey(bundle.url, event404.source);
41
+ }
42
+ return undefined;
43
+ });
44
+
45
+ // counts pageviews per each group
46
+ dataChunks.addSeries('traffic_domain', series.pageViews);
47
+
48
+ return dataChunks.facets.uniqueUrlCombinations.map((facet) => {
49
+ const [urlTo, urlFrom] = facet.value.split(DELIMITER);
50
+
51
+ return {
52
+ traffic_domain: facet.metrics.traffic_domain.sum,
53
+ url_to: urlTo,
54
+ url_from: urlFrom,
55
+ };
56
+ });
57
+ }
58
+
59
+ export default {
60
+ handler,
61
+ checkpoints: ['404', 'navigate'],
62
+ };
package/src/index.js CHANGED
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import { fetchBundles } from './common/rum-bundler-client.js';
13
13
  import notfound from './functions/404.js';
14
+ import notfoundInternalLinks from './functions/404-internal-links.js';
14
15
  import cwv from './functions/cwv.js';
15
16
  import formVitals from './functions/form-vitals.js';
16
17
  import experiment from './functions/experiment.js';
@@ -22,6 +23,7 @@ import highOrganicLowCtr from './functions/opportunities/high-organic-low-ctr.js
22
23
 
23
24
  const HANDLERS = {
24
25
  404: notfound,
26
+ '404-internal-links': notfoundInternalLinks,
25
27
  cwv,
26
28
  'form-vitals': formVitals,
27
29
  experiment,