@squide/firefly 14.0.0 → 15.0.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,5 +1,33 @@
1
1
  # @squide/firefly
2
2
 
3
+ ## 15.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#318](https://github.com/workleap/wl-squide/pull/318) [`6bf9a65`](https://github.com/workleap/wl-squide/commit/6bf9a65f222a6201655cf1ee525e94211aabe0b7) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Honeycomb instrumentation is now registered when an Honeycomb client is provided to the `initializeFirefly` function rather than by implicitly using global variables. Also updated dependency versions.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`6bf9a65`](https://github.com/workleap/wl-squide/commit/6bf9a65f222a6201655cf1ee525e94211aabe0b7)]:
12
+ - @squide/module-federation@7.0.2
13
+ - @squide/react-router@8.1.1
14
+ - @squide/core@6.1.1
15
+ - @squide/msw@4.0.2
16
+
17
+ ## 14.1.0
18
+
19
+ ### Minor Changes
20
+
21
+ - [#313](https://github.com/workleap/wl-squide/pull/313) [`bea660b`](https://github.com/workleap/wl-squide/commit/bea660bf827dd123a52f6062a7be8865dc99055b) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Hardened Honeycomb integration and added support for React Router relative paths.
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [[`bea660b`](https://github.com/workleap/wl-squide/commit/bea660bf827dd123a52f6062a7be8865dc99055b)]:
26
+ - @squide/react-router@8.1.0
27
+ - @squide/core@6.1.0
28
+ - @squide/module-federation@7.0.1
29
+ - @squide/msw@4.0.1
30
+
3
31
  ## 14.0.0
4
32
 
5
33
  ### Major Changes
@@ -1,2 +1,3 @@
1
+ import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
1
2
  import type { FireflyRuntime } from "../FireflyRuntime.tsx";
2
- export declare function initializeHoneycomb(runtime: FireflyRuntime): Promise<void>;
3
+ export declare function initializeHoneycomb(runtime: FireflyRuntime, honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient): Promise<void>;
@@ -1,22 +1,18 @@
1
- import { canRegisterHoneycombInstrumentation } from "./canRegisterHoneycombInstrumentation.js";
2
-
3
- ;// CONCATENATED MODULE: external "./canRegisterHoneycombInstrumentation.js"
4
1
 
5
2
  ;// CONCATENATED MODULE: ./src/honeycomb/initializeHoneycomb.ts
6
-
7
- async function initializeHoneycomb(runtime) {
8
- if (canRegisterHoneycombInstrumentation()) {
3
+ async function initializeHoneycomb(runtime, honeycombInstrumentationClient) {
4
+ if (honeycombInstrumentationClient) {
9
5
  try {
10
6
  // Dynamically import the Honeycomb instrumentation to prevent loading all the Honeycomb libraries
11
7
  // if Honeycomb instrumentation is not registered by the hosting application.
12
8
  const mod = await import("./registerHoneycombInstrumentation.js");
13
- mod.registerHoneycombInstrumentation(runtime);
9
+ mod.registerHoneycombInstrumentation(runtime, honeycombInstrumentationClient);
14
10
  } catch (error) {
15
- runtime.logger.error("[squide] Failed to register Honeycomb instrumentation. The \"./registerHoneycombInstrumentation.ts\" cannot be imported.");
11
+ runtime.logger.error("[squide] Failed to register Honeycomb instrumentation. The \"./registerHoneycombInstrumentation.ts\" file cannot be imported.");
16
12
  throw error;
17
13
  }
18
14
  } else {
19
- runtime.logger.information("[squide] Cannot register Honeycomb instrumentation because the host application is not using the \"@workleap/honeycomb\" package.");
15
+ runtime.logger.information("[squide] Cannot register Honeycomb instrumentation because the host application hasn't provided a client.");
20
16
  }
21
17
  }
22
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"honeycomb/initializeHoneycomb.js","sources":["webpack://@squide/firefly/./src/honeycomb/initializeHoneycomb.ts"],"sourcesContent":["import type { FireflyRuntime } from \"../FireflyRuntime.tsx\";\nimport { canRegisterHoneycombInstrumentation } from \"./canRegisterHoneycombInstrumentation.ts\";\n\nexport async function initializeHoneycomb(runtime: FireflyRuntime) {\n if (canRegisterHoneycombInstrumentation()) {\n try {\n // Dynamically import the Honeycomb instrumentation to prevent loading all the Honeycomb libraries\n // if Honeycomb instrumentation is not registered by the hosting application.\n const mod = await import(\"./registerHoneycombInstrumentation.ts\");\n\n mod.registerHoneycombInstrumentation(runtime);\n } catch (error: unknown) {\n runtime.logger.error(\"[squide] Failed to register Honeycomb instrumentation. The \\\"./registerHoneycombInstrumentation.ts\\\" cannot be imported.\");\n\n throw error;\n }\n } else {\n runtime.logger.information(\"[squide] Cannot register Honeycomb instrumentation because the host application is not using the \\\"@workleap/honeycomb\\\" package.\");\n }\n}\n\n\n"],"names":["canRegisterHoneycombInstrumentation","initializeHoneycomb","runtime","mod","error"],"mappings":";;;;;AAC+F;AAExF,eAAeC,oBAAoBC,OAAuB;IAC7D,IAAIF,mCAAmCA,IAAI;QACvC,IAAI;YACA,kGAAkG;YAClG,6EAA6E;YAC7E,MAAMG,MAAM,MAAM,+CAA+C;YAEjEA,IAAI,gCAAgC,CAACD;QACzC,EAAE,OAAOE,OAAgB;YACrBF,QAAQ,MAAM,CAAC,KAAK,CAAC;YAErB,MAAME;QACV;IACJ,OAAO;QACHF,QAAQ,MAAM,CAAC,WAAW,CAAC;IAC/B;AACJ"}
1
+ {"version":3,"file":"honeycomb/initializeHoneycomb.js","sources":["webpack://@squide/firefly/./src/honeycomb/initializeHoneycomb.ts"],"sourcesContent":["import type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport type { FireflyRuntime } from \"../FireflyRuntime.tsx\";\n\nexport async function initializeHoneycomb(runtime: FireflyRuntime, honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient) {\n if (honeycombInstrumentationClient) {\n try {\n // Dynamically import the Honeycomb instrumentation to prevent loading all the Honeycomb libraries\n // if Honeycomb instrumentation is not registered by the hosting application.\n const mod = await import(\"./registerHoneycombInstrumentation.ts\");\n\n mod.registerHoneycombInstrumentation(runtime, honeycombInstrumentationClient);\n } catch (error: unknown) {\n runtime.logger.error(\"[squide] Failed to register Honeycomb instrumentation. The \\\"./registerHoneycombInstrumentation.ts\\\" file cannot be imported.\");\n\n throw error;\n }\n } else {\n runtime.logger.information(\"[squide] Cannot register Honeycomb instrumentation because the host application hasn't provided a client.\");\n }\n}\n\n\n"],"names":["initializeHoneycomb","runtime","honeycombInstrumentationClient","mod","error"],"mappings":";;AAGO,eAAeA,oBAAoBC,OAAuB,EAAEC,8BAAsE;IACrI,IAAIA,gCAAgC;QAChC,IAAI;YACA,kGAAkG;YAClG,6EAA6E;YAC7E,MAAMC,MAAM,MAAM,+CAA+C;YAEjEA,IAAI,gCAAgC,CAACF,SAASC;QAClD,EAAE,OAAOE,OAAgB;YACrBH,QAAQ,MAAM,CAAC,KAAK,CAAC;YAErB,MAAMG;QACV;IACJ,OAAO;QACHH,QAAQ,MAAM,CAAC,WAAW,CAAC;IAC/B;AACJ"}
@@ -1,3 +1,4 @@
1
+ import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
1
2
  import type { FireflyRuntime } from "../FireflyRuntime.tsx";
2
- export declare function reduceDataFetchEvents(runtime: FireflyRuntime, onDataFetchStarted: () => void, onDataReady: () => void, onPublicDataFetchStarted: () => void, onPublicDataReady: () => void, onProtectedDataFetchStarted: () => void, onProtectedDataReady: () => void, onDataFetchFailed: (queriesErrors: Error[]) => void): void;
3
- export declare function registerHoneycombInstrumentation(runtime: FireflyRuntime): void;
3
+ export declare function reduceDataFetchEvents(runtime: FireflyRuntime, onDataFetchStarted: () => void, onDataReady: () => void, onPublicDataFetchStarted: () => void, onPublicDataReady: () => void, onProtectedDataFetchStarted: () => void, onProtectedDataReady: () => void, onDataFetchFailed: (queriesErrors: Error[]) => void, onUnmanagedError: (error: unknown) => void): void;
4
+ export declare function registerHoneycombInstrumentation(runtime: FireflyRuntime, honeycombInstrumentationClient: HoneycombInstrumentationPartialClient): void;
@@ -36,18 +36,29 @@ import { endActiveSpan, startActiveChildSpan, startChildSpan, startSpan, traceEr
36
36
 
37
37
 
38
38
 
39
- function reduceDataFetchEvents(runtime, onDataFetchStarted, onDataReady, onPublicDataFetchStarted, onPublicDataReady, onProtectedDataFetchStarted, onProtectedDataReady, onDataFetchFailed) {
39
+ function addProtectedListener(runtime, eventName, callback, options) {
40
+ const protectedCallback = (...args)=>{
41
+ try {
42
+ callback(...args);
43
+ } catch (error) {
44
+ runtime.logger.withText(`[squide] An unmanaged error occurred while handling event "${eventName.toString()}" for Honeycomb instrumentation:`).withError(error).error();
45
+ }
46
+ };
47
+ runtime.eventBus.addListener(eventName, protectedCallback, options);
48
+ }
49
+ function reduceDataFetchEvents(runtime, onDataFetchStarted, onDataReady, onPublicDataFetchStarted, onPublicDataReady, onProtectedDataFetchStarted, onProtectedDataReady, onDataFetchFailed, onUnmanagedError) {
40
50
  let dataFetchState = "none";
41
- runtime.eventBus.addListener(PublicDataFetchStartedEvent, ()=>{
51
+ addProtectedListener(runtime, PublicDataFetchStartedEvent, ()=>{
42
52
  if (dataFetchState === "none") {
43
53
  dataFetchState = "fetching-data";
44
54
  onDataFetchStarted();
45
55
  }
46
56
  onPublicDataFetchStarted();
47
57
  }, {
48
- once: true
58
+ once: true,
59
+ onError: onUnmanagedError
49
60
  });
50
- runtime.eventBus.addListener(PublicDataReadyEvent, (payload)=>{
61
+ addProtectedListener(runtime, PublicDataReadyEvent, (payload)=>{
51
62
  onPublicDataReady();
52
63
  if (dataFetchState === "fetching-data") {
53
64
  if (payload && !payload.waitForProtectedData) {
@@ -61,18 +72,20 @@ function reduceDataFetchEvents(runtime, onDataFetchStarted, onDataReady, onPubli
61
72
  onDataReady();
62
73
  }
63
74
  }, {
64
- once: true
75
+ once: true,
76
+ onError: onUnmanagedError
65
77
  });
66
- runtime.eventBus.addListener(ProtectedDataFetchStartedEvent, ()=>{
78
+ addProtectedListener(runtime, ProtectedDataFetchStartedEvent, ()=>{
67
79
  if (dataFetchState === "none") {
68
80
  dataFetchState = "fetching-data";
69
81
  onDataFetchStarted();
70
82
  }
71
83
  onProtectedDataFetchStarted();
72
84
  }, {
73
- once: true
85
+ once: true,
86
+ onError: onUnmanagedError
74
87
  });
75
- runtime.eventBus.addListener(ProtectedDataReadyEvent, (payload)=>{
88
+ addProtectedListener(runtime, ProtectedDataReadyEvent, (payload)=>{
76
89
  onProtectedDataReady();
77
90
  if (dataFetchState === "fetching-data") {
78
91
  if (payload && !payload.waitForPublicData) {
@@ -86,7 +99,8 @@ function reduceDataFetchEvents(runtime, onDataFetchStarted, onDataReady, onPubli
86
99
  onDataReady();
87
100
  }
88
101
  }, {
89
- once: true
102
+ once: true,
103
+ onError: onUnmanagedError
90
104
  });
91
105
  const handleDataFetchFailed = (payload)=>{
92
106
  if (dataFetchState !== "data-fetch-failed") {
@@ -94,15 +108,18 @@ function reduceDataFetchEvents(runtime, onDataFetchStarted, onDataReady, onPubli
94
108
  onDataFetchFailed(payload);
95
109
  }
96
110
  };
97
- runtime.eventBus.addListener(PublicDataFetchFailedEvent, handleDataFetchFailed, {
98
- once: true
111
+ addProtectedListener(runtime, PublicDataFetchFailedEvent, handleDataFetchFailed, {
112
+ once: true,
113
+ onError: onUnmanagedError
99
114
  });
100
- runtime.eventBus.addListener(ProtectedDataFetchFailedEvent, handleDataFetchFailed, {
101
- once: true
115
+ addProtectedListener(runtime, ProtectedDataFetchFailedEvent, handleDataFetchFailed, {
116
+ once: true,
117
+ onError: onUnmanagedError
102
118
  });
103
119
  }
104
120
  function registerTrackingListeners(runtime) {
105
121
  let bootstrappingSpan;
122
+ let bootstrappingSpanHasEnded = false;
106
123
  let localModuleRegistrationSpan;
107
124
  let localModuleDeferredRegistrationSpan;
108
125
  let remoteModuleRegistrationSpan;
@@ -111,26 +128,61 @@ function registerTrackingListeners(runtime) {
111
128
  let deferredRegistrationsUpdateSpan;
112
129
  let localModuleDeferredRegistrationsUpdateSpan;
113
130
  let remoteModuleDeferredRegistrationsUpdateSpan;
114
- runtime.eventBus.addListener(ApplicationBootstrappingStartedEvent, ()=>{
131
+ const handleUnmanagedError = (error)=>{
132
+ if (bootstrappingSpan && !bootstrappingSpanHasEnded) {
133
+ traceError(bootstrappingSpan, error);
134
+ bootstrappingSpan.end();
135
+ bootstrappingSpanHasEnded = true;
136
+ }
137
+ if (localModuleRegistrationSpan) {
138
+ localModuleRegistrationSpan.end();
139
+ }
140
+ if (localModuleDeferredRegistrationSpan) {
141
+ localModuleDeferredRegistrationSpan.end();
142
+ }
143
+ if (remoteModuleRegistrationSpan) {
144
+ remoteModuleRegistrationSpan.end();
145
+ }
146
+ if (remoteModuleDeferredRegistrationSpan) {
147
+ remoteModuleDeferredRegistrationSpan.end();
148
+ }
149
+ if (dataFetchSpan) {
150
+ dataFetchSpan.instance.end();
151
+ }
152
+ if (deferredRegistrationsUpdateSpan) {
153
+ deferredRegistrationsUpdateSpan.end();
154
+ }
155
+ if (localModuleDeferredRegistrationsUpdateSpan) {
156
+ localModuleDeferredRegistrationsUpdateSpan.instance.end();
157
+ }
158
+ if (remoteModuleDeferredRegistrationsUpdateSpan) {
159
+ remoteModuleDeferredRegistrationsUpdateSpan.instance.end();
160
+ }
161
+ };
162
+ addProtectedListener(runtime, ApplicationBootstrappingStartedEvent, ()=>{
115
163
  bootstrappingSpan = startSpan((options, context)=>getTracer().startSpan("squide-bootstrapping", options, context));
116
164
  }, {
117
- once: true
165
+ once: true,
166
+ onError: handleUnmanagedError
118
167
  });
119
- runtime.eventBus.addListener(ApplicationBoostrappedEvent, ()=>{
168
+ addProtectedListener(runtime, ApplicationBoostrappedEvent, ()=>{
120
169
  if (bootstrappingSpan) {
121
170
  bootstrappingSpan.end();
171
+ bootstrappingSpanHasEnded = true;
122
172
  }
123
173
  }, {
124
- once: true
174
+ once: true,
175
+ onError: handleUnmanagedError
125
176
  });
126
- runtime.eventBus.addListener(MswReadyEvent, ()=>{
177
+ addProtectedListener(runtime, MswReadyEvent, ()=>{
127
178
  if (bootstrappingSpan) {
128
179
  bootstrappingSpan.addEvent("msw-ready");
129
180
  }
130
181
  }, {
131
- once: true
182
+ once: true,
183
+ onError: handleUnmanagedError
132
184
  });
133
- runtime.eventBus.addListener(LocalModulesRegistrationStartedEvent, (payload)=>{
185
+ addProtectedListener(runtime, LocalModulesRegistrationStartedEvent, (payload)=>{
134
186
  const attributes = {
135
187
  "app.squide.module_count": payload.moduleCount
136
188
  };
@@ -144,9 +196,10 @@ function registerTrackingListeners(runtime) {
144
196
  }, context);
145
197
  });
146
198
  }, {
147
- once: true
199
+ once: true,
200
+ onError: handleUnmanagedError
148
201
  });
149
- runtime.eventBus.addListener(LocalModulesRegistrationCompletedEvent, (payload)=>{
202
+ addProtectedListener(runtime, LocalModulesRegistrationCompletedEvent, (payload)=>{
150
203
  if (bootstrappingSpan) {
151
204
  bootstrappingSpan.addEvent("local-module-registration-completed", {
152
205
  "app.squide.module_count": payload.moduleCount
@@ -156,16 +209,19 @@ function registerTrackingListeners(runtime) {
156
209
  localModuleRegistrationSpan.end();
157
210
  }
158
211
  }, {
159
- once: true
212
+ once: true,
213
+ onError: handleUnmanagedError
160
214
  });
161
215
  // Can occur multiple times.
162
- runtime.eventBus.addListener(LocalModuleRegistrationFailedEvent, (payload)=>{
216
+ addProtectedListener(runtime, LocalModuleRegistrationFailedEvent, (payload)=>{
163
217
  const registrationError = payload;
164
218
  if (localModuleRegistrationSpan) {
165
219
  traceError(localModuleRegistrationSpan, registrationError);
166
220
  }
221
+ }, {
222
+ onError: handleUnmanagedError
167
223
  });
168
- runtime.eventBus.addListener(LocalModulesDeferredRegistrationStartedEvent, (payload)=>{
224
+ addProtectedListener(runtime, LocalModulesDeferredRegistrationStartedEvent, (payload)=>{
169
225
  const attributes = {
170
226
  "app.squide.registration_count": payload.registrationCount
171
227
  };
@@ -179,9 +235,10 @@ function registerTrackingListeners(runtime) {
179
235
  }, context);
180
236
  });
181
237
  }, {
182
- once: true
238
+ once: true,
239
+ onError: handleUnmanagedError
183
240
  });
184
- runtime.eventBus.addListener(LocalModulesDeferredRegistrationCompletedEvent, (payload)=>{
241
+ addProtectedListener(runtime, LocalModulesDeferredRegistrationCompletedEvent, (payload)=>{
185
242
  if (bootstrappingSpan) {
186
243
  bootstrappingSpan.addEvent("local-module-deferred-registration-completed", {
187
244
  "app.squide.registration_count": payload.registrationCount
@@ -191,16 +248,19 @@ function registerTrackingListeners(runtime) {
191
248
  localModuleDeferredRegistrationSpan.end();
192
249
  }
193
250
  }, {
194
- once: true
251
+ once: true,
252
+ onError: handleUnmanagedError
195
253
  });
196
254
  // Can occur multiple times.
197
- runtime.eventBus.addListener(LocalModuleDeferredRegistrationFailedEvent, (payload)=>{
255
+ addProtectedListener(runtime, LocalModuleDeferredRegistrationFailedEvent, (payload)=>{
198
256
  const registrationError = payload;
199
257
  if (localModuleDeferredRegistrationSpan) {
200
258
  traceError(localModuleRegistrationSpan, registrationError);
201
259
  }
260
+ }, {
261
+ onError: handleUnmanagedError
202
262
  });
203
- runtime.eventBus.addListener(RemoteModulesRegistrationStartedEvent, (payload)=>{
263
+ addProtectedListener(runtime, RemoteModulesRegistrationStartedEvent, (payload)=>{
204
264
  const attributes = {
205
265
  "app.squide.remote_count": payload.remoteCount
206
266
  };
@@ -214,9 +274,10 @@ function registerTrackingListeners(runtime) {
214
274
  }, context);
215
275
  });
216
276
  }, {
217
- once: true
277
+ once: true,
278
+ onError: handleUnmanagedError
218
279
  });
219
- runtime.eventBus.addListener(RemoteModulesRegistrationCompletedEvent, (payload)=>{
280
+ addProtectedListener(runtime, RemoteModulesRegistrationCompletedEvent, (payload)=>{
220
281
  if (bootstrappingSpan) {
221
282
  bootstrappingSpan.addEvent("remote-module-registration-completed", {
222
283
  "app.squide.remote_count": payload.remoteCount
@@ -226,16 +287,19 @@ function registerTrackingListeners(runtime) {
226
287
  remoteModuleRegistrationSpan.end();
227
288
  }
228
289
  }, {
229
- once: true
290
+ once: true,
291
+ onError: handleUnmanagedError
230
292
  });
231
293
  // Can occur multiple times.
232
- runtime.eventBus.addListener(RemoteModuleRegistrationFailedEvent, (payload)=>{
294
+ addProtectedListener(runtime, RemoteModuleRegistrationFailedEvent, (payload)=>{
233
295
  const registrationError = payload;
234
296
  if (remoteModuleRegistrationSpan) {
235
297
  traceError(remoteModuleRegistrationSpan, registrationError);
236
298
  }
299
+ }, {
300
+ onError: handleUnmanagedError
237
301
  });
238
- runtime.eventBus.addListener(RemoteModulesDeferredRegistrationStartedEvent, (payload)=>{
302
+ addProtectedListener(runtime, RemoteModulesDeferredRegistrationStartedEvent, (payload)=>{
239
303
  const attributes = {
240
304
  "app.squide.registration_count": payload.registrationCount
241
305
  };
@@ -249,9 +313,10 @@ function registerTrackingListeners(runtime) {
249
313
  }, context);
250
314
  });
251
315
  }, {
252
- once: true
316
+ once: true,
317
+ onError: handleUnmanagedError
253
318
  });
254
- runtime.eventBus.addListener(RemoteModulesDeferredRegistrationCompletedEvent, (payload)=>{
319
+ addProtectedListener(runtime, RemoteModulesDeferredRegistrationCompletedEvent, (payload)=>{
255
320
  if (bootstrappingSpan) {
256
321
  bootstrappingSpan.addEvent("remote-module-deferred-registration-completed", {
257
322
  "app.squide.registration_count": payload.registrationCount
@@ -261,14 +326,17 @@ function registerTrackingListeners(runtime) {
261
326
  remoteModuleDeferredRegistrationSpan.end();
262
327
  }
263
328
  }, {
264
- once: true
329
+ once: true,
330
+ onError: handleUnmanagedError
265
331
  });
266
332
  // Can occur multiple times.
267
- runtime.eventBus.addListener(RemoteModuleDeferredRegistrationFailedEvent, (payload)=>{
333
+ addProtectedListener(runtime, RemoteModuleDeferredRegistrationFailedEvent, (payload)=>{
268
334
  const registrationError = payload;
269
335
  if (remoteModuleDeferredRegistrationSpan) {
270
336
  traceError(remoteModuleDeferredRegistrationSpan, registrationError);
271
337
  }
338
+ }, {
339
+ onError: handleUnmanagedError
272
340
  });
273
341
  const handleFetchDataStarted = ()=>{
274
342
  dataFetchSpan = startActiveChildSpan(bootstrappingSpan, (options, context)=>{
@@ -315,36 +383,43 @@ function registerTrackingListeners(runtime) {
315
383
  // will be aborted and a react-router error boundary will be rendered.
316
384
  if (bootstrappingSpan) {
317
385
  bootstrappingSpan.end();
386
+ bootstrappingSpanHasEnded = true;
318
387
  }
319
388
  }
320
389
  };
321
- reduceDataFetchEvents(runtime, handleFetchDataStarted, handleDataReady, handlePublicDataFetchStarted, handlePublicDataReady, handleProtectedDataFetchStarted, handleProtectedDataReady, handleDataFetchFailed);
322
- runtime.eventBus.addListener(ModulesRegisteredEvent, ()=>{
390
+ reduceDataFetchEvents(runtime, handleFetchDataStarted, handleDataReady, handlePublicDataFetchStarted, handlePublicDataReady, handleProtectedDataFetchStarted, handleProtectedDataReady, handleDataFetchFailed, handleUnmanagedError);
391
+ addProtectedListener(runtime, ModulesRegisteredEvent, ()=>{
323
392
  if (bootstrappingSpan) {
324
393
  bootstrappingSpan.addEvent("modules-registered");
325
394
  }
326
395
  }, {
327
- once: true
396
+ once: true,
397
+ onError: handleUnmanagedError
328
398
  });
329
- runtime.eventBus.addListener(ModulesReadyEvent, ()=>{
399
+ addProtectedListener(runtime, ModulesReadyEvent, ()=>{
330
400
  if (bootstrappingSpan) {
331
401
  bootstrappingSpan.addEvent("modules-ready");
332
402
  }
333
403
  }, {
334
- once: true
404
+ once: true,
405
+ onError: handleUnmanagedError
335
406
  });
336
407
  // Can occur multiple times.
337
- runtime.eventBus.addListener(DeferredRegistrationsUpdateStartedEvent, ()=>{
408
+ addProtectedListener(runtime, DeferredRegistrationsUpdateStartedEvent, ()=>{
338
409
  deferredRegistrationsUpdateSpan = startSpan((options, context)=>getTracer().startSpan("squide-deferred-registrations-update", options, context));
410
+ }, {
411
+ onError: handleUnmanagedError
339
412
  });
340
413
  // Can occur multiple times.
341
- runtime.eventBus.addListener(DeferredRegistrationsUpdateCompletedEvent, ()=>{
414
+ addProtectedListener(runtime, DeferredRegistrationsUpdateCompletedEvent, ()=>{
342
415
  if (deferredRegistrationsUpdateSpan) {
343
416
  deferredRegistrationsUpdateSpan.end();
344
417
  }
418
+ }, {
419
+ onError: handleUnmanagedError
345
420
  });
346
421
  // Can occur multiple times.
347
- runtime.eventBus.addListener(LocalModulesDeferredRegistrationsUpdateStartedEvent, (payload)=>{
422
+ addProtectedListener(runtime, LocalModulesDeferredRegistrationsUpdateStartedEvent, (payload)=>{
348
423
  const attributes = {
349
424
  "app.squide.registration_count": payload.registrationCount
350
425
  };
@@ -362,9 +437,11 @@ function registerTrackingListeners(runtime) {
362
437
  span
363
438
  };
364
439
  });
440
+ }, {
441
+ onError: handleUnmanagedError
365
442
  });
366
443
  // Can occur multiple times.
367
- runtime.eventBus.addListener(LocalModulesDeferredRegistrationsUpdateCompletedEvent, (payload)=>{
444
+ addProtectedListener(runtime, LocalModulesDeferredRegistrationsUpdateCompletedEvent, (payload)=>{
368
445
  if (deferredRegistrationsUpdateSpan) {
369
446
  deferredRegistrationsUpdateSpan.addEvent("local-module-deferred-registrations-update-completed", {
370
447
  "app.squide.registration_count": payload.registrationCount
@@ -373,16 +450,20 @@ function registerTrackingListeners(runtime) {
373
450
  if (localModuleDeferredRegistrationsUpdateSpan) {
374
451
  endActiveSpan(localModuleDeferredRegistrationsUpdateSpan);
375
452
  }
453
+ }, {
454
+ onError: handleUnmanagedError
376
455
  });
377
456
  // Can occur multiple times.
378
- runtime.eventBus.addListener(LocalModuleDeferredRegistrationUpdateFailedEvent, (payload)=>{
457
+ addProtectedListener(runtime, LocalModuleDeferredRegistrationUpdateFailedEvent, (payload)=>{
379
458
  const registrationError = payload;
380
459
  if (localModuleDeferredRegistrationsUpdateSpan) {
381
460
  traceError(localModuleDeferredRegistrationsUpdateSpan.instance, registrationError);
382
461
  }
462
+ }, {
463
+ onError: handleUnmanagedError
383
464
  });
384
465
  // Can occur multiple times.
385
- runtime.eventBus.addListener(RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload)=>{
466
+ addProtectedListener(runtime, RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload)=>{
386
467
  const attributes = {
387
468
  "app.squide.registration_count": payload.registrationCount
388
469
  };
@@ -400,9 +481,11 @@ function registerTrackingListeners(runtime) {
400
481
  span
401
482
  };
402
483
  });
484
+ }, {
485
+ onError: handleUnmanagedError
403
486
  });
404
487
  // Can occur multiple times.
405
- runtime.eventBus.addListener(RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload)=>{
488
+ addProtectedListener(runtime, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload)=>{
406
489
  if (deferredRegistrationsUpdateSpan) {
407
490
  deferredRegistrationsUpdateSpan.addEvent("remote-module-deferred-registrations-update-completed", {
408
491
  "app.squide.registration_count": payload.registrationCount
@@ -411,40 +494,30 @@ function registerTrackingListeners(runtime) {
411
494
  if (remoteModuleDeferredRegistrationsUpdateSpan) {
412
495
  endActiveSpan(remoteModuleDeferredRegistrationsUpdateSpan);
413
496
  }
497
+ }, {
498
+ onError: handleUnmanagedError
414
499
  });
415
500
  // Can occur multiple times.
416
- runtime.eventBus.addListener(RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload)=>{
501
+ addProtectedListener(runtime, RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload)=>{
417
502
  const registrationError = payload;
418
503
  if (remoteModuleDeferredRegistrationsUpdateSpan) {
419
504
  traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);
420
505
  }
506
+ }, {
507
+ onError: handleUnmanagedError
421
508
  });
422
509
  }
423
- function getRegisterFetchRequestHookFunction() {
424
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
425
- // @ts-ignore
426
- if (globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__) {
427
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
428
- // @ts-ignore
429
- return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__;
430
- }
431
- // Fallback to fix an error. Will remove soon.
432
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
433
- // @ts-ignore
434
- return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK;
435
- }
436
- function registerHoneycombInstrumentation(runtime) {
437
- const registerFetchRequestHookFunction = getRegisterFetchRequestHookFunction();
438
- if (registerFetchRequestHookFunction) {
510
+ function registerHoneycombInstrumentation(runtime, honeycombInstrumentationClient) {
511
+ try {
439
512
  registerActiveSpanStack();
440
- const activeSpanOverrideFunction = createOverrideFetchRequestSpanWithActiveSpanContext(runtime.logger);
441
513
  // Dynamically registering this request hook function to nest the HTTP requests
442
514
  // of squide bootstrapping under the appropriate Honeycomb span.
443
- registerFetchRequestHookFunction(activeSpanOverrideFunction);
444
- } else {
445
- runtime.logger.warning("[squide] Cannot register Honeycomb fetch request hook because \"globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__\" is not available. Honeycomb instrumentation is still functional but in degraded mode.");
515
+ honeycombInstrumentationClient.registerFetchRequestHook(createOverrideFetchRequestSpanWithActiveSpanContext(runtime.logger));
516
+ registerTrackingListeners(runtime);
517
+ runtime.logger.information("[squide] Honeycomb instrumentation is registered.");
518
+ } catch (error) {
519
+ runtime.logger.withText("[squide] An error occurred while registering Honeycomb instrumentation:").withError(error).error();
446
520
  }
447
- registerTrackingListeners(runtime);
448
521
  }
449
522
 
450
523
  export { reduceDataFetchEvents, registerHoneycombInstrumentation };