@adobe/helix-rum-enhancer 2.7.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 +7 -0
- package/package.json +1 -1
- package/src/index.js +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
# [2.7.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.6.0...v2.7.0) (2024-04-18)
|
|
2
9
|
|
|
3
10
|
|
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 = {
|
|
@@ -25,6 +24,7 @@ const getTargetValue = (element) => element.getAttribute('data-rum-target') || e
|
|
|
25
24
|
|| element.currentSrc || element.getAttribute('src') || element.dataset.action || element.action;
|
|
26
25
|
|
|
27
26
|
const targetselector = (element) => {
|
|
27
|
+
if (!element) return undefined;
|
|
28
28
|
let value = getTargetValue(element);
|
|
29
29
|
if (!value && element.tagName !== 'A' && element.closest('a')) {
|
|
30
30
|
value = getTargetValue(element.closest('a'));
|
|
@@ -118,8 +118,8 @@ function addCWVTracking() {
|
|
|
118
118
|
data.cwv[measurement.name] = measurement.value;
|
|
119
119
|
if (measurement.name === 'LCP' && measurement.entries.length > 0) {
|
|
120
120
|
const { element } = measurement.entries.pop();
|
|
121
|
-
data.target =
|
|
122
|
-
data.source =
|
|
121
|
+
data.target = targetselector(element);
|
|
122
|
+
data.source = sourceselector(element) || element.outerHTML.slice(0, 30);
|
|
123
123
|
}
|
|
124
124
|
sampleRUM('cwv', data);
|
|
125
125
|
};
|
|
@@ -291,9 +291,6 @@ function addTrackingFromConfig() {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
function initEnhancer() {
|
|
294
|
-
// eslint-disable-next-line max-len
|
|
295
|
-
const rumStorage = sessionStorage.getItem(SESSION_STORAGE_KEY) ? JSON.parse(sessionStorage.getItem(SESSION_STORAGE_KEY)) : {};
|
|
296
|
-
sampleRUM('pagesviewed', { source: rumStorage.pages });
|
|
297
294
|
addTrackingFromConfig();
|
|
298
295
|
window.hlx.rum.collector = trackCheckpoint;
|
|
299
296
|
processQueue();
|