@squide/firefly 13.0.0 → 13.0.2
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 +18 -0
- package/dist/AppRouter.js +17 -17
- package/dist/AppRouter.js.map +1 -1
- package/dist/AppRouterContext.js +8 -8
- package/dist/AppRouterContext.js.map +1 -1
- package/dist/AppRouterReducer.js +47 -47
- package/dist/AppRouterReducer.js.map +1 -1
- package/dist/FireflyProvider.js +3 -3
- package/dist/FireflyProvider.js.map +1 -1
- package/dist/FireflyRuntime.js +11 -11
- package/dist/FireflyRuntime.js.map +1 -1
- package/dist/RootRoute.js +10 -10
- package/dist/RootRoute.js.map +1 -1
- package/dist/honeycomb/activeSpan.js +6 -6
- package/dist/honeycomb/activeSpan.js.map +1 -1
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.d.ts +1 -0
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.js +11 -0
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.js.map +1 -0
- package/dist/honeycomb/initializeHoneycomb.d.ts +2 -0
- package/dist/honeycomb/initializeHoneycomb.js +25 -0
- package/dist/honeycomb/initializeHoneycomb.js.map +1 -0
- package/dist/honeycomb/registerHoneycombInstrumentation.d.ts +1 -2
- package/dist/honeycomb/registerHoneycombInstrumentation.js +104 -99
- package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
- package/dist/honeycomb/tracer.js +2 -2
- package/dist/honeycomb/tracer.js.map +1 -1
- package/dist/honeycomb/utils.js +12 -12
- package/dist/honeycomb/utils.js.map +1 -1
- package/dist/initializeFirefly.js +19 -18
- package/dist/initializeFirefly.js.map +1 -1
- package/dist/useAppRouterStore.js +2 -2
- package/dist/useAppRouterStore.js.map +1 -1
- package/dist/useCanFetchProtectedData.js +2 -2
- package/dist/useCanFetchProtectedData.js.map +1 -1
- package/dist/useCanFetchPublicData.js +2 -2
- package/dist/useCanFetchPublicData.js.map +1 -1
- package/dist/useCanRegisterDeferredRegistrations.js +2 -2
- package/dist/useCanRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useCanUpdateDeferredRegistrations.js +2 -2
- package/dist/useCanUpdateDeferredRegistrations.js.map +1 -1
- package/dist/useDeferredRegistrations.js +13 -13
- package/dist/useDeferredRegistrations.js.map +1 -1
- package/dist/useExecuteOnce.js +3 -3
- package/dist/useExecuteOnce.js.map +1 -1
- package/dist/useIsActiveRouteProtected.js +5 -5
- package/dist/useIsActiveRouteProtected.js.map +1 -1
- package/dist/useIsBootstrapping.js +2 -2
- package/dist/useIsBootstrapping.js.map +1 -1
- package/dist/useNavigationItems.js +4 -4
- package/dist/useNavigationItems.js.map +1 -1
- package/dist/useProtectedDataHandler.js +4 -4
- package/dist/useProtectedDataHandler.js.map +1 -1
- package/dist/useProtectedDataQueries.js +20 -20
- package/dist/useProtectedDataQueries.js.map +1 -1
- package/dist/usePublicDataHandler.js +4 -4
- package/dist/usePublicDataHandler.js.map +1 -1
- package/dist/usePublicDataQueries.js +19 -19
- package/dist/usePublicDataQueries.js.map +1 -1
- package/dist/useRegisterDeferredRegistrations.js +4 -4
- package/dist/useRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useStrictRegistrationMode.js +12 -12
- package/dist/useStrictRegistrationMode.js.map +1 -1
- package/dist/useUpdateDeferredRegistrations.js +6 -6
- package/dist/useUpdateDeferredRegistrations.js.map +1 -1
- package/package.json +16 -21
- package/src/honeycomb/canRegisterHoneycombInstrumentation.ts +5 -0
- package/src/honeycomb/initializeHoneycomb.ts +22 -0
- package/src/honeycomb/registerHoneycombInstrumentation.ts +43 -50
- package/src/initializeFirefly.ts +12 -9
|
@@ -40,8 +40,8 @@ import {
|
|
|
40
40
|
import { ApplicationBoostrappedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, PublicDataReadyEvent } from "../AppRouterReducer.ts";
|
|
41
41
|
import type { FireflyRuntime } from "../FireflyRuntime.tsx";
|
|
42
42
|
import { ApplicationBootstrappingStartedEvent } from "../initializeFirefly.ts";
|
|
43
|
-
import { ProtectedDataFetchStartedEvent } from "../useProtectedDataQueries.ts";
|
|
44
|
-
import { PublicDataFetchStartedEvent } from "../usePublicDataQueries.ts";
|
|
43
|
+
import { ProtectedDataFetchFailedEvent, ProtectedDataFetchStartedEvent } from "../useProtectedDataQueries.ts";
|
|
44
|
+
import { PublicDataFetchFailedEvent, PublicDataFetchStartedEvent } from "../usePublicDataQueries.ts";
|
|
45
45
|
import { type ActiveSpan, createOverrideFetchRequestSpanWithActiveSpanContext, registerActiveSpanStack } from "./activeSpan.ts";
|
|
46
46
|
import { getTracer } from "./tracer.ts";
|
|
47
47
|
import { endActiveSpan, startActiveChildSpan, startChildSpan, startSpan, traceError } from "./utils.ts";
|
|
@@ -49,30 +49,29 @@ import { endActiveSpan, startActiveChildSpan, startChildSpan, startSpan, traceEr
|
|
|
49
49
|
// TIPS:
|
|
50
50
|
// To query those traces in Honeycomb, use the following query filter: "root.name = squide-bootstrapping".
|
|
51
51
|
|
|
52
|
-
type DataFetchState = "none" | "fetching-data" | "public-data-ready" | "protected-data-ready" | "data-ready";
|
|
52
|
+
type DataFetchState = "none" | "fetching-data" | "public-data-ready" | "protected-data-ready" | "data-ready" | "data-fetch-failed";
|
|
53
53
|
|
|
54
54
|
export function reduceDataFetchEvents(
|
|
55
55
|
runtime: FireflyRuntime,
|
|
56
|
-
|
|
56
|
+
onDataFetchStarted: () => void,
|
|
57
57
|
onDataReady: () => void,
|
|
58
58
|
onPublicDataFetchStarted: () => void,
|
|
59
59
|
onPublicDataReady: () => void,
|
|
60
60
|
onProtectedDataFetchStarted: () => void,
|
|
61
|
-
onProtectedDataReady: () => void
|
|
61
|
+
onProtectedDataReady: () => void,
|
|
62
|
+
onDataFetchFailed: (queriesErrors: Error[]) => void
|
|
62
63
|
) {
|
|
63
64
|
let dataFetchState: DataFetchState = "none";
|
|
64
65
|
|
|
65
|
-
// TODO: Validate if this handler should use { once: true }.
|
|
66
66
|
runtime.eventBus.addListener(PublicDataFetchStartedEvent, () => {
|
|
67
67
|
if (dataFetchState === "none") {
|
|
68
68
|
dataFetchState = "fetching-data";
|
|
69
|
-
|
|
69
|
+
onDataFetchStarted();
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
onPublicDataFetchStarted();
|
|
73
|
-
});
|
|
73
|
+
}, { once: true });
|
|
74
74
|
|
|
75
|
-
// TODO: Validate if this handler should use { once: true }.
|
|
76
75
|
runtime.eventBus.addListener(PublicDataReadyEvent, () => {
|
|
77
76
|
onPublicDataReady();
|
|
78
77
|
|
|
@@ -82,19 +81,17 @@ export function reduceDataFetchEvents(
|
|
|
82
81
|
dataFetchState = "data-ready";
|
|
83
82
|
onDataReady();
|
|
84
83
|
}
|
|
85
|
-
});
|
|
84
|
+
}, { once: true });
|
|
86
85
|
|
|
87
|
-
// TODO: Validate if this handler should use { once: true }.
|
|
88
86
|
runtime.eventBus.addListener(ProtectedDataFetchStartedEvent, () => {
|
|
89
87
|
if (dataFetchState === "none") {
|
|
90
88
|
dataFetchState = "fetching-data";
|
|
91
|
-
|
|
89
|
+
onDataFetchStarted();
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
onProtectedDataFetchStarted();
|
|
95
|
-
});
|
|
93
|
+
}, { once: true });
|
|
96
94
|
|
|
97
|
-
// TODO: Validate if this handler should use { once: true }.
|
|
98
95
|
runtime.eventBus.addListener(ProtectedDataReadyEvent, () => {
|
|
99
96
|
onProtectedDataReady();
|
|
100
97
|
|
|
@@ -104,7 +101,18 @@ export function reduceDataFetchEvents(
|
|
|
104
101
|
dataFetchState = "data-ready";
|
|
105
102
|
onDataReady();
|
|
106
103
|
}
|
|
107
|
-
});
|
|
104
|
+
}, { once: true });
|
|
105
|
+
|
|
106
|
+
const handleDataFetchFailed = (payload: unknown) => {
|
|
107
|
+
if (dataFetchState !== "data-fetch-failed") {
|
|
108
|
+
dataFetchState = "data-fetch-failed";
|
|
109
|
+
|
|
110
|
+
onDataFetchFailed(payload as Error[]);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
runtime.eventBus.addListener(PublicDataFetchFailedEvent, handleDataFetchFailed, { once: true });
|
|
115
|
+
runtime.eventBus.addListener(ProtectedDataFetchFailedEvent, handleDataFetchFailed, { once: true });
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
@@ -316,6 +324,24 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
316
324
|
}
|
|
317
325
|
};
|
|
318
326
|
|
|
327
|
+
const handleDataFetchFailed = (queriesErrors: Error[]) => {
|
|
328
|
+
if (dataFetchSpan) {
|
|
329
|
+
queriesErrors.forEach(x => {
|
|
330
|
+
traceError(dataFetchSpan.instance, x);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
dataFetchSpan.instance.end();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (bootstrappingSpan) {
|
|
337
|
+
queriesErrors.forEach(x => {
|
|
338
|
+
traceError(bootstrappingSpan, x);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
bootstrappingSpan.end();
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
319
345
|
reduceDataFetchEvents(
|
|
320
346
|
runtime,
|
|
321
347
|
handleFetchDataStarted,
|
|
@@ -323,7 +349,8 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
323
349
|
handlePublicDataFetchStarted,
|
|
324
350
|
handlePublicDataReady,
|
|
325
351
|
handleProtectedDataFetchStarted,
|
|
326
|
-
handleProtectedDataReady
|
|
352
|
+
handleProtectedDataReady,
|
|
353
|
+
handleDataFetchFailed
|
|
327
354
|
);
|
|
328
355
|
|
|
329
356
|
runtime.eventBus.addListener(ModulesRegisteredEvent, () => {
|
|
@@ -467,38 +494,4 @@ export function registerHoneycombInstrumentation(runtime: FireflyRuntime) {
|
|
|
467
494
|
}
|
|
468
495
|
|
|
469
496
|
registerTrackingListeners(runtime);
|
|
470
|
-
|
|
471
|
-
// try {
|
|
472
|
-
// const registerFetchRequestHookFunction = getRegisterFetchRequestHookFunction();
|
|
473
|
-
|
|
474
|
-
// if (registerFetchRequestHookFunction) {
|
|
475
|
-
// const overrideFetchRequestHook = createOverrideFetchRequestWithManifestSectionSpanContext(runtime.logger);
|
|
476
|
-
|
|
477
|
-
// // Dynamically registering this request hook function to nest the HTTP requests
|
|
478
|
-
// // of the widgets initialization under the appropriate Honeycomb span.
|
|
479
|
-
// registerFetchRequestHookFunction(overrideFetchRequestHook);
|
|
480
|
-
// } else {
|
|
481
|
-
// runtime.logger.warning("[wlp-widgets] 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.");
|
|
482
|
-
// }
|
|
483
|
-
|
|
484
|
-
// registerTrackingListeners(runtime);
|
|
485
|
-
// } catch (error: unknown) {
|
|
486
|
-
// runtime.logger.error("[wlp-widgets] An error occured while registering Honeycomb instrumentation.", error);
|
|
487
|
-
// runtime.errorPropagator.propagate(error as Error);
|
|
488
|
-
// }
|
|
489
497
|
}
|
|
490
|
-
|
|
491
|
-
export function canRegisterHoneycombInstrumentation() {
|
|
492
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
493
|
-
// @ts-ignore
|
|
494
|
-
return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
// export function registerHoneycombInstrumentation(runtime: FireflyRuntime, namespace: string, serviceName: NonNullable<HoneycombSdkOptions["serviceName"]>, apiServiceUrls: PropagateTraceHeaderCorsUrls, options?: RegisterHoneycombInstrumentationOptions) {
|
|
498
|
-
// const augmentedOptions = getInstrumentationOptions(runtime, options);
|
|
499
|
-
|
|
500
|
-
// registerWorkleapHoneycombInstrumentation(namespace, serviceName, apiServiceUrls, augmentedOptions);
|
|
501
|
-
|
|
502
|
-
// registerTrackingListeners(runtime);
|
|
503
|
-
// registerActiveSpanStack();
|
|
504
|
-
// }
|
package/src/initializeFirefly.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { isFunction, registerLocalModules, type ModuleRegisterFunction, type Reg
|
|
|
2
2
|
import { registerRemoteModules, type RemoteDefinition } from "@squide/module-federation";
|
|
3
3
|
import { setMswAsReady } from "@squide/msw";
|
|
4
4
|
import { FireflyRuntime, type FireflyRuntimeOptions } from "./FireflyRuntime.tsx";
|
|
5
|
-
import {
|
|
5
|
+
import { initializeHoneycomb } from "./honeycomb/initializeHoneycomb.ts";
|
|
6
6
|
|
|
7
7
|
export const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
8
8
|
|
|
@@ -70,7 +70,8 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
|
|
|
70
70
|
mode,
|
|
71
71
|
useMsw,
|
|
72
72
|
loggers,
|
|
73
|
-
plugins
|
|
73
|
+
plugins,
|
|
74
|
+
onError
|
|
74
75
|
} = options;
|
|
75
76
|
|
|
76
77
|
if (hasExecuted) {
|
|
@@ -86,13 +87,15 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
|
|
|
86
87
|
plugins
|
|
87
88
|
});
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
initializeHoneycomb(runtime)
|
|
91
|
+
.catch((error: unknown) => {
|
|
92
|
+
if (onError) {
|
|
93
|
+
onError(error);
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
.finally(() => {
|
|
97
|
+
bootstrap(runtime, options);
|
|
98
|
+
});
|
|
96
99
|
|
|
97
100
|
return runtime;
|
|
98
101
|
}
|