@adobe/helix-rum-enhancer 1.18.0 → 1.18.1

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
+ ## [1.18.1](https://github.com/adobe/helix-rum-enhancer/compare/v1.18.0...v1.18.1) (2024-05-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * avoid adding the mutation observer if cookie is present ([b93e598](https://github.com/adobe/helix-rum-enhancer/commit/b93e598cfc9de55dfdc4f6b47ca7f5f74b27bf62))
7
+
1
8
  # [1.18.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.17.1...v1.18.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": "1.18.0",
3
+ "version": "1.18.1",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -204,29 +204,29 @@ if ([770, 1136].includes(Array.from(window.origin).map((a) => a.charCodeAt(0)).r
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
  }