@adobe/helix-rum-enhancer 2.9.0 → 2.10.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,10 @@
1
+ # [2.10.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.9.0...v2.10.0) (2024-05-31)
2
+
3
+
4
+ ### Features
5
+
6
+ * **index:** add new feature flag system ([7ef9f20](https://github.com/adobe/helix-rum-enhancer/commit/7ef9f20cd9e3ec07ac06c3924fb4ca33f68a49e1))
7
+
1
8
  # [2.9.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.8.0...v2.9.0) (2024-05-24)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.9.0",
3
+ "version": "2.10.0",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -41,7 +41,7 @@
41
41
  "husky": "9.0.11",
42
42
  "jsdoc-to-markdown": "8.0.1",
43
43
  "junit-report-builder": "3.2.1",
44
- "lint-staged": "15.2.2",
44
+ "lint-staged": "15.2.5",
45
45
  "mocha": "10.4.0",
46
46
  "mocha-multi-reporters": "1.5.1",
47
47
  "semantic-release": "23.1.1"
package/src/index.js CHANGED
@@ -14,6 +14,15 @@ const KNOWN_PROPERTIES = ['weight', 'id', 'referer', 'checkpoint', 't', 'source'
14
14
  const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource', 'utm'];
15
15
  const { sampleRUM, queue, isSelected } = (window.hlx && window.hlx.rum) ? window.hlx.rum : {};
16
16
 
17
+ const fflags = {
18
+ has: (flag) => this[flag].indexOf(Array.from(window.origin)
19
+ .map((a) => a.charCodeAt(0))
20
+ .reduce((a, b) => a + b, 1) % 1371) !== -1,
21
+ enabled: (flag, callback) => this.has(flag) && callback(),
22
+ disabled: (flag, callback) => !this.has(flag) && callback(),
23
+ onetrust: [543, 770, 1136],
24
+ };
25
+
17
26
  const urlSanitizers = {
18
27
  full: () => window.location.href,
19
28
  origin: () => window.location.origin,
@@ -87,9 +96,7 @@ function optedIn(checkpoint, data) {
87
96
  // Gets configured collection from the config service for the current domain
88
97
  function getCollectionConfig() {
89
98
  // eslint-disable-next-line max-len
90
- if ([770, 1136].includes(Array.from(window.origin).map((a) => a.charCodeAt(0)).reduce((a, b) => a + b, 1) % 1371)) {
91
- return DEFAULT_TRACKING_EVENTS.concat('consent');
92
- }
99
+ fflags.enabled('onetrust', () => DEFAULT_TRACKING_EVENTS.push('consent'));
93
100
  return DEFAULT_TRACKING_EVENTS;
94
101
  }
95
102