@adobe/helix-rum-enhancer 1.17.1 → 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,17 @@
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
+
8
+ # [1.18.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.17.1...v1.18.0) (2024-05-24)
9
+
10
+
11
+ ### Features
12
+
13
+ * **checkpoint:** add consent checkpoint to 1.x ([cf72b07](https://github.com/adobe/helix-rum-enhancer/commit/cf72b0762aa9b3d1949fc3c9b9a46879fc394b63))
14
+
1
15
  ## [1.17.1](https://github.com/adobe/helix-rum-enhancer/compare/v1.17.0...v1.17.1) (2024-05-21)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "1.17.1",
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
@@ -195,3 +195,38 @@ new PerformanceObserver((list) => {
195
195
  .forEach(([key, value]) => {
196
196
  sampleRUM('utm', { source: key, target: value });
197
197
  });
198
+
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)) {
201
+ const cmpCookie = document.cookie.split(';')
202
+ .map((c) => c.trim())
203
+ .find((cookie) => cookie.startsWith('OptanonAlertBoxClosed='));
204
+
205
+ if (cmpCookie) {
206
+ sampleRUM('consent', { source: 'onetrust', target: 'hidden' });
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
+ };
219
+
220
+ if (!trackShowConsent()) {
221
+ // eslint-disable-next-line max-len
222
+ consentMutationObserver = window.MutationObserver ? new MutationObserver(trackShowConsent) : null;
223
+ if (consentMutationObserver) {
224
+ consentMutationObserver.observe(
225
+ document.body,
226
+ // eslint-disable-next-line object-curly-newline
227
+ { attributes: false, childList: true, subtree: false },
228
+ );
229
+ }
230
+ }
231
+ }
232
+ }