@adobe/helix-rum-enhancer 2.25.0 → 2.26.0-beta.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
@@ -29,5 +29,5 @@ module.exports = {
29
29
  slackChannel: "rum-explorers",
30
30
  }],
31
31
  ],
32
- branches: ['main'],
32
+ branches: ['main', { name: 'beta', prerelease: true }],
33
33
  };
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [2.26.0-beta.1](https://github.com/adobe/helix-rum-enhancer/compare/v2.25.0...v2.26.0-beta.1) (2024-10-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * handle pre-rendering ([bb11187](https://github.com/adobe/helix-rum-enhancer/commit/bb11187058b8cb521a270c316323b66414a8d817))
7
+
1
8
  # [2.25.0](https://github.com/adobe/helix-rum-enhancer/compare/v2.24.0...v2.25.0) (2024-10-03)
2
9
 
3
10
 
package/modules/index.js CHANGED
@@ -112,9 +112,21 @@ function addCWVTracking() {
112
112
  function addNavigationTracking() {
113
113
  // enter checkpoint when referrer is not the current page url
114
114
  const navigate = (source, type, redirectCount) => {
115
+ // target can be 'visible', 'hidden' (background tab) or 'prerendered' (speculation rules)
115
116
  const payload = { source, target: document.visibilityState };
116
- // reload: same page, navigate: same origin, enter: everything else
117
- if (type === 'reload' || source === window.location.href) {
117
+ if (document.prerendering) {
118
+ // listen for "activation" of the current pre-rendered page
119
+ document.addEventListener('prerenderingchange', () => {
120
+ // pre-rendered page is now "activated"
121
+ payload.target = 'prerendered';
122
+ sampleRUM('navigate', payload); // prerendered navigation
123
+ }, {
124
+ once: true,
125
+ });
126
+ if (type === 'navigate') {
127
+ sampleRUM('prerender', payload); // prerendering page
128
+ }
129
+ } else if (type === 'reload' || source === window.location.href) {
118
130
  sampleRUM('reload', payload);
119
131
  } else if (type && type !== 'navigate') {
120
132
  sampleRUM(type, payload); // back, forward, prerender, etc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.25.0",
3
+ "version": "2.26.0-beta.1",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "build-bundle": "rollup --config",
15
15
  "prepack": "npm run build-bundle",
16
16
  "semantic-release": "semantic-release",
17
- "semantic-release-dry": "semantic-release --dry-run --branches $CI_BRANCH 1.x main",
17
+ "semantic-release-dry": "semantic-release --dry-run --branches $CI_BRANCH 1.x main beta",
18
18
  "prepare": "husky"
19
19
  },
20
20
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "reporter-options": "configFile=.mocha-multi.json"
34
34
  },
35
35
  "devDependencies": {
36
- "@adobe/eslint-config-helix": "2.0.7",
36
+ "@adobe/eslint-config-helix": "2.0.8",
37
37
  "@adobe/helix-rum-js": "2.6.0",
38
38
  "@esm-bundle/chai": "4.3.4-fix.0",
39
39
  "@semantic-release/changelog": "6.0.3",
@@ -47,7 +47,7 @@
47
47
  "codecov": "3.8.3",
48
48
  "eslint": "8.57.1",
49
49
  "eslint-plugin-header": "3.1.1",
50
- "eslint-plugin-import": "2.30.0",
50
+ "eslint-plugin-import": "2.31.0",
51
51
  "husky": "9.1.6",
52
52
  "jsdoc-to-markdown": "9.0.2",
53
53
  "junit-report-builder": "5.1.1",
package/src/index.js CHANGED
@@ -266,7 +266,17 @@
266
266
  function addNavigationTracking() {
267
267
  const navigate = (source, type, redirectCount) => {
268
268
  const payload = { source, target: document.visibilityState };
269
- if (type === 'reload' || source === window.location.href) {
269
+ if (document.prerendering) {
270
+ document.addEventListener('prerenderingchange', () => {
271
+ payload.target = 'prerendered';
272
+ sampleRUM('navigate', payload);
273
+ }, {
274
+ once: true,
275
+ });
276
+ if (type === 'navigate') {
277
+ sampleRUM('prerender', payload);
278
+ }
279
+ } else if (type === 'reload' || source === window.location.href) {
270
280
  sampleRUM('reload', payload);
271
281
  } else if (type && type !== 'navigate') {
272
282
  sampleRUM(type, payload);
package/src/index.md5 CHANGED
@@ -1 +1 @@
1
- f87fdcb7d5c1e4526225b185d4f392fb
1
+ 81557c0399da9e24aeac8f384303248a