@squide/firefly 15.0.5 → 16.0.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/CHANGELOG.md +25 -0
- package/dist/AppRouter.js.map +1 -1
- package/dist/AppRouterContext.js.map +1 -1
- package/dist/AppRouterReducer.d.ts +3 -4
- package/dist/AppRouterReducer.js +51 -82
- package/dist/AppRouterReducer.js.map +1 -1
- package/dist/AppRouterStore.js.map +1 -1
- package/dist/FireflyPlugin.d.ts +6 -0
- package/dist/FireflyPlugin.js +6 -0
- package/dist/FireflyPlugin.js.map +1 -0
- package/dist/FireflyProvider.js.map +1 -1
- package/dist/FireflyRuntime.d.ts +26 -11
- package/dist/FireflyRuntime.js +61 -45
- package/dist/FireflyRuntime.js.map +1 -1
- package/dist/GlobalDataQueriesError.js.map +1 -1
- package/dist/RootRoute.js.map +1 -1
- package/dist/honeycomb/activeSpan.js.map +1 -1
- package/dist/honeycomb/createTraceContextId.js.map +1 -1
- package/dist/honeycomb/initializeHoneycomb.js.map +1 -1
- package/dist/honeycomb/registerHoneycombInstrumentation.d.ts +8 -0
- package/dist/honeycomb/registerHoneycombInstrumentation.js +19 -136
- package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
- package/dist/honeycomb/tracer.js.map +1 -1
- package/dist/honeycomb/utils.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/initializeFirefly.d.ts +8 -6
- package/dist/initializeFirefly.js +34 -34
- package/dist/initializeFirefly.js.map +1 -1
- package/dist/internal.d.ts +6 -0
- package/dist/internal.js +26 -0
- package/dist/internal.js.map +1 -0
- package/dist/useAppRouterStore.js.map +1 -1
- package/dist/useCanFetchProtectedData.js.map +1 -1
- package/dist/useCanFetchPublicData.js.map +1 -1
- package/dist/useCanRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useCanUpdateDeferredRegistrations.js.map +1 -1
- package/dist/useDeferredRegistrations.d.ts +1 -5
- package/dist/useDeferredRegistrations.js +2 -5
- package/dist/useDeferredRegistrations.js.map +1 -1
- package/dist/useExecuteOnce.js.map +1 -1
- package/dist/useIsActiveRouteProtected.js.map +1 -1
- package/dist/useIsBootstrapping.js.map +1 -1
- package/dist/useNavigationItems.js.map +1 -1
- package/dist/useProtectedDataHandler.js.map +1 -1
- package/dist/useProtectedDataQueries.js.map +1 -1
- package/dist/usePublicDataHandler.js.map +1 -1
- package/dist/usePublicDataQueries.js.map +1 -1
- package/dist/useRegisterDeferredRegistrations.d.ts +1 -4
- package/dist/useRegisterDeferredRegistrations.js +1 -5
- package/dist/useRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useStrictRegistrationMode.js +10 -17
- package/dist/useStrictRegistrationMode.js.map +1 -1
- package/dist/useUpdateDeferredRegistrations.d.ts +3 -4
- package/dist/useUpdateDeferredRegistrations.js +6 -6
- package/dist/useUpdateDeferredRegistrations.js.map +1 -1
- package/package.json +33 -23
- package/src/AppRouterReducer.ts +51 -89
- package/src/FireflyPlugin.ts +11 -0
- package/src/FireflyRuntime.tsx +89 -55
- package/src/honeycomb/registerHoneycombInstrumentation.ts +30 -169
- package/src/index.ts +31 -4
- package/src/initializeFirefly.ts +60 -49
- package/src/internal.ts +22 -0
- package/src/useDeferredRegistrations.ts +3 -12
- package/src/useRegisterDeferredRegistrations.ts +1 -2
- package/src/useStrictRegistrationMode.ts +10 -15
- package/src/useUpdateDeferredRegistrations.ts +8 -2
package/src/FireflyRuntime.tsx
CHANGED
|
@@ -1,110 +1,127 @@
|
|
|
1
1
|
import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from "@squide/core";
|
|
2
|
-
import {
|
|
2
|
+
import { EnvironmentVariableKey, EnvironmentVariables, EnvironmentVariableValue, getEnvironmentVariablesPlugin } from "@squide/env-vars";
|
|
3
|
+
import { getMswPlugin, MswPluginName, MswState } from "@squide/msw";
|
|
3
4
|
import { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from "@squide/react-router";
|
|
4
5
|
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
5
6
|
import type { Logger } from "@workleap/logging";
|
|
6
7
|
import type { RequestHandler } from "msw";
|
|
7
|
-
import { getAreModulesRegistered } from "./AppRouterReducer.ts";
|
|
8
8
|
import { type AppRouterStore, createAppRouterStore } from "./AppRouterStore.ts";
|
|
9
9
|
|
|
10
|
-
export interface FireflyRuntimeOptions extends RuntimeOptions {
|
|
11
|
-
useMsw?: boolean;
|
|
10
|
+
export interface FireflyRuntimeOptions<TRuntime extends FireflyRuntime = FireflyRuntime> extends RuntimeOptions<TRuntime> {
|
|
12
11
|
honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {}
|
|
16
15
|
|
|
17
16
|
export interface IFireflyRuntime extends IReactRouterRuntime {
|
|
17
|
+
getMswState(): MswState;
|
|
18
18
|
registerRequestHandlers: (handlers: RequestHandler[]) => void;
|
|
19
19
|
get requestHandlers(): RequestHandler[];
|
|
20
|
-
get appRouterStore(): AppRouterStore;
|
|
21
20
|
get isMswEnabled(): boolean;
|
|
21
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;
|
|
22
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
|
|
23
|
+
getEnvironmentVariable(key: EnvironmentVariableKey): EnvironmentVariableValue;
|
|
24
|
+
getEnvironmentVariables(): EnvironmentVariables;
|
|
25
|
+
get appRouterStore(): AppRouterStore;
|
|
22
26
|
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
export class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends ReactRouterRuntime<TRuntime> implements IFireflyRuntime {
|
|
26
31
|
protected _appRouterStore: AppRouterStore;
|
|
27
|
-
protected _useMsw: boolean;
|
|
28
32
|
protected _honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;
|
|
29
33
|
|
|
30
|
-
constructor(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
],
|
|
37
|
-
...options
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
this._useMsw = true;
|
|
41
|
-
} else {
|
|
42
|
-
super({
|
|
43
|
-
plugins,
|
|
44
|
-
...options
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
this._useMsw = false;
|
|
48
|
-
}
|
|
34
|
+
constructor(options: FireflyRuntimeOptions = {}) {
|
|
35
|
+
const {
|
|
36
|
+
honeycombInstrumentationClient
|
|
37
|
+
} = options;
|
|
38
|
+
|
|
39
|
+
super(options);
|
|
49
40
|
|
|
50
41
|
this._appRouterStore = createAppRouterStore(this._logger);
|
|
51
42
|
this._honeycombInstrumentationClient = honeycombInstrumentationClient;
|
|
52
43
|
}
|
|
53
44
|
|
|
45
|
+
registerRoute(route: Route, options: RegisterRouteOptions = {}) {
|
|
46
|
+
if (this.moduleManager.getAreModulesRegistered()) {
|
|
47
|
+
throw new Error("[squide] Cannot register a route once the modules are registered. Are you trying to register a route in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
super.registerRoute(route, options);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getMswState() {
|
|
54
|
+
const plugin = getMswPlugin(this);
|
|
55
|
+
|
|
56
|
+
return plugin.mswState;
|
|
57
|
+
}
|
|
58
|
+
|
|
54
59
|
registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {
|
|
55
60
|
const logger = this._getLogger(options);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
if (!mswPlugin) {
|
|
59
|
-
throw new Error("[squide] Cannot register the provided MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \"useMsw\" option?");
|
|
60
|
-
}
|
|
61
|
+
const plugin = getMswPlugin(this);
|
|
61
62
|
|
|
62
|
-
if (getAreModulesRegistered()) {
|
|
63
|
+
if (this.moduleManager.getAreModulesRegistered()) {
|
|
63
64
|
throw new Error("[squide] Cannot register an MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
plugin.registerRequestHandlers(handlers, {
|
|
67
68
|
logger
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
// Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
|
|
72
73
|
get requestHandlers(): RequestHandler[] {
|
|
73
|
-
const
|
|
74
|
+
const plugin = getMswPlugin(this);
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
76
|
+
return plugin.requestHandlers;
|
|
77
|
+
}
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
get isMswEnabled() {
|
|
80
|
+
return this._plugins.some(x => x.name === MswPluginName);
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
throw new Error("[squide] Cannot register a route once the modules are registered. Are you trying to register a route in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
|
|
85
|
-
}
|
|
83
|
+
getEnvironmentVariable(key: EnvironmentVariableKey) {
|
|
84
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
return plugin.getVariable(key);
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
getEnvironmentVariables() {
|
|
90
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
91
|
+
|
|
92
|
+
return plugin.getVariables();
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue) {
|
|
96
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
97
|
+
|
|
98
|
+
return plugin.registerVariable(key, value);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {
|
|
102
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
103
|
+
|
|
104
|
+
return plugin.registerVariables(variables);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
get appRouterStore() {
|
|
108
|
+
return this._appRouterStore;
|
|
96
109
|
}
|
|
97
110
|
|
|
98
111
|
get honeycombInstrumentationClient() {
|
|
99
112
|
return this._honeycombInstrumentationClient;
|
|
100
113
|
}
|
|
101
114
|
|
|
102
|
-
startScope(logger: Logger):
|
|
103
|
-
return (new FireflyRuntimeScope(this, logger) as unknown) as
|
|
115
|
+
startScope(logger: Logger): TRuntime {
|
|
116
|
+
return (new FireflyRuntimeScope(this, logger) as unknown) as TRuntime;
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
119
|
|
|
107
120
|
export class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntime> extends ReactRouterRuntimeScope<TRuntime> implements IFireflyRuntime {
|
|
121
|
+
getMswState() {
|
|
122
|
+
return this._runtime.getMswState();
|
|
123
|
+
}
|
|
124
|
+
|
|
108
125
|
registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {
|
|
109
126
|
this._runtime.registerRequestHandlers(handlers, {
|
|
110
127
|
...options,
|
|
@@ -112,19 +129,36 @@ export class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntim
|
|
|
112
129
|
});
|
|
113
130
|
}
|
|
114
131
|
|
|
132
|
+
// Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
|
|
115
133
|
get requestHandlers(): RequestHandler[] {
|
|
116
134
|
return this._runtime.requestHandlers;
|
|
117
135
|
}
|
|
118
136
|
|
|
119
|
-
get appRouterStore() {
|
|
120
|
-
return this._runtime.appRouterStore;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
137
|
get isMswEnabled() {
|
|
124
138
|
return this._runtime.isMswEnabled;
|
|
125
139
|
}
|
|
126
140
|
|
|
127
|
-
|
|
128
|
-
return this._runtime.
|
|
141
|
+
getEnvironmentVariables() {
|
|
142
|
+
return this._runtime.getEnvironmentVariables();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
getEnvironmentVariable(key: EnvironmentVariableKey) {
|
|
146
|
+
return this._runtime.getEnvironmentVariable(key);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue) {
|
|
150
|
+
this._runtime.registerEnvironmentVariable(key, value);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {
|
|
154
|
+
this._runtime.registerEnvironmentVariables(variables);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
get appRouterStore(): AppRouterStore {
|
|
158
|
+
throw new Error("[squide] Cannot retrieve the app router store from a runtime scope instance.");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient {
|
|
162
|
+
throw new Error("[squide] Cannot retrieve the Honeycomb instrumentation client from a runtime scope instance.");
|
|
129
163
|
}
|
|
130
164
|
}
|
|
@@ -20,43 +20,27 @@ import {
|
|
|
20
20
|
type LocalModulesRegistrationStartedEventPayload,
|
|
21
21
|
type ModuleRegistrationError
|
|
22
22
|
} from "@squide/core";
|
|
23
|
-
import {
|
|
24
|
-
DeferredRegistrationsUpdateCompletedEvent,
|
|
25
|
-
DeferredRegistrationsUpdateStartedEvent,
|
|
26
|
-
RemoteModuleDeferredRegistrationFailedEvent,
|
|
27
|
-
RemoteModuleDeferredRegistrationUpdateFailedEvent,
|
|
28
|
-
type RemoteModuleRegistrationError,
|
|
29
|
-
RemoteModuleRegistrationFailedEvent,
|
|
30
|
-
RemoteModulesDeferredRegistrationCompletedEvent,
|
|
31
|
-
type RemoteModulesDeferredRegistrationCompletedEventPayload,
|
|
32
|
-
RemoteModulesDeferredRegistrationStartedEvent,
|
|
33
|
-
type RemoteModulesDeferredRegistrationStartedEventPayload,
|
|
34
|
-
RemoteModulesDeferredRegistrationsUpdateCompletedEvent,
|
|
35
|
-
type RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload,
|
|
36
|
-
RemoteModulesDeferredRegistrationsUpdateStartedEvent,
|
|
37
|
-
type RemoteModulesDeferredRegistrationsUpdateStartedEventPayload,
|
|
38
|
-
RemoteModulesRegistrationCompletedEvent,
|
|
39
|
-
type RemoteModulesRegistrationCompletedEventPayload,
|
|
40
|
-
RemoteModulesRegistrationStartedEvent,
|
|
41
|
-
type RemoteModulesRegistrationStartedEventPayload
|
|
42
|
-
} from "@squide/module-federation";
|
|
43
23
|
import { ApplicationBoostrappedEvent, type AppRouterWaitState, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, PublicDataReadyEvent } from "../AppRouterReducer.ts";
|
|
24
|
+
import { FireflyPlugin } from "../FireflyPlugin.ts";
|
|
44
25
|
import type { FireflyRuntime } from "../FireflyRuntime.tsx";
|
|
45
26
|
import { ApplicationBootstrappingStartedEvent } from "../initializeFirefly.ts";
|
|
46
27
|
import { ProtectedDataFetchFailedEvent, ProtectedDataFetchStartedEvent } from "../useProtectedDataQueries.ts";
|
|
47
28
|
import { PublicDataFetchFailedEvent, PublicDataFetchStartedEvent } from "../usePublicDataQueries.ts";
|
|
29
|
+
import { DeferredRegistrationsUpdateCompletedEvent, DeferredRegistrationsUpdateStartedEvent } from "../useUpdateDeferredRegistrations.ts";
|
|
48
30
|
import { type ActiveSpan, createOverrideFetchRequestSpanWithActiveSpanContext, registerActiveSpanStack } from "./activeSpan.ts";
|
|
49
31
|
import { getTracer } from "./tracer.ts";
|
|
50
32
|
import { endActiveSpan, startActiveChildSpan, startChildSpan, startSpan, traceError } from "./utils.ts";
|
|
51
33
|
|
|
52
34
|
// TIPS:
|
|
53
|
-
// To query those traces in Honeycomb, use the following query filter:
|
|
35
|
+
// To query those traces in Honeycomb, use the following query filter:
|
|
36
|
+
// "root.name = squide-bootstrapping" and
|
|
37
|
+
// "root.name = squide-deferred-registrations-update".
|
|
54
38
|
|
|
55
|
-
interface AddProtectedListenerOptions extends AddListenerOptions {
|
|
39
|
+
export interface AddProtectedListenerOptions extends AddListenerOptions {
|
|
56
40
|
onError?: (error: unknown) => void;
|
|
57
41
|
}
|
|
58
42
|
|
|
59
|
-
function addProtectedListener(runtime: FireflyRuntime, eventName: EventName, callback: EventCallbackFunction, options?: AddProtectedListenerOptions) {
|
|
43
|
+
export function addProtectedListener(runtime: FireflyRuntime, eventName: EventName, callback: EventCallbackFunction, options?: AddProtectedListenerOptions) {
|
|
60
44
|
const protectedCallback = (...args: unknown[]) => {
|
|
61
45
|
try {
|
|
62
46
|
callback(...args);
|
|
@@ -71,6 +55,9 @@ function addProtectedListener(runtime: FireflyRuntime, eventName: EventName, cal
|
|
|
71
55
|
runtime.eventBus.addListener(eventName, protectedCallback, options);
|
|
72
56
|
}
|
|
73
57
|
|
|
58
|
+
export type GetSpanFunction = () => Span;
|
|
59
|
+
export type HoneycombTrackingUnmanagedErrorHandler = (error: unknown) => void;
|
|
60
|
+
|
|
74
61
|
type DataFetchState = "none" | "fetching-data" | "public-data-ready" | "protected-data-ready" | "data-ready" | "data-fetch-failed";
|
|
75
62
|
|
|
76
63
|
export function reduceDataFetchEvents(
|
|
@@ -172,12 +159,11 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
172
159
|
let bootstrappingSpanHasEnded: boolean = false;
|
|
173
160
|
let localModuleRegistrationSpan: Span;
|
|
174
161
|
let localModuleDeferredRegistrationSpan: Span;
|
|
175
|
-
let remoteModuleRegistrationSpan: Span;
|
|
176
|
-
let remoteModuleDeferredRegistrationSpan: Span;
|
|
177
162
|
let dataFetchSpan: ActiveSpan;
|
|
178
163
|
let deferredRegistrationsUpdateSpan: Span;
|
|
179
164
|
let localModuleDeferredRegistrationsUpdateSpan: ActiveSpan;
|
|
180
|
-
|
|
165
|
+
|
|
166
|
+
const pluginsUnmanagedErrorHandlers: HoneycombTrackingUnmanagedErrorHandler[] = [];
|
|
181
167
|
|
|
182
168
|
const handleUnmanagedError = (error: unknown) => {
|
|
183
169
|
if (bootstrappingSpan && !bootstrappingSpanHasEnded) {
|
|
@@ -195,14 +181,6 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
195
181
|
localModuleDeferredRegistrationSpan.end();
|
|
196
182
|
}
|
|
197
183
|
|
|
198
|
-
if (remoteModuleRegistrationSpan) {
|
|
199
|
-
remoteModuleRegistrationSpan.end();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (remoteModuleDeferredRegistrationSpan) {
|
|
203
|
-
remoteModuleDeferredRegistrationSpan.end();
|
|
204
|
-
}
|
|
205
|
-
|
|
206
184
|
if (dataFetchSpan) {
|
|
207
185
|
dataFetchSpan.instance.end();
|
|
208
186
|
}
|
|
@@ -215,9 +193,9 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
215
193
|
localModuleDeferredRegistrationsUpdateSpan.instance.end();
|
|
216
194
|
}
|
|
217
195
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
196
|
+
pluginsUnmanagedErrorHandlers.forEach(x => {
|
|
197
|
+
x(error);
|
|
198
|
+
});
|
|
221
199
|
};
|
|
222
200
|
|
|
223
201
|
addProtectedListener(runtime, ApplicationBootstrappingStartedEvent, () => {
|
|
@@ -332,92 +310,6 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
332
310
|
onError: handleUnmanagedError
|
|
333
311
|
});
|
|
334
312
|
|
|
335
|
-
addProtectedListener(runtime, RemoteModulesRegistrationStartedEvent, (payload: unknown) => {
|
|
336
|
-
const attributes = {
|
|
337
|
-
"app.squide.remote_count": (payload as RemoteModulesRegistrationStartedEventPayload).remoteCount
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
if (bootstrappingSpan) {
|
|
341
|
-
bootstrappingSpan.addEvent("remote-module-registration-started", attributes);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
remoteModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {
|
|
345
|
-
return getTracer().startSpan("remote-module-registration", { ...options, attributes }, context);
|
|
346
|
-
});
|
|
347
|
-
}, {
|
|
348
|
-
once: true,
|
|
349
|
-
onError: handleUnmanagedError
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
addProtectedListener(runtime, RemoteModulesRegistrationCompletedEvent, (payload: unknown) => {
|
|
353
|
-
if (bootstrappingSpan) {
|
|
354
|
-
bootstrappingSpan.addEvent("remote-module-registration-completed", {
|
|
355
|
-
"app.squide.remote_count": (payload as RemoteModulesRegistrationCompletedEventPayload).remoteCount
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (remoteModuleRegistrationSpan) {
|
|
360
|
-
remoteModuleRegistrationSpan.end();
|
|
361
|
-
}
|
|
362
|
-
}, {
|
|
363
|
-
once: true,
|
|
364
|
-
onError: handleUnmanagedError
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
// Can occur multiple times.
|
|
368
|
-
addProtectedListener(runtime, RemoteModuleRegistrationFailedEvent, (payload: unknown) => {
|
|
369
|
-
const registrationError = payload as RemoteModuleRegistrationError;
|
|
370
|
-
|
|
371
|
-
if (remoteModuleRegistrationSpan) {
|
|
372
|
-
traceError(remoteModuleRegistrationSpan, registrationError);
|
|
373
|
-
}
|
|
374
|
-
}, {
|
|
375
|
-
onError: handleUnmanagedError
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
addProtectedListener(runtime, RemoteModulesDeferredRegistrationStartedEvent, (payload: unknown) => {
|
|
379
|
-
const attributes = {
|
|
380
|
-
"app.squide.registration_count": (payload as RemoteModulesDeferredRegistrationStartedEventPayload).registrationCount
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
if (bootstrappingSpan) {
|
|
384
|
-
bootstrappingSpan.addEvent("remote-module-deferred-registration-started", attributes);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
remoteModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {
|
|
388
|
-
return getTracer().startSpan("remote-module-deferred-registration", { ...options, attributes }, context);
|
|
389
|
-
});
|
|
390
|
-
}, {
|
|
391
|
-
once: true,
|
|
392
|
-
onError: handleUnmanagedError
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
addProtectedListener(runtime, RemoteModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {
|
|
396
|
-
if (bootstrappingSpan) {
|
|
397
|
-
bootstrappingSpan.addEvent("remote-module-deferred-registration-completed", {
|
|
398
|
-
"app.squide.registration_count": (payload as RemoteModulesDeferredRegistrationCompletedEventPayload).registrationCount
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (remoteModuleDeferredRegistrationSpan) {
|
|
403
|
-
remoteModuleDeferredRegistrationSpan.end();
|
|
404
|
-
}
|
|
405
|
-
}, {
|
|
406
|
-
once: true,
|
|
407
|
-
onError: handleUnmanagedError
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
// Can occur multiple times.
|
|
411
|
-
addProtectedListener(runtime, RemoteModuleDeferredRegistrationFailedEvent, (payload: unknown) => {
|
|
412
|
-
const registrationError = payload as RemoteModuleRegistrationError;
|
|
413
|
-
|
|
414
|
-
if (remoteModuleDeferredRegistrationSpan) {
|
|
415
|
-
traceError(remoteModuleDeferredRegistrationSpan, registrationError);
|
|
416
|
-
}
|
|
417
|
-
}, {
|
|
418
|
-
onError: handleUnmanagedError
|
|
419
|
-
});
|
|
420
|
-
|
|
421
313
|
const handleFetchDataStarted = () => {
|
|
422
314
|
dataFetchSpan = startActiveChildSpan(bootstrappingSpan, (options, context) => {
|
|
423
315
|
const name = "data-fetch";
|
|
@@ -576,57 +468,26 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
576
468
|
onError: handleUnmanagedError
|
|
577
469
|
});
|
|
578
470
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
const attributes = {
|
|
582
|
-
"app.squide.registration_count": (payload as RemoteModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
if (deferredRegistrationsUpdateSpan) {
|
|
586
|
-
deferredRegistrationsUpdateSpan.addEvent("remote-module-deferred-registrations-update-started", attributes);
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
remoteModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context) => {
|
|
590
|
-
const name = "remote-module-deferred-registrations-update";
|
|
591
|
-
|
|
592
|
-
const span = getTracer().startSpan(name, {
|
|
593
|
-
attributes,
|
|
594
|
-
...options
|
|
595
|
-
}, context);
|
|
596
|
-
|
|
597
|
-
return {
|
|
598
|
-
name,
|
|
599
|
-
span
|
|
600
|
-
};
|
|
601
|
-
});
|
|
602
|
-
}, {
|
|
603
|
-
onError: handleUnmanagedError
|
|
604
|
-
});
|
|
471
|
+
const getBootstrappingSpan: GetSpanFunction = () => bootstrappingSpan;
|
|
472
|
+
const getDeferredRegistrationsUpdateSpan: GetSpanFunction = () => deferredRegistrationsUpdateSpan;
|
|
605
473
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
deferredRegistrationsUpdateSpan.addEvent("remote-module-deferred-registrations-update-completed", {
|
|
610
|
-
"app.squide.registration_count": (payload as RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount
|
|
611
|
-
});
|
|
612
|
-
}
|
|
474
|
+
const handlePluginUnmanagedError: HoneycombTrackingUnmanagedErrorHandler = (error: unknown) => {
|
|
475
|
+
handleUnmanagedError(error);
|
|
476
|
+
};
|
|
613
477
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}, {
|
|
618
|
-
onError: handleUnmanagedError
|
|
619
|
-
});
|
|
478
|
+
// Register plugins specific handlers for Honeycomb telemetry.
|
|
479
|
+
runtime.plugins.forEach(x => {
|
|
480
|
+
const plugin = x as FireflyPlugin;
|
|
620
481
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
482
|
+
if (plugin.registerHoneycombTrackingListeners) {
|
|
483
|
+
const unmanagedErrorHandler = plugin.registerHoneycombTrackingListeners(
|
|
484
|
+
getBootstrappingSpan,
|
|
485
|
+
getDeferredRegistrationsUpdateSpan,
|
|
486
|
+
handlePluginUnmanagedError
|
|
487
|
+
);
|
|
624
488
|
|
|
625
|
-
|
|
626
|
-
traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);
|
|
489
|
+
pluginsUnmanagedErrorHandlers.push(unmanagedErrorHandler);
|
|
627
490
|
}
|
|
628
|
-
}, {
|
|
629
|
-
onError: handleUnmanagedError
|
|
630
491
|
});
|
|
631
492
|
}
|
|
632
493
|
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
export * from "@squide/core";
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export {
|
|
3
|
+
EnvironmentVariablesPlugin,
|
|
4
|
+
useEnvironmentVariable,
|
|
5
|
+
useEnvironmentVariables,
|
|
6
|
+
type EnvironmentVariableKey,
|
|
7
|
+
type EnvironmentVariables,
|
|
8
|
+
type EnvironmentVariablesPluginOptions,
|
|
9
|
+
type EnvironmentVariableValue
|
|
10
|
+
} from "@squide/env-vars";
|
|
11
|
+
export {
|
|
12
|
+
MswPlugin,
|
|
13
|
+
MswState,
|
|
14
|
+
type MswPluginOptions,
|
|
15
|
+
type MswPluginRegisterRequestHandlersOptions,
|
|
16
|
+
type MswReadyListener,
|
|
17
|
+
type MswStateOptions
|
|
18
|
+
} from "@squide/msw";
|
|
4
19
|
export * from "@squide/react-router";
|
|
5
20
|
|
|
21
|
+
export type { FireflyPlugin } from "./FireflyPlugin.ts";
|
|
6
22
|
export * from "./FireflyProvider.tsx";
|
|
7
23
|
export * from "./FireflyRuntime.tsx";
|
|
8
24
|
|
|
9
25
|
export * from "./AppRouter.tsx";
|
|
10
|
-
export
|
|
11
|
-
|
|
26
|
+
export {
|
|
27
|
+
ActiveRouteIsProtectedEvent,
|
|
28
|
+
ActiveRouteIsPublicEvent,
|
|
29
|
+
ApplicationBoostrappedEvent,
|
|
30
|
+
DeferredRegistrationsUpdatedEvent,
|
|
31
|
+
ModulesReadyEvent,
|
|
32
|
+
ModulesRegisteredEvent,
|
|
33
|
+
MswReadyEvent,
|
|
34
|
+
ProtectedDataReadyEvent,
|
|
35
|
+
ProtectedDataUpdatedEvent,
|
|
36
|
+
PublicDataReadyEvent,
|
|
37
|
+
PublicDataUpdatedEvent
|
|
38
|
+
} from "./AppRouterReducer.ts";
|
|
12
39
|
|
|
13
40
|
export * from "./AppRouterStore.ts";
|
|
14
41
|
export * from "./GlobalDataQueriesError.ts";
|