@squide/firefly 16.1.2 → 16.1.3
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 +6 -0
- package/dist/initializeFirefly.js +30 -1
- package/dist/initializeFirefly.js.map +1 -1
- package/package.json +1 -1
- package/src/initializeFirefly.ts +72 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @squide/firefly
|
|
2
2
|
|
|
3
|
+
## 16.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#363](https://github.com/workleap/wl-squide/pull/363) [`b114284`](https://github.com/workleap/wl-squide/commit/b114284529ff87e719d594d9612a52b1935a0bb2) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Added a log when the application is initialized with the provided arguments.
|
|
8
|
+
|
|
3
9
|
## 16.1.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -54,13 +54,41 @@ function bootstrap(runtime, modulesDefinitions, options = {}) {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
function logInitializationState(runtime, options, plugins) {
|
|
58
|
+
const { mode, localModules, moduleDefinitions, useMsw, environmentVariables, honeycombInstrumentationClient, launchDarklyClient } = options;
|
|
59
|
+
const scope = runtime.logger.startScope("[squide] Initializing the application.");
|
|
60
|
+
try {
|
|
61
|
+
scope.information(`[squide] Mode: ${mode ?? "development"}`);
|
|
62
|
+
if (localModules) {
|
|
63
|
+
scope.withText("[squide] Local modules:").withObject(localModules).information();
|
|
64
|
+
}
|
|
65
|
+
if (moduleDefinitions) {
|
|
66
|
+
scope.withText("[squide] Module definitions:").withObject(moduleDefinitions).information();
|
|
67
|
+
}
|
|
68
|
+
scope.information(`[squide] Use MSW: ${useMsw ? "Yes" : "No"}`);
|
|
69
|
+
if (environmentVariables && Object.keys(environmentVariables).length > 0) {
|
|
70
|
+
scope.withText("[squide] Environment variables:").withObject(environmentVariables).information();
|
|
71
|
+
}
|
|
72
|
+
if (honeycombInstrumentationClient) {
|
|
73
|
+
scope.withText("[squide] Honeycomb instrumentation client:").withObject(honeycombInstrumentationClient).information();
|
|
74
|
+
}
|
|
75
|
+
if (launchDarklyClient) {
|
|
76
|
+
scope.withText("[squide] LaunchDarkly client:").withObject(launchDarklyClient).information();
|
|
77
|
+
}
|
|
78
|
+
if (plugins.length > 0) {
|
|
79
|
+
scope.withText("[squide] Plugins:").withObject(plugins).information();
|
|
80
|
+
}
|
|
81
|
+
} finally{
|
|
82
|
+
scope.end();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
57
85
|
let hasExecuted = false;
|
|
58
86
|
// Should only be used by tests.
|
|
59
87
|
function __resetHasExecutedGuard() {
|
|
60
88
|
hasExecuted = false;
|
|
61
89
|
}
|
|
62
90
|
function initializeFirefly(options = {}) {
|
|
63
|
-
const { mode, localModules = [], moduleDefinitions = [], useMsw,
|
|
91
|
+
const { mode, localModules = [], moduleDefinitions = [], useMsw, environmentVariables, honeycombInstrumentationClient, launchDarklyClient, plugins = [], loggers, onError } = options;
|
|
64
92
|
if (hasExecuted) {
|
|
65
93
|
throw new Error("[squide] A squide application can only be initialized once. Did you call the \"initializeSquide\" function twice?");
|
|
66
94
|
}
|
|
@@ -82,6 +110,7 @@ function initializeFirefly(options = {}) {
|
|
|
82
110
|
...plugins
|
|
83
111
|
]
|
|
84
112
|
});
|
|
113
|
+
logInitializationState(runtime, options, plugins);
|
|
85
114
|
initializeHoneycomb(runtime).catch((error)=>{
|
|
86
115
|
if (onError) {
|
|
87
116
|
onError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeFirefly.js","sources":["../src/initializeFirefly.ts"],"sourcesContent":["import { ModuleDefinition, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { isFunction } from \"@squide/core/internal\";\nimport { EnvironmentVariables, EnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { LaunchDarklyPlugin } from \"@squide/launch-darkly\";\nimport { MswPlugin } from \"@squide/msw\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport { LDClient } from \"launchdarkly-js-client-sdk\";\nimport { FireflyRuntime, type FireflyRuntimeOptions } from \"./FireflyRuntime.tsx\";\nimport { initializeHoneycomb } from \"./honeycomb/initializeHoneycomb.ts\";\n\nexport const ApplicationBootstrappingStartedEvent = \"squide-app-bootstrapping-started\";\n\nexport type OnInitializationErrorFunction = (error: unknown) => void;\n\nexport type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {\n localModules?: (ModuleRegisterFunction<TRuntime, TContext, TData> | undefined)[];\n moduleDefinitions?: ModuleDefinition<TRuntime, TContext, TData>[];\n useMsw?: boolean;\n environmentVariables?: Partial<EnvironmentVariables>;\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\n launchDarklyClient?: LDClient;\n startMsw?: StartMswFunction<FireflyRuntime>;\n onError?: OnInitializationErrorFunction;\n}\n\nexport function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(\n runtime: TRuntime,\n modulesDefinitions: (ModuleDefinition<TRuntime, TContext, TData> | undefined)[],\n options: Omit<InitializeFireflyOptions<TRuntime, TContext, TData>, \"localModules\" | \"moduleDefinitions\"> = {}\n) {\n const {\n startMsw,\n onError,\n context\n } = options;\n\n runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);\n\n runtime.moduleManager.registerModules(\n modulesDefinitions.filter((x): x is ModuleDefinition => Boolean(x)),\n { context }\n ).then(results => {\n if (runtime.isMswEnabled) {\n if (!isFunction(startMsw)) {\n throw new Error(\"[squide] When MSW is enabled, the \\\"startMsw\\\" function must be provided.\");\n }\n\n startMsw(runtime)\n .then(() => {\n if (runtime.isMswEnabled) {\n runtime.mswState.setAsReady();\n }\n })\n .catch((error: unknown) => {\n runtime.logger\n .withText(\"[squide] An error occured while starting MSW.\")\n .withError(error as Error)\n .error();\n });\n }\n\n if (onError) {\n results.forEach(error => {\n onError(error);\n });\n }\n });\n}\n\nlet hasExecuted = false;\n\n// Should only be used by tests.\nexport function __resetHasExecutedGuard() {\n hasExecuted = false;\n}\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n mode,\n localModules = [],\n moduleDefinitions = [],\n useMsw,\n plugins = [],\n environmentVariables,\n honeycombInstrumentationClient,\n launchDarklyClient,\n loggers,\n onError\n } = options;\n\n if (hasExecuted) {\n throw new Error(\"[squide] A squide application can only be initialized once. Did you call the \\\"initializeSquide\\\" function twice?\");\n }\n\n hasExecuted = true;\n\n if (useMsw) {\n plugins.push(x => new MswPlugin(x));\n }\n\n if (launchDarklyClient) {\n plugins.push(x => new LaunchDarklyPlugin(x, launchDarklyClient));\n }\n\n const runtime = new FireflyRuntime({\n mode,\n honeycombInstrumentationClient,\n loggers,\n plugins: [\n x => new EnvironmentVariablesPlugin(x, {\n variables: environmentVariables\n }),\n ...plugins\n ]\n });\n\n initializeHoneycomb(runtime)\n .catch((error: unknown) => {\n if (onError) {\n onError(error);\n }\n })\n .finally(() => {\n bootstrap(\n runtime,\n [...moduleDefinitions, ...toLocalModuleDefinitions(localModules)],\n options\n );\n });\n\n return runtime;\n}\n"],"names":["toLocalModuleDefinitions","isFunction","EnvironmentVariablesPlugin","LaunchDarklyPlugin","MswPlugin","FireflyRuntime","initializeHoneycomb","ApplicationBootstrappingStartedEvent","bootstrap","runtime","modulesDefinitions","options","startMsw","onError","context","x","Boolean","results","Error","error","hasExecuted","__resetHasExecutedGuard","initializeFirefly","mode","localModules","moduleDefinitions","useMsw","plugins","environmentVariables","honeycombInstrumentationClient","launchDarklyClient","loggers"],"mappings":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AACW;IACpC;IAEA,IAAIe,oBAAoB;QACpBH,QAAQ,IAAI,CAACZ,CAAAA,IAAK,IAAIZ,kBAAkBA,CAACY,GAAGe;IAChD;IAEA,MAAMrB,UAAU,IAAIJ,cAAcA,CAAC;QAC/BkB;QACAM;QACAE;QACA,SAAS;YACLhB,CAAAA,IAAK,IAAIb,0BAA0BA,CAACa,GAAG;oBACnC,WAAWa;gBACf;eACGD;SACN;IACL;IAEArB,mBAAmBA,CAACG,SACf,KAAK,CAAC,CAACU;QACJ,IAAIN,SAAS;YACTA,QAAQM;QACZ;IACJ,GACC,OAAO,CAAC;QACLX,UACIC,SACA;eAAIgB;eAAsBzB,wBAAwBA,CAACwB;SAAc,EACjEb;IAER;IAEJ,OAAOF;AACX"}
|
|
1
|
+
{"version":3,"file":"initializeFirefly.js","sources":["../src/initializeFirefly.ts"],"sourcesContent":["import { ModuleDefinition, PluginFactory, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { isFunction } from \"@squide/core/internal\";\nimport { EnvironmentVariables, EnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { LaunchDarklyPlugin } from \"@squide/launch-darkly\";\nimport { MswPlugin } from \"@squide/msw\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport { RootLogger } from \"@workleap/logging\";\nimport { LDClient } from \"launchdarkly-js-client-sdk\";\nimport { FireflyRuntime, type FireflyRuntimeOptions } from \"./FireflyRuntime.tsx\";\nimport { initializeHoneycomb } from \"./honeycomb/initializeHoneycomb.ts\";\n\nexport const ApplicationBootstrappingStartedEvent = \"squide-app-bootstrapping-started\";\n\nexport type OnInitializationErrorFunction = (error: unknown) => void;\n\nexport type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {\n localModules?: (ModuleRegisterFunction<TRuntime, TContext, TData> | undefined)[];\n moduleDefinitions?: ModuleDefinition<TRuntime, TContext, TData>[];\n useMsw?: boolean;\n environmentVariables?: Partial<EnvironmentVariables>;\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\n launchDarklyClient?: LDClient;\n startMsw?: StartMswFunction<FireflyRuntime>;\n onError?: OnInitializationErrorFunction;\n}\n\nexport function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(\n runtime: TRuntime,\n modulesDefinitions: (ModuleDefinition<TRuntime, TContext, TData> | undefined)[],\n options: Omit<InitializeFireflyOptions<TRuntime, TContext, TData>, \"localModules\" | \"moduleDefinitions\"> = {}\n) {\n const {\n startMsw,\n onError,\n context\n } = options;\n\n runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);\n\n runtime.moduleManager.registerModules(\n modulesDefinitions.filter((x): x is ModuleDefinition => Boolean(x)),\n { context }\n ).then(results => {\n if (runtime.isMswEnabled) {\n if (!isFunction(startMsw)) {\n throw new Error(\"[squide] When MSW is enabled, the \\\"startMsw\\\" function must be provided.\");\n }\n\n startMsw(runtime)\n .then(() => {\n if (runtime.isMswEnabled) {\n runtime.mswState.setAsReady();\n }\n })\n .catch((error: unknown) => {\n runtime.logger\n .withText(\"[squide] An error occured while starting MSW.\")\n .withError(error as Error)\n .error();\n });\n }\n\n if (onError) {\n results.forEach(error => {\n onError(error);\n });\n }\n });\n}\n\nfunction logInitializationState<TContext = unknown, TData = unknown>(\n runtime: FireflyRuntime,\n options: InitializeFireflyOptions<FireflyRuntime, TContext, TData>,\n plugins: PluginFactory<FireflyRuntime>[]\n) {\n const {\n mode,\n localModules,\n moduleDefinitions,\n useMsw,\n environmentVariables,\n honeycombInstrumentationClient,\n launchDarklyClient\n } = options;\n const scope = (runtime.logger as RootLogger).startScope(\"[squide] Initializing the application.\");\n\n try {\n scope.information(`[squide] Mode: ${mode ?? \"development\"}`);\n\n if (localModules) {\n scope\n .withText(\"[squide] Local modules:\")\n .withObject(localModules)\n .information();\n }\n\n if (moduleDefinitions) {\n scope\n .withText(\"[squide] Module definitions:\")\n .withObject(moduleDefinitions)\n .information();\n }\n\n scope.information(`[squide] Use MSW: ${useMsw ? \"Yes\" : \"No\"}`);\n\n if (environmentVariables && Object.keys(environmentVariables).length > 0) {\n scope\n .withText(\"[squide] Environment variables:\")\n .withObject(environmentVariables)\n .information();\n }\n\n if (honeycombInstrumentationClient) {\n scope\n .withText(\"[squide] Honeycomb instrumentation client:\")\n .withObject(honeycombInstrumentationClient)\n .information();\n }\n\n if (launchDarklyClient) {\n scope\n .withText(\"[squide] LaunchDarkly client:\")\n .withObject(launchDarklyClient)\n .information();\n }\n\n if (plugins.length > 0) {\n scope\n .withText(\"[squide] Plugins:\")\n .withObject(plugins)\n .information();\n }\n } finally {\n scope.end();\n }\n}\n\nlet hasExecuted = false;\n\n// Should only be used by tests.\nexport function __resetHasExecutedGuard() {\n hasExecuted = false;\n}\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n mode,\n localModules = [],\n moduleDefinitions = [],\n useMsw,\n environmentVariables,\n honeycombInstrumentationClient,\n launchDarklyClient,\n plugins = [],\n loggers,\n onError\n } = options;\n\n if (hasExecuted) {\n throw new Error(\"[squide] A squide application can only be initialized once. Did you call the \\\"initializeSquide\\\" function twice?\");\n }\n\n hasExecuted = true;\n\n if (useMsw) {\n plugins.push(x => new MswPlugin(x));\n }\n\n if (launchDarklyClient) {\n plugins.push(x => new LaunchDarklyPlugin(x, launchDarklyClient));\n }\n\n const runtime = new FireflyRuntime({\n mode,\n honeycombInstrumentationClient,\n loggers,\n plugins: [\n x => new EnvironmentVariablesPlugin(x, {\n variables: environmentVariables\n }),\n ...plugins\n ]\n });\n\n logInitializationState(runtime, options, plugins);\n\n initializeHoneycomb(runtime)\n .catch((error: unknown) => {\n if (onError) {\n onError(error);\n }\n })\n .finally(() => {\n bootstrap(\n runtime,\n [...moduleDefinitions, ...toLocalModuleDefinitions(localModules)],\n options\n );\n });\n\n return runtime;\n}\n"],"names":["toLocalModuleDefinitions","isFunction","EnvironmentVariablesPlugin","LaunchDarklyPlugin","MswPlugin","FireflyRuntime","initializeHoneycomb","ApplicationBootstrappingStartedEvent","bootstrap","runtime","modulesDefinitions","options","startMsw","onError","context","x","Boolean","results","Error","error","logInitializationState","plugins","mode","localModules","moduleDefinitions","useMsw","environmentVariables","honeycombInstrumentationClient","launchDarklyClient","scope","Object","hasExecuted","__resetHasExecutedGuard","initializeFirefly","loggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAmJ;AAChG;AACiC;AACzB;AACnB;AAI0C;AACT;AAElE,MAAMO,uCAAuC,mCAAmC;AAiBhF,SAASC,UACZC,OAAiB,EACjBC,kBAA+E,EAC/EC,UAA2G,CAAC,CAAC;IAE7G,MAAM,EACFC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACV,GAAGH;IAEJF,QAAQ,QAAQ,CAAC,QAAQ,CAACF;IAE1BE,QAAQ,aAAa,CAAC,eAAe,CACjCC,mBAAmB,MAAM,CAAC,CAACK,IAA6BC,QAAQD,KAChE;QAAED;IAAQ,GACZ,IAAI,CAACG,CAAAA;QACH,IAAIR,QAAQ,YAAY,EAAE;YACtB,IAAI,CAACR,UAAUA,CAACW,WAAW;gBACvB,MAAM,IAAIM,MAAM;YACpB;YAEAN,SAASH,SACJ,IAAI,CAAC;gBACF,IAAIA,QAAQ,YAAY,EAAE;oBACtBA,QAAQ,QAAQ,CAAC,UAAU;gBAC/B;YACJ,GACC,KAAK,CAAC,CAACU;gBACJV,QAAQ,MAAM,CACT,QAAQ,CAAC,iDACT,SAAS,CAACU,OACV,KAAK;YACd;QACR;QAEA,IAAIN,SAAS;YACTI,QAAQ,OAAO,CAACE,CAAAA;gBACZN,QAAQM;YACZ;QACJ;IACJ;AACJ;AAEA,SAASC,uBACLX,OAAuB,EACvBE,OAAkE,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oB,aAAa;QACb,MAAM,IAAIb,MAAM;IACpB;IAEAa,cAAc;IAEd,IAAIN,QAAQ;QACRJ,QAAQ,IAAI,CAACN,CAAAA,IAAK,IAAIX,SAASA,CAACW;IACpC;IAEA,IAAIa,oBAAoB;QACpBP,QAAQ,IAAI,CAACN,CAAAA,IAAK,IAAIZ,kBAAkBA,CAACY,GAAGa;IAChD;IAEA,MAAMnB,UAAU,IAAIJ,cAAcA,CAAC;QAC/BiB;QACAK;QACAO;QACA,SAAS;YACLnB,CAAAA,IAAK,IAAIb,0BAA0BA,CAACa,GAAG;oBACnC,WAAWW;gBACf;eACGL;SACN;IACL;IAEAD,uBAAuBX,SAASE,SAASU;IAEzCf,mBAAmBA,CAACG,SACf,KAAK,CAAC,CAACU;QACJ,IAAIN,SAAS;YACTA,QAAQM;QACZ;IACJ,GACC,OAAO,CAAC;QACLX,UACIC,SACA;eAAIe;eAAsBxB,wBAAwBA,CAACuB;SAAc,EACjEZ;IAER;IAEJ,OAAOF;AACX"}
|
package/package.json
CHANGED
package/src/initializeFirefly.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ModuleDefinition, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from "@squide/core";
|
|
1
|
+
import { ModuleDefinition, PluginFactory, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from "@squide/core";
|
|
2
2
|
import { isFunction } from "@squide/core/internal";
|
|
3
3
|
import { EnvironmentVariables, EnvironmentVariablesPlugin } from "@squide/env-vars";
|
|
4
4
|
import { LaunchDarklyPlugin } from "@squide/launch-darkly";
|
|
5
5
|
import { MswPlugin } from "@squide/msw";
|
|
6
6
|
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
7
|
+
import { RootLogger } from "@workleap/logging";
|
|
7
8
|
import { LDClient } from "launchdarkly-js-client-sdk";
|
|
8
9
|
import { FireflyRuntime, type FireflyRuntimeOptions } from "./FireflyRuntime.tsx";
|
|
9
10
|
import { initializeHoneycomb } from "./honeycomb/initializeHoneycomb.ts";
|
|
@@ -69,6 +70,73 @@ export function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TCon
|
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
function logInitializationState<TContext = unknown, TData = unknown>(
|
|
74
|
+
runtime: FireflyRuntime,
|
|
75
|
+
options: InitializeFireflyOptions<FireflyRuntime, TContext, TData>,
|
|
76
|
+
plugins: PluginFactory<FireflyRuntime>[]
|
|
77
|
+
) {
|
|
78
|
+
const {
|
|
79
|
+
mode,
|
|
80
|
+
localModules,
|
|
81
|
+
moduleDefinitions,
|
|
82
|
+
useMsw,
|
|
83
|
+
environmentVariables,
|
|
84
|
+
honeycombInstrumentationClient,
|
|
85
|
+
launchDarklyClient
|
|
86
|
+
} = options;
|
|
87
|
+
const scope = (runtime.logger as RootLogger).startScope("[squide] Initializing the application.");
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
scope.information(`[squide] Mode: ${mode ?? "development"}`);
|
|
91
|
+
|
|
92
|
+
if (localModules) {
|
|
93
|
+
scope
|
|
94
|
+
.withText("[squide] Local modules:")
|
|
95
|
+
.withObject(localModules)
|
|
96
|
+
.information();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (moduleDefinitions) {
|
|
100
|
+
scope
|
|
101
|
+
.withText("[squide] Module definitions:")
|
|
102
|
+
.withObject(moduleDefinitions)
|
|
103
|
+
.information();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
scope.information(`[squide] Use MSW: ${useMsw ? "Yes" : "No"}`);
|
|
107
|
+
|
|
108
|
+
if (environmentVariables && Object.keys(environmentVariables).length > 0) {
|
|
109
|
+
scope
|
|
110
|
+
.withText("[squide] Environment variables:")
|
|
111
|
+
.withObject(environmentVariables)
|
|
112
|
+
.information();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (honeycombInstrumentationClient) {
|
|
116
|
+
scope
|
|
117
|
+
.withText("[squide] Honeycomb instrumentation client:")
|
|
118
|
+
.withObject(honeycombInstrumentationClient)
|
|
119
|
+
.information();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (launchDarklyClient) {
|
|
123
|
+
scope
|
|
124
|
+
.withText("[squide] LaunchDarkly client:")
|
|
125
|
+
.withObject(launchDarklyClient)
|
|
126
|
+
.information();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (plugins.length > 0) {
|
|
130
|
+
scope
|
|
131
|
+
.withText("[squide] Plugins:")
|
|
132
|
+
.withObject(plugins)
|
|
133
|
+
.information();
|
|
134
|
+
}
|
|
135
|
+
} finally {
|
|
136
|
+
scope.end();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
72
140
|
let hasExecuted = false;
|
|
73
141
|
|
|
74
142
|
// Should only be used by tests.
|
|
@@ -82,10 +150,10 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
|
|
|
82
150
|
localModules = [],
|
|
83
151
|
moduleDefinitions = [],
|
|
84
152
|
useMsw,
|
|
85
|
-
plugins = [],
|
|
86
153
|
environmentVariables,
|
|
87
154
|
honeycombInstrumentationClient,
|
|
88
155
|
launchDarklyClient,
|
|
156
|
+
plugins = [],
|
|
89
157
|
loggers,
|
|
90
158
|
onError
|
|
91
159
|
} = options;
|
|
@@ -116,6 +184,8 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
|
|
|
116
184
|
]
|
|
117
185
|
});
|
|
118
186
|
|
|
187
|
+
logInitializationState(runtime, options, plugins);
|
|
188
|
+
|
|
119
189
|
initializeHoneycomb(runtime)
|
|
120
190
|
.catch((error: unknown) => {
|
|
121
191
|
if (onError) {
|