@adobe/helix-rum-enhancer 2.16.0 → 2.17.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/.husky/pre-commit +1 -0
- package/CHANGELOG.md +15 -0
- package/modules/defaults.js +1 -1
- package/modules/fflags.js +4 -4
- package/modules/index.js +5 -2
- package/package.json +11 -9
- package/rollup.config.js +7 -0
- package/src/index.js +6 -7
- package/web-test-runner.config.js +38 -0
package/.husky/pre-commit
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [2.17.1](https://github.com/adobe/helix-rum-enhancer/compare/v2.17.0...v2.17.1) (2024-08-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **loadresource:** fix closing bracket ([0978b71](https://github.com/adobe/helix-rum-enhancer/commit/0978b7138f16421b5eb22c49b3c757116cb7053b))
|
|
7
|
+
* **loadresource:** include all JSON resources, and GraphQL resources ([8ebaa97](https://github.com/adobe/helix-rum-enhancer/commit/8ebaa97e844ff605ec2e6a458fc43adc3c5a37dd))
|
|
8
|
+
|
|
9
|
+
# [2.17.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.16.0...v2.17.0) (2024-07-03)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **email:** rollout for all customers 2.x ([#222](https://github.com/adobe/helix-rum-enhancer/issues/222)) ([bb71ae6](https://github.com/adobe/helix-rum-enhancer/commit/bb71ae656fbb8c34ca5de3436f950a9e10e8f188))
|
|
15
|
+
|
|
1
16
|
# [2.16.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.15.0...v2.16.0) (2024-07-02)
|
|
2
17
|
|
|
3
18
|
|
package/modules/defaults.js
CHANGED
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
export const KNOWN_PROPERTIES = ['weight', 'id', 'referer', 'checkpoint', 't', 'source', 'target', 'cwv', 'CLS', 'FID', 'LCP', 'INP', 'TTFB'];
|
|
13
|
-
export const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource', 'utm', 'paid'];
|
|
13
|
+
export const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource', 'utm', 'paid', 'email'];
|
package/modules/fflags.js
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
export const fflags = {
|
|
13
|
-
has: (flag) =>
|
|
14
|
-
.
|
|
15
|
-
|
|
13
|
+
has: (flag) => !!window.origin.match(/localhost/)
|
|
14
|
+
|| fflags[flag].indexOf(Array.from(window.origin)
|
|
15
|
+
.map((a) => a.charCodeAt(0))
|
|
16
|
+
.reduce((a, b) => a + b, 1) % 1371) !== -1,
|
|
16
17
|
enabled: (flag, callback) => fflags.has(flag) && callback(),
|
|
17
18
|
disabled: (flag, callback) => !fflags.has(flag) && callback(),
|
|
18
19
|
onetrust: [543, 770, 1136],
|
|
19
|
-
email: [1139, 543],
|
|
20
20
|
};
|
package/modules/index.js
CHANGED
|
@@ -31,7 +31,6 @@ function optedIn(checkpoint, data) {
|
|
|
31
31
|
function getCollectionConfig() {
|
|
32
32
|
// eslint-disable-next-line max-len
|
|
33
33
|
fflags.enabled('onetrust', () => DEFAULT_TRACKING_EVENTS.push('consent'));
|
|
34
|
-
fflags.enabled('email', () => DEFAULT_TRACKING_EVENTS.push('email'));
|
|
35
34
|
return DEFAULT_TRACKING_EVENTS;
|
|
36
35
|
}
|
|
37
36
|
|
|
@@ -45,6 +44,7 @@ function trackCheckpoint(checkpoint, data, t) {
|
|
|
45
44
|
if (window.location.origin === origin) {
|
|
46
45
|
const headers = { type: 'application/json' };
|
|
47
46
|
navigator.sendBeacon(url, new Blob([body], headers));
|
|
47
|
+
/* c8 ignore next 3 */
|
|
48
48
|
} else {
|
|
49
49
|
navigator.sendBeacon(url, body);
|
|
50
50
|
}
|
|
@@ -98,6 +98,7 @@ function addCWVTracking() {
|
|
|
98
98
|
});
|
|
99
99
|
};
|
|
100
100
|
document.head.appendChild(script);
|
|
101
|
+
/* c8 ignore next 3 */
|
|
101
102
|
} catch (error) {
|
|
102
103
|
// something went wrong
|
|
103
104
|
}
|
|
@@ -145,7 +146,7 @@ function addLoadResourceTracking() {
|
|
|
145
146
|
list.getEntries()
|
|
146
147
|
.filter((entry) => !entry.responseStatus || entry.responseStatus < 400)
|
|
147
148
|
.filter((entry) => window.location.hostname === new URL(entry.name).hostname)
|
|
148
|
-
.filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html
|
|
149
|
+
.filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html$|\\.json|graphql)'))
|
|
149
150
|
.forEach((entry) => {
|
|
150
151
|
sampleRUM('loadresource', { source: entry.name, target: Math.round(entry.duration) });
|
|
151
152
|
});
|
|
@@ -154,6 +155,7 @@ function addLoadResourceTracking() {
|
|
|
154
155
|
.forEach((entry) => {
|
|
155
156
|
sampleRUM('missingresource', { source: entry.name, target: entry.hostname });
|
|
156
157
|
});
|
|
158
|
+
/* c8 ignore next 3 */
|
|
157
159
|
} catch (error) {
|
|
158
160
|
// something went wrong
|
|
159
161
|
}
|
|
@@ -188,6 +190,7 @@ function getIntersectionObsever(checkpoint) {
|
|
|
188
190
|
const source = sourceSelector(entry.target);
|
|
189
191
|
sampleRUM(checkpoint, { target, source });
|
|
190
192
|
});
|
|
193
|
+
/* c8 ignore next 3 */
|
|
191
194
|
} catch (error) {
|
|
192
195
|
// something went wrong
|
|
193
196
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-rum-enhancer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.1",
|
|
4
4
|
"description": "Helix RUM Enhancer",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"setup-playwright": "npx playwright install --with-deps chromium firefox webkit",
|
|
9
|
-
"test": "npm run setup-playwright && web-test-runner --node-resolve --coverage --playwright --browsers chromium firefox webkit",
|
|
10
|
-
"test:ci": "npm run setup-playwright && web-test-runner --node-resolve --coverage --playwright --browsers chromium firefox webkit",
|
|
9
|
+
"test": "npm run build-bundle && npm run setup-playwright && web-test-runner --node-resolve --coverage --playwright --browsers chromium firefox webkit",
|
|
10
|
+
"test:ci": "npm run build-bundle && npm run setup-playwright && web-test-runner --node-resolve --coverage --playwright --browsers chromium firefox webkit",
|
|
11
11
|
"test:watch": "web-test-runner --node-resolve --playwright --coverage --watch",
|
|
12
12
|
"lint": "eslint .",
|
|
13
13
|
"docs": "npx jsdoc2md -c .jsdoc.json --files 'src/*.js' > docs/API.md",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@adobe/eslint-config-helix": "2.0.6",
|
|
37
|
+
"@adobe/helix-rum-js": "2.1.4",
|
|
37
38
|
"@esm-bundle/chai": "4.3.4-fix.0",
|
|
38
39
|
"@semantic-release/changelog": "6.0.3",
|
|
39
40
|
"@semantic-release/git": "10.0.1",
|
|
@@ -47,16 +48,17 @@
|
|
|
47
48
|
"eslint": "8.57.0",
|
|
48
49
|
"eslint-plugin-header": "3.1.1",
|
|
49
50
|
"eslint-plugin-import": "2.29.1",
|
|
50
|
-
"husky": "9.
|
|
51
|
-
"jsdoc-to-markdown": "8.0.
|
|
52
|
-
"junit-report-builder": "
|
|
51
|
+
"husky": "9.1.3",
|
|
52
|
+
"jsdoc-to-markdown": "8.0.3",
|
|
53
|
+
"junit-report-builder": "4.0.0",
|
|
53
54
|
"lint-staged": "15.2.7",
|
|
54
|
-
"mocha": "10.
|
|
55
|
+
"mocha": "10.7.0",
|
|
55
56
|
"mocha-multi-reporters": "1.5.1",
|
|
56
|
-
"rollup": "4.
|
|
57
|
+
"rollup": "4.19.1",
|
|
57
58
|
"rollup-plugin-cleanup": "3.2.1",
|
|
58
59
|
"rollup-plugin-eslint-bundle": "9.0.0",
|
|
59
|
-
"semantic-release": "24.0.0"
|
|
60
|
+
"semantic-release": "24.0.0",
|
|
61
|
+
"web-vitals": "4.2.2"
|
|
60
62
|
},
|
|
61
63
|
"lint-staged": {
|
|
62
64
|
"*.js": "eslint",
|
package/rollup.config.js
CHANGED
|
@@ -45,6 +45,13 @@ export default [...bundles.map(({ outputFile, source }) => ({
|
|
|
45
45
|
exports: 'auto',
|
|
46
46
|
banner,
|
|
47
47
|
},
|
|
48
|
+
{
|
|
49
|
+
file: `${outputFile}.map.js`,
|
|
50
|
+
format: 'iife',
|
|
51
|
+
sourcemap: 'inline',
|
|
52
|
+
exports: 'auto',
|
|
53
|
+
banner,
|
|
54
|
+
},
|
|
48
55
|
],
|
|
49
56
|
plugins: [
|
|
50
57
|
cleanup({
|
package/src/index.js
CHANGED
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const KNOWN_PROPERTIES = ['weight', 'id', 'referer', 'checkpoint', 't', 'source', 'target', 'cwv', 'CLS', 'FID', 'LCP', 'INP', 'TTFB'];
|
|
19
|
-
const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource', 'utm', 'paid'];
|
|
19
|
+
const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource', 'utm', 'paid', 'email'];
|
|
20
20
|
|
|
21
21
|
const fflags = {
|
|
22
|
-
has: (flag) =>
|
|
23
|
-
.
|
|
24
|
-
|
|
22
|
+
has: (flag) => !!window.origin.match(/localhost/)
|
|
23
|
+
|| fflags[flag].indexOf(Array.from(window.origin)
|
|
24
|
+
.map((a) => a.charCodeAt(0))
|
|
25
|
+
.reduce((a, b) => a + b, 1) % 1371) !== -1,
|
|
25
26
|
enabled: (flag, callback) => fflags.has(flag) && callback(),
|
|
26
27
|
disabled: (flag, callback) => !fflags.has(flag) && callback(),
|
|
27
28
|
onetrust: [543, 770, 1136],
|
|
28
|
-
email: [1139, 543],
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const urlSanitizers = {
|
|
@@ -132,7 +132,6 @@
|
|
|
132
132
|
function getCollectionConfig() {
|
|
133
133
|
// eslint-disable-next-line max-len
|
|
134
134
|
fflags.enabled('onetrust', () => DEFAULT_TRACKING_EVENTS.push('consent'));
|
|
135
|
-
fflags.enabled('email', () => DEFAULT_TRACKING_EVENTS.push('email'));
|
|
136
135
|
return DEFAULT_TRACKING_EVENTS;
|
|
137
136
|
}
|
|
138
137
|
|
|
@@ -246,7 +245,7 @@
|
|
|
246
245
|
list.getEntries()
|
|
247
246
|
.filter((entry) => !entry.responseStatus || entry.responseStatus < 400)
|
|
248
247
|
.filter((entry) => window.location.hostname === new URL(entry.name).hostname)
|
|
249
|
-
.filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html
|
|
248
|
+
.filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html$|\\.json|graphql)'))
|
|
250
249
|
.forEach((entry) => {
|
|
251
250
|
sampleRUM('loadresource', { source: entry.name, target: Math.round(entry.duration) });
|
|
252
251
|
});
|
|
@@ -10,16 +10,54 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
export default {
|
|
13
|
+
testFramework: {
|
|
14
|
+
type: 'mocha',
|
|
15
|
+
config: {
|
|
16
|
+
timeout: 10000,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
13
19
|
coverageConfig: {
|
|
14
20
|
report: true,
|
|
15
21
|
reportDir: 'coverage',
|
|
16
22
|
exclude: [
|
|
17
23
|
'test/fixtures/**',
|
|
18
24
|
'node_modules/**',
|
|
25
|
+
'.rum/**',
|
|
19
26
|
],
|
|
20
27
|
},
|
|
21
28
|
files: [
|
|
22
29
|
'test/**/*.test.{html,js}',
|
|
23
30
|
'test/*.test.{html,js}',
|
|
24
31
|
],
|
|
32
|
+
middleware: [
|
|
33
|
+
async function emulateRUM(context, next) {
|
|
34
|
+
if (context.url.startsWith('/src/index.map.js')) {
|
|
35
|
+
await next();
|
|
36
|
+
context.body = context.body
|
|
37
|
+
.replace(/navigator\.sendBeacon/g, 'fakeSendBeacon');
|
|
38
|
+
return true;
|
|
39
|
+
} else if (context.url.startsWith('/.rum')) {
|
|
40
|
+
if (context.url.startsWith('/.rum/@adobe/helix-rum-js@%5E2/dist/')
|
|
41
|
+
|| context.url.startsWith('/.rum/@adobe/helix-rum-js@^2/dist/')
|
|
42
|
+
) {
|
|
43
|
+
context.url = '/node_modules/@adobe/helix-rum-js/dist/rum-standalone.js';
|
|
44
|
+
await next();
|
|
45
|
+
context.body = context.body
|
|
46
|
+
.replace(/const weight.*/, 'const weight = 1;')
|
|
47
|
+
.replace(/navigator\.sendBeacon/g, 'fakeSendBeacon')
|
|
48
|
+
.replace('.rum/@adobe/helix-rum-enhancer@^2/src/index.js', 'src/index.map.js');
|
|
49
|
+
return true;
|
|
50
|
+
} else if (context.url.startsWith('/.rum/web-vitals')) {
|
|
51
|
+
context.url = '/node_modules/web-vitals/dist/web-vitals.iife.js';
|
|
52
|
+
await next();
|
|
53
|
+
return true;
|
|
54
|
+
} else if (context.url === '/.rum/1') {
|
|
55
|
+
// return a 201 response and do nothing
|
|
56
|
+
context.status = 201;
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return next();
|
|
61
|
+
},
|
|
62
|
+
],
|
|
25
63
|
};
|