@adobe/helix-rum-enhancer 1.18.0 → 1.18.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,17 @@
1
+ ## [1.18.2](https://github.com/adobe/helix-rum-enhancer/compare/v1.18.1...v1.18.2) (2024-05-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * enable feature flag ([0f315ab](https://github.com/adobe/helix-rum-enhancer/commit/0f315ab65011c50473656e556af48224bcb1deb3))
7
+
8
+ ## [1.18.1](https://github.com/adobe/helix-rum-enhancer/compare/v1.18.0...v1.18.1) (2024-05-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * avoid adding the mutation observer if cookie is present ([b93e598](https://github.com/adobe/helix-rum-enhancer/commit/b93e598cfc9de55dfdc4f6b47ca7f5f74b27bf62))
14
+
1
15
  # [1.18.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.17.1...v1.18.0) (2024-05-24)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "1.18.0",
3
+ "version": "1.18.2",
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
@@ -197,36 +197,36 @@ new PerformanceObserver((list) => {
197
197
  });
198
198
 
199
199
  // eslint-disable-next-line max-len
200
- if ([770, 1136].includes(Array.from(window.origin).map((a) => a.charCodeAt(0)).reduce((a, b) => a + b, 1) % 1371)) {
200
+ if ([543, 770, 1136].includes(Array.from(window.origin).map((a) => a.charCodeAt(0)).reduce((a, b) => a + b, 1) % 1371)) {
201
201
  const cmpCookie = document.cookie.split(';')
202
202
  .map((c) => c.trim())
203
203
  .find((cookie) => cookie.startsWith('OptanonAlertBoxClosed='));
204
204
 
205
205
  if (cmpCookie) {
206
206
  sampleRUM('consent', { source: 'onetrust', target: 'hidden' });
207
- }
207
+ } else {
208
+ let consentMutationObserver;
209
+ const trackShowConsent = () => {
210
+ if (document.querySelector('body > div#onetrust-consent-sdk')) {
211
+ sampleRUM('consent', { source: 'onetrust', target: 'show' });
212
+ if (consentMutationObserver) {
213
+ consentMutationObserver.disconnect();
214
+ }
215
+ return true;
216
+ }
217
+ return false;
218
+ };
208
219
 
209
- let consentMutationObserver;
210
- const trackShowConsent = () => {
211
- if (document.querySelector('body > div#onetrust-consent-sdk')) {
212
- sampleRUM('consent', { source: 'onetrust', target: 'show' });
220
+ if (!trackShowConsent()) {
221
+ // eslint-disable-next-line max-len
222
+ consentMutationObserver = window.MutationObserver ? new MutationObserver(trackShowConsent) : null;
213
223
  if (consentMutationObserver) {
214
- consentMutationObserver.disconnect();
224
+ consentMutationObserver.observe(
225
+ document.body,
226
+ // eslint-disable-next-line object-curly-newline
227
+ { attributes: false, childList: true, subtree: false },
228
+ );
215
229
  }
216
- return true;
217
- }
218
- return false;
219
- };
220
-
221
- if (!trackShowConsent()) {
222
- // eslint-disable-next-line max-len
223
- consentMutationObserver = window.MutationObserver ? new MutationObserver(trackShowConsent) : null;
224
- if (consentMutationObserver) {
225
- consentMutationObserver.observe(
226
- document.body,
227
- // eslint-disable-next-line object-curly-newline
228
- { attributes: false, childList: true, subtree: false },
229
- );
230
230
  }
231
231
  }
232
232
  }