@adobe/helix-rum-enhancer 2.1.0 → 2.1.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,13 @@
1
+ ## [2.1.1](https://github.com/adobe/helix-rum-enhancer/compare/v2.1.0...v2.1.1) (2024-02-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **cwv:** only report LCP and CLS eagerly ([9d44949](https://github.com/adobe/helix-rum-enhancer/commit/9d44949701865242ac44255d5080f52b22be2b72))
7
+ * **cwv:** report metrics eagerly ([4cfcad9](https://github.com/adobe/helix-rum-enhancer/commit/4cfcad9e8271a2a3c4571db419e26857b72d0c6d))
8
+ * **cwv:** small change ([542fd6a](https://github.com/adobe/helix-rum-enhancer/commit/542fd6a050fdb911b4fb5faad7f83d0843af4d1e))
9
+ * **cwv:** small change ([3a41b52](https://github.com/adobe/helix-rum-enhancer/commit/3a41b52676484d44585e8b0debe7352fe7a2e5ac))
10
+
1
11
  # [2.1.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.0.0...v2.1.0) (2024-01-22)
2
12
 
3
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -9,7 +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",
12
+ "semantic-release-dry": "semantic-release --dry-run --branches $CI_BRANCH 1.x main",
13
13
  "prepare": "husky install"
14
14
  },
15
15
  "repository": {
@@ -29,20 +29,20 @@
29
29
  "reporter-options": "configFile=.mocha-multi.json"
30
30
  },
31
31
  "devDependencies": {
32
- "@adobe/eslint-config-helix": "2.0.5",
32
+ "@adobe/eslint-config-helix": "2.0.6",
33
33
  "@semantic-release/changelog": "6.0.3",
34
34
  "@semantic-release/git": "10.0.1",
35
35
  "@semantic-release/npm": "11.0.2",
36
36
  "c8": "9.1.0",
37
37
  "codecov": "3.8.3",
38
- "eslint": "8.56.0",
38
+ "eslint": "8.57.0",
39
39
  "eslint-plugin-header": "3.1.1",
40
40
  "eslint-plugin-import": "2.29.1",
41
- "husky": "8.0.3",
42
- "jsdoc-to-markdown": "8.0.0",
43
- "junit-report-builder": "3.1.0",
44
- "lint-staged": "15.2.0",
45
- "mocha": "10.2.0",
41
+ "husky": "9.0.11",
42
+ "jsdoc-to-markdown": "8.0.1",
43
+ "junit-report-builder": "3.2.1",
44
+ "lint-staged": "15.2.2",
45
+ "mocha": "10.3.0",
46
46
  "mocha-multi-reporters": "1.5.1",
47
47
  "semantic-release": "22.0.12"
48
48
  },
package/src/index.js CHANGED
@@ -107,14 +107,19 @@ function addCWVTracking() {
107
107
  data.cwv[measurement.name] = measurement.value;
108
108
  sampleRUM('cwv', data);
109
109
  };
110
+
111
+ const featureToggle = () => window.location.hostname === 'blog.adobe.com';
112
+ const isEager = (metric) => ['CLS', 'LCP'].includes(metric);
113
+
110
114
  // When loading `web-vitals` using a classic script, all the public
111
115
  // methods can be found on the `webVitals` global namespace.
112
- ['CLS', 'FID', 'LCP', 'INP', 'TTFB']
113
- .map((metric) => window.webVitals[`get${metric}`])
114
- .filter((metric) => typeof metric === 'function')
115
- .forEach((invokeMetric) => {
116
- invokeMetric(storeCWV);
117
- });
116
+ ['FID', 'INP', 'TTFB', 'CLS', 'LCP'].forEach((metric) => {
117
+ const metricFn = window.webVitals[`on${metric}`];
118
+ if (typeof metricFn === 'function') {
119
+ const opts = isEager(metric) ? { reportAllChanges: featureToggle() } : undefined;
120
+ metricFn(storeCWV, opts);
121
+ }
122
+ });
118
123
  };
119
124
  document.head.appendChild(script);
120
125
  }, 2000); // wait for delayed