@adobe/helix-rum-enhancer 2.31.0-beta.4 → 2.31.0-beta.6

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,17 @@
1
+ # [2.31.0-beta.6](https://github.com/adobe/helix-rum-enhancer/compare/v2.31.0-beta.5...v2.31.0-beta.6) (2025-01-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * plugins are not executing because they are exported as iife ([6e30eb5](https://github.com/adobe/helix-rum-enhancer/commit/6e30eb57efe19c15f2ea453f9c97477dec79c3d2))
7
+
8
+ # [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)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * just forcing a release ([84ab687](https://github.com/adobe/helix-rum-enhancer/commit/84ab68734b5862816a532d4847df0ffa753b0717))
14
+
1
15
  # [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
16
 
3
17
 
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`, condition: () => document.querySelector('form'), isBlockDependent: true },
38
- video: { url: `${pluginBasePath}/video.js`, condition: () => document.querySelector('video'), isBlockDependent: true },
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`, condition: ({ urlParameters }) => urlParameters.size > 0 },
41
- onetrust: { url: `${pluginBasePath}/onetrust.js`, condition: () => (document.querySelector('#onetrust-consent-sdk') || hasCookieKey('OptanonAlertBoxClosed')), isBlockDependent: true },
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.condition && !plugin.condition({ urlParameters: usp })) {
59
+ if (!pluginCache.has(key) && plugin.when && !plugin.when({ urlParameters: usp })) {
58
60
  return null;
59
61
  }
60
62
  if (!pluginCache.has(key)) {
61
- try {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-rum-enhancer",
3
- "version": "2.31.0-beta.4",
3
+ "version": "2.31.0-beta.6",
4
4
  "description": "Helix RUM Enhancer",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/rollup.config.js CHANGED
@@ -38,22 +38,23 @@ const bundles = [
38
38
  ...['cwv', 'form', 'martech', 'onetrust', 'video'].map((plugin) => ({
39
39
  source: `plugins/${plugin}.js`,
40
40
  outputFile: `src/plugins/${plugin}`,
41
+ format: 'es',
41
42
  })),
42
43
  ];
43
44
 
44
- export default [...bundles.map(({ outputFile, source }) => ({
45
+ export default [...bundles.map(({ outputFile, source, format }) => ({
45
46
  input: source,
46
47
  output: [
47
48
  {
48
49
  file: `${outputFile}.map.js`,
49
- format: 'iife',
50
+ format: format || 'iife',
50
51
  sourcemap: 'inline',
51
52
  exports: 'auto',
52
53
  banner,
53
54
  },
54
55
  {
55
56
  file: `${outputFile}.js`,
56
- format: 'iife',
57
+ format: format || 'iife',
57
58
  sourcemap: false,
58
59
  exports: 'auto',
59
60
  banner,
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
- condition: () => document.querySelector('form'),
139
+ when: () => document.querySelector('form'),
140
140
  isBlockDependent: true
141
141
  },
142
142
  video: {
143
143
  url: `${pluginBasePath}/video.js`,
144
- condition: () => document.querySelector('video'),
144
+ when: () => document.querySelector('video'),
145
145
  isBlockDependent: true
146
146
  },
147
147
  martech: {
148
148
  url: `${pluginBasePath}/martech.js`,
149
- condition: ({
149
+ when: ({
150
150
  urlParameters
151
151
  }) => urlParameters.size > 0
152
152
  },
153
153
  onetrust: {
154
154
  url: `${pluginBasePath}/onetrust.js`,
155
- condition: () => document.querySelector('#onetrust-consent-sdk') || hasCookieKey('OptanonAlertBoxClosed'),
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.condition && !plugin.condition({
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
- try {
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
- 4496e739d9016b3ea998093c5552cd22
1
+ 6927b0ca98e3d69c532b6b104f0ffb14