@adobe/helix-rum-enhancer 2.10.0 → 2.11.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 +14 -0
- package/package.json +1 -1
- package/src/index.js +38 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.11.1](https://github.com/adobe/helix-rum-enhancer/compare/v2.11.0...v2.11.1) (2024-06-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* no this in arrow functions ([#182](https://github.com/adobe/helix-rum-enhancer/issues/182)) ([218e608](https://github.com/adobe/helix-rum-enhancer/commit/218e60890c5e1328de27d03916a680c6019f92af))
|
|
7
|
+
|
|
8
|
+
# [2.11.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.10.0...v2.11.0) (2024-05-31)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **index:** report ad clicks and email clicks ([f5b0779](https://github.com/adobe/helix-rum-enhancer/commit/f5b0779e4286962d881b69411efb8045660ff5de))
|
|
14
|
+
|
|
1
15
|
# [2.10.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.9.0...v2.10.0) (2024-05-31)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -15,12 +15,14 @@ const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewbloc
|
|
|
15
15
|
const { sampleRUM, queue, isSelected } = (window.hlx && window.hlx.rum) ? window.hlx.rum : {};
|
|
16
16
|
|
|
17
17
|
const fflags = {
|
|
18
|
-
has: (flag) =>
|
|
18
|
+
has: (flag) => fflags[flag].indexOf(Array.from(window.origin)
|
|
19
19
|
.map((a) => a.charCodeAt(0))
|
|
20
20
|
.reduce((a, b) => a + b, 1) % 1371) !== -1,
|
|
21
|
-
enabled: (flag, callback) =>
|
|
22
|
-
disabled: (flag, callback) => !
|
|
21
|
+
enabled: (flag, callback) => fflags.has(flag) && callback(),
|
|
22
|
+
disabled: (flag, callback) => !fflags.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])
|