@adobe/helix-rum-enhancer 2.0.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,25 @@
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
+
11
+ # [2.1.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.0.0...v2.1.0) (2024-01-22)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **loadresource:** enable loadresource checkpoint for all origins ([0be8de7](https://github.com/adobe/helix-rum-enhancer/commit/0be8de7ee3e57afdd60a2b9af743bedd061e907d))
17
+
18
+
19
+ ### Features
20
+
21
+ * **observer:** enable tracking of JSON loading for all browsers that have a PerformanceObserver implementation ([45b5e64](https://github.com/adobe/helix-rum-enhancer/commit/45b5e6428fb9c51e8fc4d477c574d44a361b3ec2))
22
+
1
23
  # [2.0.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.9.1...v2.0.0) (2024-01-16)
2
24
 
3
25
 
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": "2.0.0",
3
+ "version": "2.1.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,20 +29,20 @@
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",
35
36
  "c8": "9.1.0",
36
37
  "codecov": "3.8.3",
37
- "eslint": "8.56.0",
38
+ "eslint": "8.57.0",
38
39
  "eslint-plugin-header": "3.1.1",
39
40
  "eslint-plugin-import": "2.29.1",
40
- "husky": "8.0.3",
41
- "jsdoc-to-markdown": "8.0.0",
42
- "junit-report-builder": "3.1.0",
43
- "lint-staged": "15.2.0",
44
- "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",
45
46
  "mocha-multi-reporters": "1.5.1",
46
47
  "semantic-release": "22.0.12"
47
48
  },
package/src/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
  /* eslint-env browser */
13
13
  const KNOWN_PROPERTIES = ['weight', 'id', 'referer', 'checkpoint', 't', 'source', 'target', 'cwv', 'CLS', 'FID', 'LCP', 'INP', 'TTFB'];
14
- const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia'];
14
+ const DEFAULT_TRACKING_EVENTS = ['click', 'cwv', 'form', 'enterleave', 'viewblock', 'viewmedia', 'loadresource'];
15
15
  const SESSION_STORAGE_KEY = 'aem-rum';
16
16
  const { sampleRUM, queue, isSelected } = window.hlx.rum;
17
17
 
@@ -67,10 +67,6 @@ function optedIn(checkpoint, data) {
67
67
  }
68
68
  // Gets configured collection from the config service for the current domain
69
69
  function getCollectionConfig() {
70
- if (window.location.hostname === 'blog.adobe.com') {
71
- return ['loadresource', ...DEFAULT_TRACKING_EVENTS];
72
- }
73
- // TODO: configured collection should come from config service
74
70
  return DEFAULT_TRACKING_EVENTS;
75
71
  }
76
72
 
@@ -111,14 +107,19 @@ function addCWVTracking() {
111
107
  data.cwv[measurement.name] = measurement.value;
112
108
  sampleRUM('cwv', data);
113
109
  };
110
+
111
+ const featureToggle = () => window.location.hostname === 'blog.adobe.com';
112
+ const isEager = (metric) => ['CLS', 'LCP'].includes(metric);
113
+
114
114
  // When loading `web-vitals` using a classic script, all the public
115
115
  // methods can be found on the `webVitals` global namespace.
116
- ['CLS', 'FID', 'LCP', 'INP', 'TTFB']
117
- .map((metric) => window.webVitals[`get${metric}`])
118
- .filter((metric) => typeof metric === 'function')
119
- .forEach((invokeMetric) => {
120
- invokeMetric(storeCWV);
121
- });
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
+ });
122
123
  };
123
124
  document.head.appendChild(script);
124
125
  }, 2000); // wait for delayed
@@ -157,18 +158,16 @@ function addEnterLeaveTracking() {
157
158
  }
158
159
 
159
160
  function addLoadResourceTracking() {
160
- if (window.location.hostname === 'blog.adobe.com') {
161
- const observer = new PerformanceObserver((list) => {
162
- list.getEntries()
163
- .filter((entry) => !entry.responseStatus || entry.responseStatus < 400)
164
- .filter((entry) => window.location.hostname === new URL(entry.name).hostname)
165
- .filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html|\\.json)$'))
166
- .forEach((entry) => {
167
- sampleRUM('loadresource', { source: entry.name, target: Math.round(entry.duration) });
168
- });
169
- });
170
- observer.observe({ type: 'resource', buffered: true });
171
- }
161
+ const observer = new PerformanceObserver((list) => {
162
+ list.getEntries()
163
+ .filter((entry) => !entry.responseStatus || entry.responseStatus < 400)
164
+ .filter((entry) => window.location.hostname === new URL(entry.name).hostname)
165
+ .filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html|\\.json)$'))
166
+ .forEach((entry) => {
167
+ sampleRUM('loadresource', { source: entry.name, target: Math.round(entry.duration) });
168
+ });
169
+ });
170
+ observer.observe({ type: 'resource', buffered: true });
172
171
  }
173
172
 
174
173
  function activateBlocksMutationObserver() {