@adobe/helix-rum-enhancer 2.28.0 → 2.30.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.30.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.29.0...v2.30.0) (2025-01-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **missingresource:** report all resource error with http status code ([e238136](https://github.com/adobe/helix-rum-enhancer/commit/e238136c46a9801be1e3ce7887c7b4b292cbcf5b))
7
+
8
+ # [2.29.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.28.0...v2.29.0) (2025-01-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * **loadresource:** add `allresources` feature flag that enables tracking all resources, not just same host ([7c536d7](https://github.com/adobe/helix-rum-enhancer/commit/7c536d7b8ec77c40c4b9868dd3dff53c39529699))
14
+
1
15
  # [2.28.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.27.0...v2.28.0) (2025-01-02)
2
16
 
3
17
 
package/modules/fflags.js CHANGED
@@ -9,16 +9,15 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
+ const h = (s, a) => [...s].reduce((p, c) => p + c.charCodeAt(0), a) % 1371;
13
+
12
14
  export const fflags = {
13
- has: (flag) => fflags[flag].indexOf(Array.from(window.origin)
14
- .map((a) => a.charCodeAt(0))
15
- .reduce((a, b) => a + b, 1) % 1371) !== -1
16
- || !!window.origin.match(/localhost/),
17
- enabled: (flag, callback) => fflags.has(flag) && callback(),
18
- /* c8 ignore next */
19
- disabled: (flag, callback) => !fflags.has(flag) && callback(),
15
+ has: (f) => fflags[f].includes(h(window.origin, 1)) || /localhost/.test(window.origin),
16
+ enabled: (f, c) => fflags.has(f) && c(),
17
+ disabled: (f, c) => !fflags.has(f) && c(),
20
18
  eagercwv: [683],
21
19
  redirect: [620, 1139],
22
20
  example: [543, 770, 1136],
23
21
  language: [543, 959, 1139, 620],
22
+ allresources: [1139],
24
23
  };
package/modules/index.js CHANGED
@@ -162,15 +162,15 @@ function addLoadResourceTracking() {
162
162
  try {
163
163
  list.getEntries()
164
164
  .filter((e) => !e.responseStatus || e.responseStatus < 400)
165
- .filter((e) => window.location.hostname === new URL(e.name).hostname)
165
+ .filter((e) => window.location.hostname === new URL(e.name).hostname || fflags.has('allresources'))
166
166
  .filter((e) => new URL(e.name).pathname.match('.*(\\.plain\\.html$|\\.json|graphql|api)'))
167
167
  .forEach((e) => {
168
168
  sampleRUM('loadresource', { source: e.name, target: Math.round(e.duration) });
169
169
  });
170
170
  list.getEntries()
171
- .filter((e) => e.responseStatus === 404)
171
+ .filter((e) => e.responseStatus >= 400)
172
172
  .forEach((e) => {
173
- sampleRUM('missingresource', { source: e.name, target: e.hostname });
173
+ sampleRUM('missingresource', { source: e.name, target: e.responseStatus });
174
174
  });
175
175
  /* c8 ignore next 3 */
176
176
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.28.0",
3
+ "version": "2.30.0",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -41,6 +41,7 @@
41
41
  "@semantic-release/npm": "12.0.1",
42
42
  "@web/test-runner": "0.19.0",
43
43
  "@web/test-runner-commands": "0.9.0",
44
+ "@web/test-runner-junit-reporter": "0.7.2",
44
45
  "@web/test-runner-mocha": "0.9.0",
45
46
  "@web/test-runner-playwright": "0.11.0",
46
47
  "c8": "10.1.3",
@@ -54,11 +55,11 @@
54
55
  "lint-staged": "15.3.0",
55
56
  "mocha": "11.0.1",
56
57
  "mocha-multi-reporters": "1.5.1",
57
- "rollup": "4.29.1",
58
+ "rollup": "4.30.1",
58
59
  "rollup-plugin-checksum": "1.0.1",
59
60
  "rollup-plugin-cleanup": "3.2.1",
60
61
  "rollup-plugin-eslint-bundle": "9.0.0",
61
- "semantic-release": "24.2.0",
62
+ "semantic-release": "24.2.1",
62
63
  "semantic-release-slack-bot": "^4.0.2",
63
64
  "web-vitals": "4.2.4"
64
65
  },
package/src/index.js CHANGED
@@ -12,17 +12,16 @@
12
12
  (function () {
13
13
  'use strict';
14
14
 
15
+ const h = (s, a) => [...s].reduce((p, c) => p + c.charCodeAt(0), a) % 1371;
15
16
  const fflags = {
16
- has: (flag) => fflags[flag].indexOf(Array.from(window.origin)
17
- .map((a) => a.charCodeAt(0))
18
- .reduce((a, b) => a + b, 1) % 1371) !== -1
19
- || !!window.origin.match(/localhost/),
20
- enabled: (flag, callback) => fflags.has(flag) && callback(),
21
- disabled: (flag, callback) => !fflags.has(flag) && callback(),
17
+ has: (f) => fflags[f].includes(h(window.origin, 1)) || /localhost/.test(window.origin),
18
+ enabled: (f, c) => fflags.has(f) && c(),
19
+ disabled: (f, c) => !fflags.has(f) && c(),
22
20
  eagercwv: [683],
23
21
  redirect: [620, 1139],
24
22
  example: [543, 770, 1136],
25
23
  language: [543, 959, 1139, 620],
24
+ allresources: [1139],
26
25
  };
27
26
 
28
27
  const KNOWN_PROPERTIES = ['weight', 'id', 'referer', 'checkpoint', 't', 'source', 'target', 'cwv', 'CLS', 'FID', 'LCP', 'INP', 'TTFB'];
@@ -309,15 +308,15 @@
309
308
  try {
310
309
  list.getEntries()
311
310
  .filter((e) => !e.responseStatus || e.responseStatus < 400)
312
- .filter((e) => window.location.hostname === new URL(e.name).hostname)
311
+ .filter((e) => window.location.hostname === new URL(e.name).hostname || fflags.has('allresources'))
313
312
  .filter((e) => new URL(e.name).pathname.match('.*(\\.plain\\.html$|\\.json|graphql|api)'))
314
313
  .forEach((e) => {
315
314
  sampleRUM('loadresource', { source: e.name, target: Math.round(e.duration) });
316
315
  });
317
316
  list.getEntries()
318
- .filter((e) => e.responseStatus === 404)
317
+ .filter((e) => e.responseStatus >= 400)
319
318
  .forEach((e) => {
320
- sampleRUM('missingresource', { source: e.name, target: e.hostname });
319
+ sampleRUM('missingresource', { source: e.name, target: e.responseStatus });
321
320
  });
322
321
  } catch (error) {
323
322
  }
package/src/index.md5 CHANGED
@@ -1 +1 @@
1
- 2b54b4b328b08aa2e60c2ffb42edd06b
1
+ 5424a86261f2304969b6951549ac3941
@@ -9,7 +9,19 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
+
13
+ // eslint-disable-next-line import/no-extraneous-dependencies
14
+ import { defaultReporter } from '@web/test-runner';
15
+ // eslint-disable-next-line import/no-extraneous-dependencies
16
+ import { junitReporter } from '@web/test-runner-junit-reporter';
17
+
12
18
  export default {
19
+ nodeResolve: true,
20
+ coverage: true,
21
+ reporters: [
22
+ defaultReporter(),
23
+ junitReporter(),
24
+ ],
13
25
  testFramework: {
14
26
  type: 'mocha',
15
27
  config: {
@@ -23,7 +35,7 @@ export default {
23
35
  'test/fixtures/**',
24
36
  'node_modules/**',
25
37
  '.rum/**',
26
- 'src/**',
38
+ 'src/index.js',
27
39
  ],
28
40
  },
29
41
  files: [