@adobe/helix-rum-enhancer 2.1.1 → 2.3.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,17 @@
1
+ # [2.3.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.2.0...v2.3.0) (2024-03-06)
2
+
3
+
4
+ ### Features
5
+
6
+ * **minirum:** allow different base urls for collection and extra scripts ([c32c7b9](https://github.com/adobe/helix-rum-enhancer/commit/c32c7b9c3f7838ced71e372889fb618b3befe098))
7
+
8
+ # [2.2.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.1.1...v2.2.0) (2024-03-04)
9
+
10
+
11
+ ### Features
12
+
13
+ * **sourceselector:** highlight clicks on buttons and CTAs ([2bc8dc5](https://github.com/adobe/helix-rum-enhancer/commit/2bc8dc531ef31e9ae08daebdd428a98a493c0f9e))
14
+
1
15
  ## [2.1.1](https://github.com/adobe/helix-rum-enhancer/compare/v2.1.0...v2.1.1) (2024-02-28)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.1.1",
3
+ "version": "2.3.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.2",
35
+ "@semantic-release/npm": "11.0.3",
36
36
  "c8": "9.1.0",
37
37
  "codecov": "3.8.3",
38
38
  "eslint": "8.57.0",
package/src/index.js CHANGED
@@ -44,8 +44,8 @@ const sourceselector = (element) => {
44
44
  formElementSelector = element.tagName === 'INPUT' ? `form input[type='${element.getAttribute('type')}']` : `form ${element.tagName.toLowerCase()}`;
45
45
  }
46
46
 
47
+ const blockName = element.closest('.block') ? element.closest('.block').getAttribute('data-block-name') : '';
47
48
  if (element.id || formElementSelector) {
48
- const blockName = element.closest('.block') ? element.closest('.block').getAttribute('data-block-name') : '';
49
49
  const id = element.id ? `#${element.id}` : '';
50
50
  return blockName ? `.${blockName} ${formElementSelector}${id}` : `${formElementSelector}${id}`;
51
51
  }
@@ -53,6 +53,11 @@ const sourceselector = (element) => {
53
53
  if (element.getAttribute('data-block-name')) {
54
54
  return `.${element.getAttribute('data-block-name')}`;
55
55
  }
56
+
57
+ if (Array.from(element.classList).some((className) => className.match(/button|cta/))) {
58
+ return blockName ? `.${blockName} .button` : '.button';
59
+ }
60
+
56
61
  return sourceselector(element.parentElement);
57
62
  };
58
63
 
@@ -76,7 +81,7 @@ function trackCheckpoint(checkpoint, data, t) {
76
81
  const sendPing = (pdata = data) => {
77
82
  // eslint-disable-next-line object-curly-newline, max-len
78
83
  const body = JSON.stringify({ weight, id, sanitizeURL: urlSanitizers[window.hlx.RUM_MASK_URL || 'path'], checkpoint, t, ...data }, KNOWN_PROPERTIES);
79
- const url = new URL(`.rum/${weight}`, sampleRUM.baseURL).href;
84
+ const url = new URL(`.rum/${weight}`, sampleRUM.collectBaseURL || sampleRUM.baseURL).href;
80
85
  navigator.sendBeacon(url, body);
81
86
  // eslint-disable-next-line no-console
82
87
  console.debug(`ping:${checkpoint}`, pdata);