@adobe/helix-rum-enhancer 2.7.6 → 2.9.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,17 @@
1
+ # [2.9.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.8.0...v2.9.0) (2024-05-24)
2
+
3
+
4
+ ### Features
5
+
6
+ * **missingresource:** remove feature flag (2.x) ([0905922](https://github.com/adobe/helix-rum-enhancer/commit/090592240fe2e6b05afc5044a20d11113b8d5f21))
7
+
8
+ # [2.8.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.7.6...v2.8.0) (2024-05-24)
9
+
10
+
11
+ ### Features
12
+
13
+ * **checkpoint:** add consent checkpoint ([6bf3740](https://github.com/adobe/helix-rum-enhancer/commit/6bf3740cdb6e2ac12624f2e1a9c5d6539a3f124f))
14
+
1
15
  ## [2.7.6](https://github.com/adobe/helix-rum-enhancer/compare/v2.7.5...v2.7.6) (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": "2.7.6",
3
+ "version": "2.9.0",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -86,6 +86,10 @@ function optedIn(checkpoint, data) {
86
86
  }
87
87
  // Gets configured collection from the config service for the current domain
88
88
  function getCollectionConfig() {
89
+ // 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
+ }
89
93
  return DEFAULT_TRACKING_EVENTS;
90
94
  }
91
95
 
@@ -199,15 +203,11 @@ function addLoadResourceTracking() {
199
203
  .forEach((entry) => {
200
204
  sampleRUM('loadresource', { source: entry.name, target: Math.round(entry.duration) });
201
205
  });
202
-
203
- if (window.origin === 'business.adobe.com') {
204
- // feature flagged for now
205
- list.getEntries()
206
- .filter((entry) => entry.responseStatus === 404)
207
- .forEach((entry) => {
208
- sampleRUM('missingresource', { source: entry.name, target: entry.hostname });
209
- });
210
- }
206
+ list.getEntries()
207
+ .filter((entry) => entry.responseStatus === 404)
208
+ .forEach((entry) => {
209
+ sampleRUM('missingresource', { source: entry.name, target: entry.hostname });
210
+ });
211
211
  } catch (error) {
212
212
  // something went wrong
213
213
  }
@@ -285,6 +285,41 @@ function addFormTracking(parent) {
285
285
  });
286
286
  }
287
287
 
288
+ function addCookieConsentTracking() {
289
+ const cmpCookie = document.cookie.split(';')
290
+ .map((c) => c.trim())
291
+ .find((cookie) => cookie.startsWith('OptanonAlertBoxClosed='));
292
+
293
+ if (cmpCookie) {
294
+ sampleRUM('consent', { source: 'onetrust', target: 'hidden' });
295
+ return;
296
+ }
297
+
298
+ let consentMutationObserver;
299
+ const trackShowConsent = () => {
300
+ if (document.querySelector('body > div#onetrust-consent-sdk')) {
301
+ sampleRUM('consent', { source: 'onetrust', target: 'show' });
302
+ if (consentMutationObserver) {
303
+ consentMutationObserver.disconnect();
304
+ }
305
+ return true;
306
+ }
307
+ return false;
308
+ };
309
+
310
+ if (!trackShowConsent()) {
311
+ // eslint-disable-next-line max-len
312
+ consentMutationObserver = window.MutationObserver ? new MutationObserver(trackShowConsent) : null;
313
+ if (consentMutationObserver) {
314
+ consentMutationObserver.observe(
315
+ document.body,
316
+ // eslint-disable-next-line object-curly-newline
317
+ { attributes: false, childList: true, subtree: false },
318
+ );
319
+ }
320
+ }
321
+ }
322
+
288
323
  const addObserver = (ck, fn, block) => getCollectionConfig().includes(ck) && fn(block);
289
324
  function mutationsCallback(mutations) {
290
325
  mutations.filter((m) => m.type === 'attributes' && m.attributeName === 'data-block-status')
@@ -310,6 +345,7 @@ function addTrackingFromConfig() {
310
345
  utm: () => addUTMParametersTracking(),
311
346
  viewblock: () => addViewBlockTracking(window.document.body),
312
347
  viewmedia: () => addViewMediaTracking(window.document.body),
348
+ consent: () => addCookieConsentTracking(),
313
349
  };
314
350
 
315
351
  getCollectionConfig().filter((ck) => trackingFunctions[ck])