@adobe/helix-rum-enhancer 2.9.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 +14 -0
- package/package.json +2 -2
- package/src/index.js +45 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
8
|
+
# [2.10.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.9.0...v2.10.0) (2024-05-31)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **index:** add new feature flag system ([7ef9f20](https://github.com/adobe/helix-rum-enhancer/commit/7ef9f20cd9e3ec07ac06c3924fb4ca33f68a49e1))
|
|
14
|
+
|
|
1
15
|
# [2.9.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.8.0...v2.9.0) (2024-05-24)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-rum-enhancer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Helix RUM Enhancer",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"husky": "9.0.11",
|
|
42
42
|
"jsdoc-to-markdown": "8.0.1",
|
|
43
43
|
"junit-report-builder": "3.2.1",
|
|
44
|
-
"lint-staged": "15.2.
|
|
44
|
+
"lint-staged": "15.2.5",
|
|
45
45
|
"mocha": "10.4.0",
|
|
46
46
|
"mocha-multi-reporters": "1.5.1",
|
|
47
47
|
"semantic-release": "23.1.1"
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,17 @@ const KNOWN_PROPERTIES = ['weight', 'id', 'referer', 'checkpoint', 't', 'source'
|
|
|
14
14
|
const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource', 'utm'];
|
|
15
15
|
const { sampleRUM, queue, isSelected } = (window.hlx && window.hlx.rum) ? window.hlx.rum : {};
|
|
16
16
|
|
|
17
|
+
const fflags = {
|
|
18
|
+
has: (flag) => this[flag].indexOf(Array.from(window.origin)
|
|
19
|
+
.map((a) => a.charCodeAt(0))
|
|
20
|
+
.reduce((a, b) => a + b, 1) % 1371) !== -1,
|
|
21
|
+
enabled: (flag, callback) => this.has(flag) && callback(),
|
|
22
|
+
disabled: (flag, callback) => !this.has(flag) && callback(),
|
|
23
|
+
onetrust: [543, 770, 1136],
|
|
24
|
+
ads: [1339],
|
|
25
|
+
email: [1339],
|
|
26
|
+
};
|
|
27
|
+
|
|
17
28
|
const urlSanitizers = {
|
|
18
29
|
full: () => window.location.href,
|
|
19
30
|
origin: () => window.location.origin,
|
|
@@ -87,9 +98,9 @@ function optedIn(checkpoint, data) {
|
|
|
87
98
|
// Gets configured collection from the config service for the current domain
|
|
88
99
|
function getCollectionConfig() {
|
|
89
100
|
// eslint-disable-next-line max-len
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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'));
|
|
93
104
|
return DEFAULT_TRACKING_EVENTS;
|
|
94
105
|
}
|
|
95
106
|
|
|
@@ -277,6 +288,35 @@ function addUTMParametersTracking() {
|
|
|
277
288
|
.forEach(([source, target]) => sampleRUM('utm', { source, target }));
|
|
278
289
|
}
|
|
279
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
|
+
|
|
280
320
|
function addFormTracking(parent) {
|
|
281
321
|
activateBlocksMutationObserver();
|
|
282
322
|
parent.querySelectorAll('form').forEach((form) => {
|
|
@@ -346,6 +386,8 @@ function addTrackingFromConfig() {
|
|
|
346
386
|
viewblock: () => addViewBlockTracking(window.document.body),
|
|
347
387
|
viewmedia: () => addViewMediaTracking(window.document.body),
|
|
348
388
|
consent: () => addCookieConsentTracking(),
|
|
389
|
+
paid: () => addAdsParametersTracking(),
|
|
390
|
+
email: () => addEmailParameterTracking(),
|
|
349
391
|
};
|
|
350
392
|
|
|
351
393
|
getCollectionConfig().filter((ck) => trackingFunctions[ck])
|