@adobe/helix-rum-enhancer 2.3.0 → 2.4.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,19 @@
1
+ # [2.4.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.3.1...v2.4.0) (2024-03-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * track UTM query parameters ([2c237e5](https://github.com/adobe/helix-rum-enhancer/commit/2c237e5361ea2f166a0c37b1b752feda30ae9293)), closes [#137](https://github.com/adobe/helix-rum-enhancer/issues/137)
7
+ * track UTM query parameters ([ed58621](https://github.com/adobe/helix-rum-enhancer/commit/ed586215611c492adb29e5a98cadca3bd140d429))
8
+ * track UTM query parameters ([d1a6552](https://github.com/adobe/helix-rum-enhancer/commit/d1a6552a9b661867c0bfde06bcd066b4a1ed9024))
9
+
10
+ ## [2.3.1](https://github.com/adobe/helix-rum-enhancer/compare/v2.3.0...v2.3.1) (2024-03-11)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * add json type header to beacon ([a1e0807](https://github.com/adobe/helix-rum-enhancer/commit/a1e0807f735a7c8097c588f401efdb9aac08dfc7))
16
+
1
17
  # [2.3.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.2.0...v2.3.0) (2024-03-06)
2
18
 
3
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  "@adobe/eslint-config-helix": "2.0.6",
33
33
  "@semantic-release/changelog": "6.0.3",
34
34
  "@semantic-release/git": "10.0.1",
35
- "@semantic-release/npm": "11.0.3",
35
+ "@semantic-release/npm": "12.0.0",
36
36
  "c8": "9.1.0",
37
37
  "codecov": "3.8.3",
38
38
  "eslint": "8.57.0",
package/src/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
  /* eslint-env browser */
13
13
  const KNOWN_PROPERTIES = ['weight', 'id', 'referer', 'checkpoint', 't', 'source', 'target', 'cwv', 'CLS', 'FID', 'LCP', 'INP', 'TTFB'];
14
- const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource'];
14
+ const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource', 'utm'];
15
15
  const SESSION_STORAGE_KEY = 'aem-rum';
16
16
  const { sampleRUM, queue, isSelected } = window.hlx.rum;
17
17
 
@@ -82,7 +82,8 @@ function trackCheckpoint(checkpoint, data, t) {
82
82
  // eslint-disable-next-line object-curly-newline, max-len
83
83
  const body = JSON.stringify({ weight, id, sanitizeURL: urlSanitizers[window.hlx.RUM_MASK_URL || 'path'], checkpoint, t, ...data }, KNOWN_PROPERTIES);
84
84
  const url = new URL(`.rum/${weight}`, sampleRUM.collectBaseURL || sampleRUM.baseURL).href;
85
- navigator.sendBeacon(url, body);
85
+ const headers = { type: 'application/json' };
86
+ navigator.sendBeacon(url, new Blob([body], headers));
86
87
  // eslint-disable-next-line no-console
87
88
  console.debug(`ping:${checkpoint}`, pdata);
88
89
  };
@@ -223,6 +224,14 @@ function addViewMediaTracking(parent) {
223
224
  }
224
225
  }
225
226
 
227
+ function addUTMParametersTracking() {
228
+ const usp = new URLSearchParams(window.location.search);
229
+ [...usp.entries()]
230
+ .filter(([key]) => key.startsWith('utm_'))
231
+ .filter(([key]) => key !== 'utm_id');
232
+ .forEach(([source, target]) => sampleRUM('utm', { source, target }));
233
+ }
234
+
226
235
  function addFormTracking(parent) {
227
236
  activateBlocksMutationObserver();
228
237
  parent.querySelectorAll('form').forEach((form) => {
@@ -253,6 +262,7 @@ function addTrackingFromConfig() {
253
262
  form: () => addFormTracking(window.document.body),
254
263
  enterleave: () => addEnterLeaveTracking(),
255
264
  loadresource: () => addLoadResourceTracking(),
265
+ utm: () => addUTMParametersTracking(),
256
266
  viewblock: () => addViewBlockTracking(window.document.body),
257
267
  viewmedia: () => addViewMediaTracking(window.document.body),
258
268
  };