@adobe/helix-rum-enhancer 2.6.0 → 2.7.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/package.json +1 -1
- package/src/index.js +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.7.1](https://github.com/adobe/helix-rum-enhancer/compare/v2.7.0...v2.7.1) (2024-04-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* make targetselector null safe ([#156](https://github.com/adobe/helix-rum-enhancer/issues/156)) ([691d40d](https://github.com/adobe/helix-rum-enhancer/commit/691d40d1659d6aaac81f4037e11c243341181b80))
|
|
7
|
+
|
|
8
|
+
# [2.7.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.6.0...v2.7.0) (2024-04-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add logic to capture target from wrapping anchor tag ([2a733b3](https://github.com/adobe/helix-rum-enhancer/commit/2a733b307d00c1a0613f645a01e325e683734625))
|
|
14
|
+
|
|
1
15
|
# [2.6.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.5.0...v2.6.0) (2024-04-16)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
/* eslint-env browser */
|
|
13
13
|
const KNOWN_PROPERTIES = ['weight', 'id', 'referer', 'checkpoint', 't', 'source', 'target', 'cwv', 'CLS', 'FID', 'LCP', 'INP', 'TTFB'];
|
|
14
14
|
const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource', 'utm'];
|
|
15
|
-
const SESSION_STORAGE_KEY = 'aem-rum';
|
|
16
15
|
const { sampleRUM, queue, isSelected } = window.hlx.rum;
|
|
17
16
|
|
|
18
17
|
const urlSanitizers = {
|
|
@@ -21,9 +20,15 @@ const urlSanitizers = {
|
|
|
21
20
|
path: () => window.location.href.replace(/\?.*$/, ''),
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
const
|
|
25
|
-
let value = element.getAttribute('data-rum-target') || element.getAttribute('href')
|
|
23
|
+
const getTargetValue = (element) => element.getAttribute('data-rum-target') || element.getAttribute('href')
|
|
26
24
|
|| element.currentSrc || element.getAttribute('src') || element.dataset.action || element.action;
|
|
25
|
+
|
|
26
|
+
const targetselector = (element) => {
|
|
27
|
+
if (!element) return undefined;
|
|
28
|
+
let value = getTargetValue(element);
|
|
29
|
+
if (!value && element.tagName !== 'A' && element.closest('a')) {
|
|
30
|
+
value = getTargetValue(element.closest('a'));
|
|
31
|
+
}
|
|
27
32
|
if (value && !value.startsWith('https://')) {
|
|
28
33
|
// resolve relative links
|
|
29
34
|
value = new URL(value, window.location).href;
|
|
@@ -113,8 +118,8 @@ function addCWVTracking() {
|
|
|
113
118
|
data.cwv[measurement.name] = measurement.value;
|
|
114
119
|
if (measurement.name === 'LCP' && measurement.entries.length > 0) {
|
|
115
120
|
const { element } = measurement.entries.pop();
|
|
116
|
-
data.target =
|
|
117
|
-
data.source =
|
|
121
|
+
data.target = targetselector(element);
|
|
122
|
+
data.source = sourceselector(element) || element.outerHTML.slice(0, 30);
|
|
118
123
|
}
|
|
119
124
|
sampleRUM('cwv', data);
|
|
120
125
|
};
|
|
@@ -286,9 +291,6 @@ function addTrackingFromConfig() {
|
|
|
286
291
|
}
|
|
287
292
|
|
|
288
293
|
function initEnhancer() {
|
|
289
|
-
// eslint-disable-next-line max-len
|
|
290
|
-
const rumStorage = sessionStorage.getItem(SESSION_STORAGE_KEY) ? JSON.parse(sessionStorage.getItem(SESSION_STORAGE_KEY)) : {};
|
|
291
|
-
sampleRUM('pagesviewed', { source: rumStorage.pages });
|
|
292
294
|
addTrackingFromConfig();
|
|
293
295
|
window.hlx.rum.collector = trackCheckpoint;
|
|
294
296
|
processQueue();
|