@adobe/helix-rum-enhancer 1.10.0 → 1.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/.releaserc.cjs +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +1 -2
- package/package.json +3 -2
- package/src/index.js +21 -19
package/.releaserc.cjs
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.11.1](https://github.com/adobe/helix-rum-enhancer/compare/v1.11.0...v1.11.1) (2024-02-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **cwv:** report metrics eagerly ([b7a7e3e](https://github.com/adobe/helix-rum-enhancer/commit/b7a7e3e202f8dc4de97994cdf36ece95075082c4))
|
|
7
|
+
|
|
8
|
+
# [1.11.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.10.0...v1.11.0) (2024-01-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **observer:** enable tracking of JSON loading for all browsers that have a PerformanceObserver implementation ([c049f93](https://github.com/adobe/helix-rum-enhancer/commit/c049f930f0cc1dc548e42bd8e76cd97709a873d7))
|
|
14
|
+
|
|
1
15
|
# [1.10.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.9.1...v1.10.0) (2024-01-16)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
## Status
|
|
6
6
|
[](https://codecov.io/gh/adobe/helix-rum-enhancer)
|
|
7
|
-
[](https://github.com/adobe/helix-rum-enhancer/actions/workflows/main.yaml)
|
|
8
8
|
[](https://github.com/adobe/helix-rum-enhancer/blob/master/LICENSE.txt)
|
|
9
9
|
[](https://github.com/adobe/helix-rum-enhancer/issues)
|
|
10
|
-
[](https://lgtm.com/projects/g/adobe/helix-rum-enhancer)
|
|
11
10
|
[](https://github.com/semantic-release/semantic-release)
|
|
12
11
|
|
|
13
12
|
## Usage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-rum-enhancer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "Helix RUM Enhancer",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"lint": "eslint .",
|
|
10
10
|
"docs": "npx jsdoc2md -c .jsdoc.json --files 'src/*.js' > docs/API.md",
|
|
11
11
|
"semantic-release": "semantic-release",
|
|
12
|
+
"semantic-release-dry": "semantic-release --dry-run --branches $CI_BRANCH 1.x main",
|
|
12
13
|
"prepare": "husky install"
|
|
13
14
|
},
|
|
14
15
|
"repository": {
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
"reporter-options": "configFile=.mocha-multi.json"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@adobe/eslint-config-helix": "2.0.
|
|
32
|
+
"@adobe/eslint-config-helix": "2.0.6",
|
|
32
33
|
"@semantic-release/changelog": "6.0.3",
|
|
33
34
|
"@semantic-release/git": "10.0.1",
|
|
34
35
|
"@semantic-release/npm": "11.0.2",
|
package/src/index.js
CHANGED
|
@@ -91,14 +91,19 @@ sampleRUM.drain('cwv', (() => {
|
|
|
91
91
|
data.cwv[measurement.name] = measurement.value;
|
|
92
92
|
sampleRUM('cwv', data);
|
|
93
93
|
};
|
|
94
|
+
|
|
95
|
+
const featureToggle = () => window.location.hostname === 'blog.adobe.com';
|
|
96
|
+
const isEager = (metric) => ['CLS', 'LCP'].includes(metric);
|
|
97
|
+
|
|
94
98
|
// When loading `web-vitals` using a classic script, all the public
|
|
95
99
|
// methods can be found on the `webVitals` global namespace.
|
|
96
|
-
['
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
100
|
+
['FID', 'INP', 'TTFB', 'CLS', 'LCP'].forEach((metric) => {
|
|
101
|
+
const metricFn = window.webVitals[`on${metric}`];
|
|
102
|
+
if (typeof metricFn === 'function') {
|
|
103
|
+
const opts = isEager(metric) ? { reportAllChanges: featureToggle() } : undefined;
|
|
104
|
+
metricFn(storeCWV, opts);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
102
107
|
};
|
|
103
108
|
document.head.appendChild(script);
|
|
104
109
|
}));
|
|
@@ -137,7 +142,6 @@ sampleRUM.sourceselector = (element) => {
|
|
|
137
142
|
if (Array.from(element.classList).some((className) => className.match(/button|cta/))) {
|
|
138
143
|
return blockName ? `.${blockName} .button` : '.button';
|
|
139
144
|
}
|
|
140
|
-
|
|
141
145
|
return sampleRUM.sourceselector(element.parentElement);
|
|
142
146
|
};
|
|
143
147
|
|
|
@@ -155,15 +159,13 @@ document.querySelectorAll('form').forEach((form) => {
|
|
|
155
159
|
window.addEventListener('visibilitychange', ((event) => sampleRUM.leave(event)));
|
|
156
160
|
window.addEventListener('pagehide', ((event) => sampleRUM.leave(event)));
|
|
157
161
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
observer.observe({ type: 'resource', buffered: true });
|
|
169
|
-
}
|
|
162
|
+
const observer = new PerformanceObserver((list) => {
|
|
163
|
+
list.getEntries()
|
|
164
|
+
.filter((entry) => !entry.responseStatus || entry.responseStatus < 400)
|
|
165
|
+
.filter((entry) => window.location.hostname === new URL(entry.name).hostname)
|
|
166
|
+
.filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html|\\.json)$'))
|
|
167
|
+
.forEach((entry) => {
|
|
168
|
+
sampleRUM('loadresource', { source: entry.name, target: Math.round(entry.duration) });
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
observer.observe({ type: 'resource', buffered: true });
|