@adobe/helix-rum-enhancer 2.10.0 → 2.11.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.11.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.10.0...v2.11.0) (2024-05-31)
2
+
3
+
4
+ ### Features
5
+
6
+ * **index:** report ad clicks and email clicks ([f5b0779](https://github.com/adobe/helix-rum-enhancer/commit/f5b0779e4286962d881b69411efb8045660ff5de))
7
+
1
8
  # [2.10.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.9.0...v2.10.0) (2024-05-31)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -21,6 +21,8 @@ const fflags = {
21
21
  enabled: (flag, callback) => this.has(flag) && callback(),
22
22
  disabled: (flag, callback) => !this.has(flag) && callback(),
23
23
  onetrust: [543, 770, 1136],
24
+ ads: [1339],
25
+ email: [1339],
24
26
  };
25
27
 
26
28
  const urlSanitizers = {
@@ -97,6 +99,8 @@ function optedIn(checkpoint, data) {
97
99
  function getCollectionConfig() {
98
100
  // eslint-disable-next-line max-len
99
101
  fflags.enabled('onetrust', () => DEFAULT_TRACKING_EVENTS.push('consent'));
102
+ fflags.enabled('ads', () => DEFAULT_TRACKING_EVENTS.push('paid'));
103
+ fflags.enabled('email', () => DEFAULT_TRACKING_EVENTS.push('email'));
100
104
  return DEFAULT_TRACKING_EVENTS;
101
105
  }
102
106
 
@@ -284,6 +288,35 @@ function addUTMParametersTracking() {
284
288
  .forEach(([source, target]) => sampleRUM('utm', { source, target }));
285
289
  }
286
290
 
291
+ function addAdsParametersTracking() {
292
+ const networks = {
293
+ google: /gclid|gclsrc|wbraid|gbraid/,
294
+ doubleclick: /dclid/,
295
+ microsoft: /msclkid/,
296
+ facebook: /fb(cl|ad_|pxl_)id/,
297
+ twitter: /tw(clid|src|term)/,
298
+ linkedin: /li_fat_id/,
299
+ pinterest: /epik/,
300
+ tiktok: /ttclid/,
301
+ };
302
+ const params = Array.from(new URLSearchParams(window.location.search).keys());
303
+ Object.entries(networks).forEach(([network, regex]) => {
304
+ params.filter((param) => regex.test(param)).forEach((param) => sampleRUM('paid', { source: network, target: param }));
305
+ });
306
+ }
307
+
308
+ function addEmailParameterTracking() {
309
+ const networks = {
310
+ mailchimp: /mc_(c|e)id/,
311
+ marketo: /mkt_tok/,
312
+
313
+ };
314
+ const params = Array.from(new URLSearchParams(window.location.search).keys());
315
+ Object.entries(networks).forEach(([network, regex]) => {
316
+ params.filter((param) => regex.test(param)).forEach((param) => sampleRUM('email', { source: network, target: param }));
317
+ });
318
+ }
319
+
287
320
  function addFormTracking(parent) {
288
321
  activateBlocksMutationObserver();
289
322
  parent.querySelectorAll('form').forEach((form) => {
@@ -353,6 +386,8 @@ function addTrackingFromConfig() {
353
386
  viewblock: () => addViewBlockTracking(window.document.body),
354
387
  viewmedia: () => addViewMediaTracking(window.document.body),
355
388
  consent: () => addCookieConsentTracking(),
389
+ paid: () => addAdsParametersTracking(),
390
+ email: () => addEmailParameterTracking(),
356
391
  };
357
392
 
358
393
  getCollectionConfig().filter((ck) => trackingFunctions[ck])