@adobe/helix-rum-enhancer 1.11.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 CHANGED
@@ -12,5 +12,5 @@ module.exports = {
12
12
  }],
13
13
  ["@semantic-release/github", {}]
14
14
  ],
15
- branches: ['main', "1.x"],
15
+ branches: ['main', '1.x'],
16
16
  };
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  # [1.11.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.10.0...v1.11.0) (2024-01-17)
2
9
 
3
10
 
package/README.md CHANGED
@@ -4,10 +4,9 @@
4
4
 
5
5
  ## Status
6
6
  [![codecov](https://img.shields.io/codecov/c/github/adobe/helix-rum-enhancer.svg)](https://codecov.io/gh/adobe/helix-rum-enhancer)
7
- [![CircleCI](https://img.shields.io/circleci/project/github/adobe/helix-rum-enhancer.svg)](https://circleci.com/gh/adobe/helix-rum-enhancer)
7
+ [![GitHub Actions](https://img.shields.io/github/actions/workflow/status/adobe/helix-rum-enhancer/main.yaml)](https://github.com/adobe/helix-rum-enhancer/actions/workflows/main.yaml)
8
8
  [![GitHub license](https://img.shields.io/github/license/adobe/helix-rum-enhancer.svg)](https://github.com/adobe/helix-rum-enhancer/blob/master/LICENSE.txt)
9
9
  [![GitHub issues](https://img.shields.io/github/issues/adobe/helix-rum-enhancer.svg)](https://github.com/adobe/helix-rum-enhancer/issues)
10
- [![LGTM Code Quality Grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/adobe/helix-rum-enhancer.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/adobe/helix-rum-enhancer)
11
10
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](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.11.0",
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.5",
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
- ['CLS', 'FID', 'LCP', 'INP', 'TTFB']
97
- .map((metric) => window.webVitals[`get${metric}`])
98
- .filter((metric) => typeof metric === 'function')
99
- .forEach((invokeMetric) => {
100
- invokeMetric(storeCWV);
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
  }));