@adobe/helix-rum-enhancer 1.18.2 → 1.19.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 +8 -0
- package/package.json +1 -1
- package/src/index.js +42 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# [1.19.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.18.2...v1.19.0) (2024-05-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **index:** ads reporting for 2.x ([b6c2314](https://github.com/adobe/helix-rum-enhancer/commit/b6c23149b82702ab592c504c1d8b304c248c3ceb))
|
|
7
|
+
* **index:** introduce simple feature flag system ([c75796c](https://github.com/adobe/helix-rum-enhancer/commit/c75796c097189b214f0822207c68be3cd443c183))
|
|
8
|
+
|
|
1
9
|
## [1.18.2](https://github.com/adobe/helix-rum-enhancer/compare/v1.18.1...v1.18.2) (2024-05-28)
|
|
2
10
|
|
|
3
11
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -11,6 +11,17 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const { sampleRUM } = window.hlx.rum;
|
|
13
13
|
|
|
14
|
+
const fflags = {
|
|
15
|
+
has: (flag) => this[flag].indexOf(Array.from(window.origin)
|
|
16
|
+
.map((a) => a.charCodeAt(0))
|
|
17
|
+
.reduce((a, b) => a + b, 1) % 1371) !== -1,
|
|
18
|
+
enabled: (flag, callback) => this.has(flag) && callback(),
|
|
19
|
+
disabled: (flag, callback) => !this.has(flag) && callback(),
|
|
20
|
+
onetrust: [543, 770, 1136],
|
|
21
|
+
ads: [1339],
|
|
22
|
+
email: [1339],
|
|
23
|
+
};
|
|
24
|
+
|
|
14
25
|
sampleRUM.baseURL = sampleRUM.baseURL || new URL('https://rum.hlx.page');
|
|
15
26
|
|
|
16
27
|
sampleRUM.blockobserver = (window.IntersectionObserver) ? new IntersectionObserver((entries) => {
|
|
@@ -196,8 +207,7 @@ new PerformanceObserver((list) => {
|
|
|
196
207
|
sampleRUM('utm', { source: key, target: value });
|
|
197
208
|
});
|
|
198
209
|
|
|
199
|
-
|
|
200
|
-
if ([543, 770, 1136].includes(Array.from(window.origin).map((a) => a.charCodeAt(0)).reduce((a, b) => a + b, 1) % 1371)) {
|
|
210
|
+
fflags.enabled('onetrust', () => {
|
|
201
211
|
const cmpCookie = document.cookie.split(';')
|
|
202
212
|
.map((c) => c.trim())
|
|
203
213
|
.find((cookie) => cookie.startsWith('OptanonAlertBoxClosed='));
|
|
@@ -229,4 +239,33 @@ if ([543, 770, 1136].includes(Array.from(window.origin).map((a) => a.charCodeAt(
|
|
|
229
239
|
}
|
|
230
240
|
}
|
|
231
241
|
}
|
|
232
|
-
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
fflags.enabled('ads', () => {
|
|
245
|
+
const networks = {
|
|
246
|
+
google: /gclid|gclsrc|wbraid|gbraid/,
|
|
247
|
+
doubleclick: /dclid/,
|
|
248
|
+
microsoft: /msclkid/,
|
|
249
|
+
facebook: /fb(cl|ad_|pxl_)id/,
|
|
250
|
+
twitter: /tw(clid|src|term)/,
|
|
251
|
+
linkedin: /li_fat_id/,
|
|
252
|
+
pinterest: /epik/,
|
|
253
|
+
tiktok: /ttclid/,
|
|
254
|
+
};
|
|
255
|
+
const params = Array.from(new URLSearchParams(window.location.search).keys());
|
|
256
|
+
Object.entries(networks).forEach(([network, regex]) => {
|
|
257
|
+
params.filter((param) => regex.test(param)).forEach((param) => sampleRUM('paid', { source: network, target: param }));
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
fflags.enabled('email', () => {
|
|
262
|
+
const networks = {
|
|
263
|
+
mailchimp: /mc_(c|e)id/,
|
|
264
|
+
marketo: /mkt_tok/,
|
|
265
|
+
|
|
266
|
+
};
|
|
267
|
+
const params = Array.from(new URLSearchParams(window.location.search).keys());
|
|
268
|
+
Object.entries(networks).forEach(([network, regex]) => {
|
|
269
|
+
params.filter((param) => regex.test(param)).forEach((param) => sampleRUM('email', { source: network, target: param }));
|
|
270
|
+
});
|
|
271
|
+
});
|