@adobe/helix-rum-enhancer 2.14.2 → 2.15.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/.releaserc.cjs CHANGED
@@ -12,5 +12,5 @@ module.exports = {
12
12
  }],
13
13
  ["@semantic-release/github", {}]
14
14
  ],
15
- branches: ['main', '1.x'],
15
+ branches: ['main'],
16
16
  };
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [2.15.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.14.2...v2.15.0) (2024-07-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use correct token for release ([094f37e](https://github.com/adobe/helix-rum-enhancer/commit/094f37ef2de8ddf5d64ea38c9071c9b1bec6119a))
7
+
8
+
9
+ ### Features
10
+
11
+ * add more logic to button selector ([#205](https://github.com/adobe/helix-rum-enhancer/issues/205)) ([c9a5629](https://github.com/adobe/helix-rum-enhancer/commit/c9a5629e7e690397a5f46cbf8db08570f0c4d250))
12
+ * clean up and trigger release ([bfc8d24](https://github.com/adobe/helix-rum-enhancer/commit/bfc8d241cd19b33975ac37be5167783b99fbe54c))
13
+ * switch release token ([0e5b3b0](https://github.com/adobe/helix-rum-enhancer/commit/0e5b3b03d0b96a32118340e7b6f004da8660f0aa))
14
+ * trigger release ([bf26949](https://github.com/adobe/helix-rum-enhancer/commit/bf269492cb330c55d22fd0eeed4aad4cfdac57a3))
15
+
1
16
  ## [2.14.2](https://github.com/adobe/helix-rum-enhancer/compare/v2.14.1...v2.14.2) (2024-06-12)
2
17
 
3
18
 
package/modules/dom.js CHANGED
@@ -54,11 +54,25 @@ export const sourceSelector = (element) => {
54
54
  return `.${element.getAttribute('data-block-name')}`;
55
55
  }
56
56
 
57
- if (Array.from(element.classList).some((className) => className.match(/button|cta/))) {
58
- return blockName ? `.${blockName} .button` : '.button';
57
+ const classes = Array.from(element.classList);
58
+ const label = element.tagName.toLowerCase();
59
+ const firstClass = classes.length > 0 ? `.${classes[0]}` : '';
60
+ const labelWithClass = `${element.tagName.toLowerCase()}${firstClass}`;
61
+ if (element.tagName.toLowerCase() === 'button'
62
+ || element.type === 'button'
63
+ || classes.some((className) => className.match(/button|cta/))) {
64
+ let parent = element.parentElement;
65
+ if (!parent) return labelWithClass;
66
+ if (parent.id) return `#${parent.id} ${label}`;
67
+ while (parent.tagName !== 'BODY' && !parent.id) parent = parent.parentElement;
68
+ if (parent.id) return `#${parent.id} ${labelWithClass}`;
69
+ return blockName ? `.${blockName} ${labelWithClass}` : labelWithClass;
59
70
  }
60
71
 
61
- return sourceSelector(element.parentElement);
72
+ const parent = sourceSelector(element.parentElement);
73
+ if (parent) return parent;
74
+
75
+ return labelWithClass;
62
76
  /* c8 ignore next 3 */
63
77
  } catch (error) {
64
78
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.14.2",
3
+ "version": "2.15.0",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -42,7 +42,7 @@
42
42
  "@web/test-runner-commands": "0.9.0",
43
43
  "@web/test-runner-mocha": "0.9.0",
44
44
  "@web/test-runner-playwright": "0.11.0",
45
- "c8": "10.0.0",
45
+ "c8": "10.1.2",
46
46
  "codecov": "3.8.3",
47
47
  "eslint": "8.57.0",
48
48
  "eslint-plugin-header": "3.1.1",
@@ -50,8 +50,8 @@
50
50
  "husky": "9.0.11",
51
51
  "jsdoc-to-markdown": "8.0.1",
52
52
  "junit-report-builder": "3.2.1",
53
- "lint-staged": "15.2.5",
54
- "mocha": "10.4.0",
53
+ "lint-staged": "15.2.7",
54
+ "mocha": "10.5.2",
55
55
  "mocha-multi-reporters": "1.5.1",
56
56
  "rollup": "4.18.0",
57
57
  "rollup-plugin-cleanup": "3.2.1",
package/src/index.js CHANGED
@@ -100,11 +100,25 @@
100
100
  return `.${element.getAttribute('data-block-name')}`;
101
101
  }
102
102
 
103
- if (Array.from(element.classList).some((className) => className.match(/button|cta/))) {
104
- return blockName ? `.${blockName} .button` : '.button';
103
+ const classes = Array.from(element.classList);
104
+ const label = element.tagName.toLowerCase();
105
+ const firstClass = classes.length > 0 ? `.${classes[0]}` : '';
106
+ const labelWithClass = `${element.tagName.toLowerCase()}${firstClass}`;
107
+ if (element.tagName.toLowerCase() === 'button'
108
+ || element.type === 'button'
109
+ || classes.some((className) => className.match(/button|cta/))) {
110
+ let parent = element.parentElement;
111
+ if (!parent) return labelWithClass;
112
+ if (parent.id) return `#${parent.id} ${label}`;
113
+ while (parent.tagName !== 'BODY' && !parent.id) parent = parent.parentElement;
114
+ if (parent.id) return `#${parent.id} ${labelWithClass}`;
115
+ return blockName ? `.${blockName} ${labelWithClass}` : labelWithClass;
105
116
  }
106
117
 
107
- return sourceSelector(element.parentElement);
118
+ const parent = sourceSelector(element.parentElement);
119
+ if (parent) return parent;
120
+
121
+ return labelWithClass;
108
122
  } catch (error) {
109
123
  return null;
110
124
  }