@adobe/helix-rum-enhancer 1.7.0 → 1.8.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/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## [1.8.1](https://github.com/adobe/helix-rum-enhancer/compare/v1.8.0...v1.8.1) (2023-11-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **navigate:** do not navigate on load ([7873379](https://github.com/adobe/helix-rum-enhancer/commit/7873379bb89b950a0efeb07ff11a89714474bfb6))
7
+
8
+ # [1.8.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.7.0...v1.8.0) (2023-11-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **navigation:** use correct buffered perf observer ([39ed811](https://github.com/adobe/helix-rum-enhancer/commit/39ed811cdb6ccf5471b30a0d147317c724c4220c))
14
+
15
+
16
+ ### Features
17
+
18
+ * **navigate:** refine checkpoints for `enter`, `navigate`, `reload`, `back_forward`, and `prerender`, track `visibilityState` ([70f622a](https://github.com/adobe/helix-rum-enhancer/commit/70f622a62aa93ff96219420b5c5357348b9ef050))
19
+
1
20
  # [1.7.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.6.0...v1.7.0) (2023-10-31)
2
21
 
3
22
 
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.7.0",
3
+ "version": "1.8.1",
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.4",
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.52.0",
37
+ "eslint": "8.54.0",
38
38
  "eslint-plugin-header": "3.1.1",
39
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.2",
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,23 @@ 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
+
65
+ new PerformanceObserver((list) => list
66
+ .getEntries().map((entry) => navigate(document.referrer, entry.type)))
67
+ .observe({ type: 'navigation', buffered: true });
55
68
 
56
69
  sampleRUM.targetselector = (element) => {
57
70
  let value = element.getAttribute('href') || element.currentSrc || element.getAttribute('src')
@@ -139,6 +152,7 @@ if (window.location.hostname === 'blog.adobe.com') {
139
152
  const observer = new PerformanceObserver((list) => {
140
153
  list.getEntries()
141
154
  .filter((entry) => !entry.responseStatus || entry.responseStatus < 400)
155
+ .filter((entry) => window.location.hostname === new URL(entry.name).hostname)
142
156
  .filter((entry) => new URL(entry.name).pathname.match('.*(\\.plain\\.html|\\.json)$'))
143
157
  .forEach((entry) => {
144
158
  sampleRUM('loadresource', { source: entry.name, target: Math.round(entry.duration) });