@adobe/helix-rum-enhancer 2.7.0 → 2.7.2

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,18 @@
1
+ ## [2.7.2](https://github.com/adobe/helix-rum-enhancer/compare/v2.7.1...v2.7.2) (2024-04-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * exclude utm_term from collection ([732c647](https://github.com/adobe/helix-rum-enhancer/commit/732c64746a238c8726f6a14d2025778880611f86)), closes [#153](https://github.com/adobe/helix-rum-enhancer/issues/153)
7
+ * exclude utm_term from collection ([545a168](https://github.com/adobe/helix-rum-enhancer/commit/545a168da34cf58a3f84be84545d0692827ee98b))
8
+
9
+ ## [2.7.1](https://github.com/adobe/helix-rum-enhancer/compare/v2.7.0...v2.7.1) (2024-04-18)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * make targetselector null safe ([#156](https://github.com/adobe/helix-rum-enhancer/issues/156)) ([691d40d](https://github.com/adobe/helix-rum-enhancer/commit/691d40d1659d6aaac81f4037e11c243341181b80))
15
+
1
16
  # [2.7.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.6.0...v2.7.0) (2024-04-18)
2
17
 
3
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
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 = sampleRUM.targetselector(element);
122
- data.source = sampleRUM.sourceselector(element) || element.outerHTML.slice(0, 30);
121
+ data.target = targetselector(element);
122
+ data.source = sourceselector(element) || element.outerHTML.slice(0, 30);
123
123
  }
124
124
  sampleRUM('cwv', data);
125
125
  };
@@ -247,7 +247,9 @@ function addUTMParametersTracking() {
247
247
  const usp = new URLSearchParams(window.location.search);
248
248
  [...usp.entries()]
249
249
  .filter(([key]) => key.startsWith('utm_'))
250
+ // exclude keys that may leak PII
250
251
  .filter(([key]) => key !== 'utm_id')
252
+ .filter(([key]) => key !== 'utm_term')
251
253
  .forEach(([source, target]) => sampleRUM('utm', { source, target }));
252
254
  }
253
255
 
@@ -291,9 +293,6 @@ function addTrackingFromConfig() {
291
293
  }
292
294
 
293
295
  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
296
  addTrackingFromConfig();
298
297
  window.hlx.rum.collector = trackCheckpoint;
299
298
  processQueue();