@adobe/helix-rum-enhancer 2.31.0-beta.4 → 2.31.0-beta.5
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 +7 -0
- package/modules/index.js +10 -11
- package/package.json +1 -1
- package/src/index.js +7 -11
- package/src/index.md5 +1 -1
- package/src/plugins/cwv.md5 +1 -1
- package/src/plugins/form.md5 +1 -1
- package/src/plugins/video.md5 +1 -1
- package/web-test-runner.config.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [2.31.0-beta.5](https://github.com/adobe/helix-rum-enhancer/compare/v2.31.0-beta.4...v2.31.0-beta.5) (2025-01-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* just forcing a release ([84ab687](https://github.com/adobe/helix-rum-enhancer/commit/84ab68734b5862816a532d4847df0ffa753b0717))
|
|
7
|
+
|
|
1
8
|
# [2.31.0-beta.4](https://github.com/adobe/helix-rum-enhancer/compare/v2.31.0-beta.3...v2.31.0-beta.4) (2025-01-16)
|
|
2
9
|
|
|
3
10
|
|
package/modules/index.js
CHANGED
|
@@ -29,16 +29,18 @@ const [blocksMO, mediaMO] = [blocksMCB, mediaMCB].map(createMO);
|
|
|
29
29
|
// Check for the presence of a given cookie
|
|
30
30
|
const hasCookieKey = (key) => () => document.cookie.split(';').some((c) => c.trim().startsWith(`${key}=`));
|
|
31
31
|
|
|
32
|
+
// Set the base path for the plugins
|
|
32
33
|
const pluginBasePath = new URL(document.currentScript.src).href.replace(/index(\.map)?\.js/, 'plugins');
|
|
33
34
|
|
|
34
35
|
const PLUGINS = {
|
|
35
36
|
cwv: `${pluginBasePath}/cwv.js`,
|
|
36
37
|
// Interactive elements
|
|
37
|
-
form: { url: `${pluginBasePath}/form.js`,
|
|
38
|
-
video: { url: `${pluginBasePath}/video.js`,
|
|
38
|
+
form: { url: `${pluginBasePath}/form.js`, when: () => document.querySelector('form'), isBlockDependent: true },
|
|
39
|
+
video: { url: `${pluginBasePath}/video.js`, when: () => document.querySelector('video'), isBlockDependent: true },
|
|
39
40
|
// Martech
|
|
40
|
-
martech: { url: `${pluginBasePath}/martech.js`,
|
|
41
|
-
onetrust: { url: `${pluginBasePath}/onetrust.js`,
|
|
41
|
+
martech: { url: `${pluginBasePath}/martech.js`, when: ({ urlParameters }) => urlParameters.size > 0 },
|
|
42
|
+
onetrust: { url: `${pluginBasePath}/onetrust.js`, when: () => (document.querySelector('#onetrust-consent-sdk') || hasCookieKey('OptanonAlertBoxClosed')), isBlockDependent: true },
|
|
43
|
+
// test: broken-plugin
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
const PLUGIN_PARAMETERS = {
|
|
@@ -54,19 +56,16 @@ const pluginCache = new Map();
|
|
|
54
56
|
function loadPlugin(key, params) {
|
|
55
57
|
const plugin = PLUGINS[key];
|
|
56
58
|
const usp = new URLSearchParams(window.location.search);
|
|
57
|
-
if (!pluginCache.has(key) && plugin.
|
|
59
|
+
if (!pluginCache.has(key) && plugin.when && !plugin.when({ urlParameters: usp })) {
|
|
58
60
|
return null;
|
|
59
61
|
}
|
|
60
62
|
if (!pluginCache.has(key)) {
|
|
61
|
-
|
|
62
|
-
pluginCache.set(key, import(`${plugin.url || plugin}`));
|
|
63
|
-
} catch (e) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
63
|
+
pluginCache.set(key, import(`${plugin.url || plugin}`));
|
|
66
64
|
}
|
|
67
65
|
const pluginLoadPromise = pluginCache.get(key);
|
|
68
66
|
return pluginLoadPromise
|
|
69
|
-
.then((p) => (p.default && p.default(params)) || (typeof p === 'function' && p(params)))
|
|
67
|
+
.then((p) => (p.default && p.default(params)) || (typeof p === 'function' && p(params)))
|
|
68
|
+
.catch(() => { /* silent plugin error catching */ });
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
function loadPlugins(filter = () => true, params = PLUGIN_PARAMETERS) {
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -136,23 +136,23 @@
|
|
|
136
136
|
cwv: `${pluginBasePath}/cwv.js`,
|
|
137
137
|
form: {
|
|
138
138
|
url: `${pluginBasePath}/form.js`,
|
|
139
|
-
|
|
139
|
+
when: () => document.querySelector('form'),
|
|
140
140
|
isBlockDependent: true
|
|
141
141
|
},
|
|
142
142
|
video: {
|
|
143
143
|
url: `${pluginBasePath}/video.js`,
|
|
144
|
-
|
|
144
|
+
when: () => document.querySelector('video'),
|
|
145
145
|
isBlockDependent: true
|
|
146
146
|
},
|
|
147
147
|
martech: {
|
|
148
148
|
url: `${pluginBasePath}/martech.js`,
|
|
149
|
-
|
|
149
|
+
when: ({
|
|
150
150
|
urlParameters
|
|
151
151
|
}) => urlParameters.size > 0
|
|
152
152
|
},
|
|
153
153
|
onetrust: {
|
|
154
154
|
url: `${pluginBasePath}/onetrust.js`,
|
|
155
|
-
|
|
155
|
+
when: () => document.querySelector('#onetrust-consent-sdk') || hasCookieKey('OptanonAlertBoxClosed'),
|
|
156
156
|
isBlockDependent: true
|
|
157
157
|
}
|
|
158
158
|
};
|
|
@@ -167,20 +167,16 @@
|
|
|
167
167
|
function loadPlugin(key, params) {
|
|
168
168
|
const plugin = PLUGINS[key];
|
|
169
169
|
const usp = new URLSearchParams(window.location.search);
|
|
170
|
-
if (!pluginCache.has(key) && plugin.
|
|
170
|
+
if (!pluginCache.has(key) && plugin.when && !plugin.when({
|
|
171
171
|
urlParameters: usp
|
|
172
172
|
})) {
|
|
173
173
|
return null;
|
|
174
174
|
}
|
|
175
175
|
if (!pluginCache.has(key)) {
|
|
176
|
-
|
|
177
|
-
pluginCache.set(key, import(`${plugin.url || plugin}`));
|
|
178
|
-
} catch (e) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
176
|
+
pluginCache.set(key, import(`${plugin.url || plugin}`));
|
|
181
177
|
}
|
|
182
178
|
const pluginLoadPromise = pluginCache.get(key);
|
|
183
|
-
return pluginLoadPromise.then(p => p.default && p.default(params) || typeof p === 'function' && p(params));
|
|
179
|
+
return pluginLoadPromise.then(p => p.default && p.default(params) || typeof p === 'function' && p(params)).catch(() => {});
|
|
184
180
|
}
|
|
185
181
|
function loadPlugins(filter = () => true, params = PLUGIN_PARAMETERS) {
|
|
186
182
|
Object.entries(PLUGINS).filter(([, plugin]) => filter(plugin)).map(([key]) => loadPlugin(key, params));
|
package/src/index.md5
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
6927b0ca98e3d69c532b6b104f0ffb14
|
package/src/plugins/cwv.md5
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
102443b9b53f78e1540d0bb8afa8d769
|
package/src/plugins/form.md5
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
089e973dcd9f9b5796c161c18e88647f
|
package/src/plugins/video.md5
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
ff797faa2362e5adf389383b0e6422d1
|
|
@@ -58,6 +58,15 @@ export default {
|
|
|
58
58
|
// rewriting dynamic plugins base url
|
|
59
59
|
.replace(/document\.currentScript\.src/g, '"http://localhost:8000/plugins"');
|
|
60
60
|
return true;
|
|
61
|
+
} else if (context.url.startsWith('/modules/index-broken.js')) {
|
|
62
|
+
const [_, search] = context.url.split('?');
|
|
63
|
+
context.url = `/modules/index.js?${search}`;
|
|
64
|
+
await next();
|
|
65
|
+
context.body = context.body
|
|
66
|
+
// rewriting dynamic plugins base url
|
|
67
|
+
.replace(/document\.currentScript\.src/g, '"http://localhost:8000/plugins"')
|
|
68
|
+
.replace(/\/\/ test: broken-plugin/g, 'foo: "foo.js",');
|
|
69
|
+
return true;
|
|
61
70
|
} else if (context.url.startsWith('/.rum')) {
|
|
62
71
|
if (context.url.startsWith('/.rum/@adobe/helix-rum-js@%5E2/dist/')
|
|
63
72
|
|| context.url.startsWith('/.rum/@adobe/helix-rum-js@^2/dist/')
|