@adobe/helix-rum-enhancer 1.6.0 → 1.8.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,23 @@
1
+ # [1.8.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.7.0...v1.8.0) (2023-11-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **navigation:** use correct buffered perf observer ([39ed811](https://github.com/adobe/helix-rum-enhancer/commit/39ed811cdb6ccf5471b30a0d147317c724c4220c))
7
+
8
+
9
+ ### Features
10
+
11
+ * **navigate:** refine checkpoints for `enter`, `navigate`, `reload`, `back_forward`, and `prerender`, track `visibilityState` ([70f622a](https://github.com/adobe/helix-rum-enhancer/commit/70f622a62aa93ff96219420b5c5357348b9ef050))
12
+
13
+ # [1.7.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.6.0...v1.7.0) (2023-10-31)
14
+
15
+
16
+ ### Features
17
+
18
+ * **checkpoint:** new loadresource checkpoint ([d818efc](https://github.com/adobe/helix-rum-enhancer/commit/d818efc854241119979300387b3dcd4d59c6c8f5))
19
+ * **checkpoint:** introduce new resource checkpoint ([2845a20](https://github.com/adobe/helix-rum-enhancer/commit/2845a202281c09f1c75b4e8a52de000663410b1c))
20
+
1
21
  # [1.6.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.5.0...v1.6.0) (2023-10-18)
2
22
 
3
23
 
package/README.md CHANGED
@@ -19,7 +19,7 @@ It will add following new checkpoints:
19
19
  - `cwv`: Core Web Vitals Collection
20
20
  - `click`: A click anywhere in the document
21
21
  - `viewblock`: A Helix block has been scrolled into the viewport
22
- - `viewmedia`: An image or viedo hosted by Helix Media Bus has been scrolled into the viewport
22
+ - `viewmedia`: An image or video hosted by Helix Media Bus has been scrolled into the viewport
23
23
  - `enter`: when page loads and the referrer is different than the current page.
24
24
 
25
25
  ## Development
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -28,22 +28,22 @@
28
28
  "reporter-options": "configFile=.mocha-multi.json"
29
29
  },
30
30
  "devDependencies": {
31
- "@adobe/eslint-config-helix": "2.0.3",
31
+ "@adobe/eslint-config-helix": "2.0.5",
32
32
  "@semantic-release/changelog": "6.0.3",
33
33
  "@semantic-release/git": "10.0.1",
34
- "@semantic-release/npm": "11.0.0",
34
+ "@semantic-release/npm": "11.0.1",
35
35
  "c8": "8.0.1",
36
36
  "codecov": "3.8.3",
37
- "eslint": "8.51.0",
37
+ "eslint": "8.54.0",
38
38
  "eslint-plugin-header": "3.1.1",
39
- "eslint-plugin-import": "2.28.1",
39
+ "eslint-plugin-import": "2.29.0",
40
40
  "husky": "8.0.3",
41
41
  "jsdoc-to-markdown": "8.0.0",
42
42
  "junit-report-builder": "3.1.0",
43
- "lint-staged": "15.0.1",
43
+ "lint-staged": "15.1.0",
44
44
  "mocha": "10.2.0",
45
45
  "mocha-multi-reporters": "1.5.1",
46
- "semantic-release": "22.0.5"
46
+ "semantic-release": "22.0.8"
47
47
  },
48
48
  "lint-staged": {
49
49
  "*.js": "eslint",
package/src/index.js CHANGED
@@ -48,10 +48,24 @@ sampleRUM.drain('observe', ((elements) => {
48
48
  });
49
49
  }));
50
50
 
51
- // enter checkpoint when referrer is not the current page url
52
- if (!!document.referrer && (document.referrer !== window.location.href)) {
53
- sampleRUM('enter', { target: undefined, source: document.referrer });
54
- }
51
+ const navigate = (source, type) => {
52
+ const payload = { source, target: document.visibilityState };
53
+ // reload: same page, navigate: same origin, enter: everything else
54
+ if (type === 'reload' || source === window.location.href) {
55
+ sampleRUM('reload', payload);
56
+ } else if (type !== 'navigate') {
57
+ sampleRUM(type, payload); // back, forward, prerender, etc.
58
+ } else if (source && window.location.origin === new URL(source).origin) {
59
+ sampleRUM('navigate', payload); // internal navigation
60
+ } else {
61
+ sampleRUM('enter', payload); // enter site
62
+ }
63
+ };
64
+ navigate(document.referrer);
65
+
66
+ new PerformanceObserver((list) => list
67
+ .getEntries().map((entry) => navigate(document.referrer, entry.type)))
68
+ .observe({ type: 'navigation', buffered: true });
55
69
 
56
70
  sampleRUM.targetselector = (element) => {
57
71
  let value = element.getAttribute('href') || element.currentSrc || element.getAttribute('src')
@@ -134,3 +148,16 @@ document.querySelectorAll('form').forEach((form) => {
134
148
 
135
149
  window.addEventListener('visibilitychange', ((event) => sampleRUM.leave(event)));
136
150
  window.addEventListener('pagehide', ((event) => sampleRUM.leave(event)));
151
+
152
+ if (window.location.hostname === 'blog.adobe.com') {
153
+ const observer = new PerformanceObserver((list) => {
154
+ list.getEntries()
155
+ .filter((entry) => !entry.responseStatus || entry.responseStatus < 400)
156
+ .filter((entry) => window.location.hostname === new URL(entry.name).hostname)
157
+ .filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html|\\.json)$'))
158
+ .forEach((entry) => {
159
+ sampleRUM('loadresource', { source: entry.name, target: Math.round(entry.duration) });
160
+ });
161
+ });
162
+ observer.observe({ type: 'resource', buffered: true });
163
+ }