@fluidframework/telemetry-utils 2.0.0-internal.3.0.0 → 2.0.0-internal.3.1.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/.eslintrc.js +11 -13
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -3
- package/dist/config.js.map +1 -1
- package/dist/debugLogger.d.ts.map +1 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/errorLogging.d.ts +5 -5
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js +20 -18
- package/dist/errorLogging.js.map +1 -1
- package/dist/eventEmitterWithErrorHandling.d.ts.map +1 -1
- package/dist/eventEmitterWithErrorHandling.js.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/fluidErrorBase.d.ts.map +1 -1
- package/dist/fluidErrorBase.js +4 -4
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +13 -12
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.d.ts +5 -5
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +5 -5
- package/dist/mockLogger.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/telemetryTypes.d.ts.map +1 -1
- package/dist/telemetryTypes.js.map +1 -1
- package/dist/thresholdCounter.d.ts.map +1 -1
- package/dist/thresholdCounter.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/lib/debugLogger.d.ts.map +1 -1
- package/lib/debugLogger.js +1 -1
- package/lib/debugLogger.js.map +1 -1
- package/lib/errorLogging.d.ts +5 -5
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js +20 -18
- package/lib/errorLogging.js.map +1 -1
- package/lib/eventEmitterWithErrorHandling.d.ts.map +1 -1
- package/lib/eventEmitterWithErrorHandling.js.map +1 -1
- package/lib/events.d.ts.map +1 -1
- package/lib/events.js.map +1 -1
- package/lib/fluidErrorBase.d.ts.map +1 -1
- package/lib/fluidErrorBase.js +4 -4
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +14 -13
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.d.ts +5 -5
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +5 -5
- package/lib/mockLogger.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/telemetryTypes.d.ts.map +1 -1
- package/lib/telemetryTypes.js.map +1 -1
- package/lib/thresholdCounter.d.ts.map +1 -1
- package/lib/thresholdCounter.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +107 -110
- package/prettier.config.cjs +1 -1
- package/src/config.ts +173 -172
- package/src/debugLogger.ts +118 -111
- package/src/errorLogging.ts +302 -299
- package/src/eventEmitterWithErrorHandling.ts +16 -12
- package/src/events.ts +26 -26
- package/src/fluidErrorBase.ts +42 -38
- package/src/index.ts +26 -16
- package/src/logger.ts +541 -533
- package/src/mockLogger.ts +113 -107
- package/src/packageVersion.ts +1 -1
- package/src/sampledTelemetryHelper.ts +122 -122
- package/src/telemetryTypes.ts +37 -37
- package/src/thresholdCounter.ts +34 -34
- package/src/utils.ts +15 -15
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
package/.eslintrc.js
CHANGED
|
@@ -4,16 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
13
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
14
|
+
"no-bitwise": "off",
|
|
15
|
+
"prefer-rest-params": "off",
|
|
16
|
+
},
|
|
17
|
+
};
|
package/.mocharc.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require(
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common-report.json"
|
|
4
4
|
}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAEpD,oBAAY,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,mBAAmB;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAEpD,oBAAY,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC3D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAC9C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;IACrD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,G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C,CAAC,SAAS,oBAAoB,GAAG,gBAAgB,EAC1F,MAAM,EAAE,CAAC,GACP,iBAAiB,CAAC,CAAC,CAAC,CAKtB;AAED,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,oBAAoB,GAAG,gBAAgB,EACvF,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,wBAiB/C"}
|
package/dist/config.js
CHANGED
|
@@ -113,9 +113,9 @@ class CachedConfigProvider {
|
|
|
113
113
|
const candidateProviders = [...orderedBaseProviders];
|
|
114
114
|
while (candidateProviders.length > 0) {
|
|
115
115
|
const baseProvider = candidateProviders.shift();
|
|
116
|
-
if (baseProvider !== undefined
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
if (baseProvider !== undefined &&
|
|
117
|
+
isConfigProviderBase(baseProvider) &&
|
|
118
|
+
!knownProviders.has(baseProvider)) {
|
|
119
119
|
knownProviders.add(baseProvider);
|
|
120
120
|
if (baseProvider instanceof CachedConfigProvider) {
|
|
121
121
|
candidateProviders.push(...baseProvider.orderedBaseProviders);
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAKA,+DAAoD;AAsBpD;;;;GAIG;AACU,QAAA,4BAA4B,GACrC,IAAI,mBAAI,CAAsB,GAAG,EAAE,CAAC,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;AAEtF,MAAM,kBAAkB,GAAwB;IAC5C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAChC,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAC/B,CAAC,OAA4B,EAAuB,EAAE;IACtD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE;QAC3C,OAAO,IAAI,oBAAoB,CAAC;YAC5B,YAAY,EAAE,CAAC,IAAY,EA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W,aAAX,WAAW,uBAAX,WAAW,CAAE,YAAY,CAAC,KAAK,UAAU,CAAC;AAC7D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { Lazy } from \"@fluidframework/common-utils\";\n\nexport type ConfigTypes = string | number | boolean | number[] | string[] | boolean[] | undefined;\n\n/**\n * Base interface for providing configurations to enable/disable/control features\n */\nexport interface IConfigProviderBase {\n getRawConfig(name: string): ConfigTypes;\n}\n\n/**\n * Explicitly typed interface for reading configurations\n */\n export interface IConfigProvider extends IConfigProviderBase {\n getBoolean(name: string): boolean | undefined;\n getNumber(name: string): number | undefined;\n getString(name: string): string | undefined;\n getBooleanArray(name: string): boolean[] | undefined;\n getNumberArray(name: string): number[] | undefined;\n getStringArray(name: string): string[] | undefined;\n }\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n */\nexport const sessionStorageConfigProvider =\n new Lazy<IConfigProviderBase>(() => inMemoryConfigProvider(safeSessionStorage()));\n\nconst NullConfigProvider: IConfigProviderBase = {\n getRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider =\n (storage: Storage | undefined): IConfigProviderBase => {\n if (storage !== undefined && storage !== null) {\n return new CachedConfigProvider({\n getRawConfig: (name: string) => {\n try {\n return stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n } catch { }\n return undefined;\n },\n });\n }\n return NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n number: number;\n string: string;\n boolean: boolean;\n [\"number[]\"]: number[];\n [\"string[]\"]: string[];\n [\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n switch (type) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n return true;\n default:\n return false;\n }\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n raw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n let output: ConfigTypes = input;\n let defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n // we do special handling for strings to try and coerce\n // them into a config type if we can. This makes it easy\n // for config sources like sessionStorage which only\n // holds strings\n if (typeof input === \"string\") {\n try {\n output = JSON.parse(input);\n // we succeeded in parsing, but we don't support parsing\n // for any object as we can't do it type safely\n // so in this case, the default return will be string\n // rather than undefined, and the consumer\n // can parse, as we don't want to provide\n // a false sense of security by just\n // casting.\n defaultReturn = { raw: input, string: input };\n } catch { }\n }\n\n if (output === undefined) {\n return defaultReturn;\n }\n\n const outputType = typeof output;\n if (isPrimitiveType(outputType)) {\n return { ...defaultReturn, raw: input, [outputType]: output };\n }\n\n if (Array.isArray(output)) {\n const firstType = typeof output[0];\n // ensure the first elements is a primitive type\n if (!isPrimitiveType(firstType)) {\n return defaultReturn;\n }\n // ensue all the elements types are homogeneous\n // aka they all have the same type as the first\n for (const v of output) {\n if (typeof v !== firstType) {\n return defaultReturn;\n }\n }\n return { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n }\n\n return defaultReturn;\n}\n\n/** `sessionStorage` is undefined in some environments such as Node */\nconst safeSessionStorage = (): Storage | undefined => {\n return globalThis.sessionStorage;\n};\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n private readonly configCache = new Map<string, StronglyTypedValue>();\n private readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n constructor(\n ... orderedBaseProviders: (IConfigProviderBase | undefined)[]\n ) {\n this.orderedBaseProviders = [];\n const knownProviders = new Set<IConfigProviderBase>();\n const candidateProviders = [...orderedBaseProviders];\n while (candidateProviders.length > 0) {\n const baseProvider = candidateProviders.shift()!;\n if (baseProvider !== undefined\n && isConfigProviderBase(baseProvider)\n && !knownProviders.has(baseProvider)\n ) {\n knownProviders.add(baseProvider);\n if (baseProvider instanceof CachedConfigProvider) {\n candidateProviders.push(...baseProvider.orderedBaseProviders);\n } else {\n this.orderedBaseProviders.push(baseProvider);\n }\n }\n }\n }\n getBoolean(name: string): boolean | undefined {\n return this.getCacheEntry(name)?.boolean;\n }\n getNumber(name: string): number | undefined {\n return this.getCacheEntry(name)?.number;\n }\n getString(name: string): string | undefined {\n return this.getCacheEntry(name)?.string;\n }\n getBooleanArray(name: string): boolean[] | undefined {\n return this.getCacheEntry(name)?.[\"boolean[]\"];\n }\n getNumberArray(name: string): number[] | undefined {\n return this.getCacheEntry(name)?.[\"number[]\"];\n }\n getStringArray(name: string): string[] | undefined {\n return this.getCacheEntry(name)?.[\"string[]\"];\n }\n\n getRawConfig(name: string): ConfigTypes {\n return this.getCacheEntry(name)?.raw;\n }\n\n private getCacheEntry(name: string): StronglyTypedValue | undefined {\n if (!this.configCache.has(name)) {\n for (const provider of this.orderedBaseProviders) {\n const parsed = stronglyTypedParse(provider?.getRawConfig(name));\n if (parsed !== undefined) {\n this.configCache.set(name, parsed);\n return parsed;\n }\n }\n // configs are immutable, if the first lookup returned no results, all lookups should\n this.configCache.set(name, { raw: undefined });\n }\n return this.configCache.get(name);\n }\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider\n */\nexport interface MonitoringContext<\n L extends ITelemetryBaseLogger = ITelemetryLogger,\n> {\n config: IConfigProvider;\n logger: L;\n}\n\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLogger>(\n obj: L): obj is L & MonitoringContext<L> {\n const maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n return isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLogger>(\n logger: L): MonitoringContext<L> {\n if (loggerIsMonitoringContext<L>(logger)) {\n return logger;\n }\n return mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLogger>(\n logger: L, ... configs: (IConfigProviderBase | undefined)[]) {\n if (loggerIsMonitoringContext<L>(logger)) {\n throw new Error(\"Logger is already a monitoring context\");\n }\n /**\n * this is the tricky bit we use for now to smuggle monitoring context around.\n * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n * of the MonitoringContext and get the config provider.\n */\n const mc: L & Partial<MonitoringContext<L>> = logger;\n mc.config = new CachedConfigProvider(...configs);\n mc.logger = logger;\n return mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n const maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n return typeof (maybeConfig?.getRawConfig) === \"function\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAKA,+DAAoD;AAsBpD;;;;GAIG;AACU,QAAA,4BAA4B,GAAG,IAAI,mBAAI,CAAsB,GAAG,EAAE,CAC9E,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,E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oB,CAAC,GAAG,OAAO,CAAC,CAAC;IACjD,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;IACnB,OAAO,EAA0B,CAAC;AACnC,CAAC;AAnBD,wDAmBC;AAED,SAAS,oBAAoB,CAAC,GAAY;IACzC,MAAM,WAAW,GAAG,GAA+C,CAAC;IACpE,OAAO,OAAO,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,YAAY,CAAA,KAAK,UAAU,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { Lazy } from \"@fluidframework/common-utils\";\n\nexport type ConfigTypes = string | number | boolean | number[] | string[] | boolean[] | undefined;\n\n/**\n * Base interface for providing configurations to enable/disable/control features\n */\nexport interface IConfigProviderBase {\n\tgetRawConfig(name: string): ConfigTypes;\n}\n\n/**\n * Explicitly typed interface for reading configurations\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider({\n\t\t\tgetRawConfig: (name: string) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {}\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input);\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/** `sessionStorage` is undefined in some environments such as Node */\nconst safeSessionStorage = (): Storage | undefined => {\n\treturn globalThis.sessionStorage;\n};\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tconstructor(...orderedBaseProviders: (IConfigProviderBase | undefined)[]) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tgetBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tgetNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tgetString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tgetBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tgetNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tgetStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tgetRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLogger> {\n\tconfig: IConfigProvider;\n\tlogger: L;\n}\n\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLogger>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLogger>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLogger>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n) {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(...configs);\n\tmc.logger = logger;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugLogger.d.ts","sourceRoot":"","sources":["../src/debugLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"debugLogger.d.ts","sourceRoot":"","sources":["../src/debugLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,mBAAmB,EACnB,oBAAoB,EAEpB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAA0B,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EACN,eAAe,EAGf,4BAA4B,EAC5B,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,WAAY,SAAQ,eAAe;IAuD9C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAvD1B;;;;;OAKG;WACW,MAAM,CACnB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,4BAA4B,GACvC,eAAe;IAWlB;;;;;;;OAOG;WACW,gBAAgB,CAC7B,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,oBAAoB,EACjC,UAAU,CAAC,EAAE,4BAA4B,GACvC,eAAe;IAclB,OAAO,CAAC,MAAM,CAAC,qBAAqB;gBAQlB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,SAAS,EACpC,UAAU,CAAC,EAAE,4BAA4B;IAK1C;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CA2C7C"}
|
package/dist/debugLogger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugLogger.js","sourceRoot":"","sources":["../src/debugLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,+DAA2D;AAC3D,iCAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"debugLogger.js","sourceRoot":"","sources":["../src/debugLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,+DAA2D;AAC3D,iCAA0D;AAC1D,qCAKkB;AAElB;;GAEG;AACH,MAAa,WAAY,SAAQ,wBAAe;IAsD/C,YACkB,KAAgB,EAChB,QAAmB,EACpC,UAAyC;QAEzC,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAJZ,UAAK,GAAL,KAAK,CAAW;QAChB,aAAQ,GAAR,QAAQ,CAAW;IAIrC,CAAC;IA3DD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CACnB,SAAiB,EACjB,UAAyC;QAEzC,uEAAuE;QACvE,MAAM,KAAK,GAAG,IAAA,aAAa,EAAC,SAAS,CAAC,CAAC;QAEvC,MAAM,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;AA9GD,kCA8GC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryProperties,\n} from \"@fluidframework/common-definitions\";\nimport { performance } from \"@fluidframework/common-utils\";\nimport { debug as registerDebug, IDebugger } from \"debug\";\nimport {\n\tTelemetryLogger,\n\tMultiSinkLogger,\n\tChildLogger,\n\tITelemetryLoggerPropertyBags,\n} from \"./logger\";\n\n/**\n * Implementation of debug logger\n */\nexport class DebugLogger extends TelemetryLogger {\n\t/**\n\t * Create debug logger - all events are output to debug npm library\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param propertyGetters - Getters to add additional properties to all events\n\t */\n\tpublic static create(\n\t\tnamespace: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// Setup base logger upfront, such that host can disable it (if needed)\n\t\tconst debug = registerDebug(namespace);\n\n\t\tconst debugErr = registerDebug(namespace);\n\t\tdebugErr.log = console.error.bind(console);\n\t\tdebugErr.enabled = true;\n\n\t\treturn new DebugLogger(debug, debugErr, properties);\n\t}\n\n\t/**\n\t * Mix in debug logger with another logger.\n\t * Returned logger will output events to both newly created debug logger, as well as base logger\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param propertyGetters - Getters to add additional properties to all events\n\t * @param baseLogger - Base logger to output events (in addition to debug logger being created). Can be undefined.\n\t */\n\tpublic static mixinDebugLogger(\n\t\tnamespace: string,\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\tif (!baseLogger) {\n\t\t\treturn DebugLogger.create(namespace, properties);\n\t\t}\n\n\t\tconst multiSinkLogger = new MultiSinkLogger(undefined, properties);\n\t\tmultiSinkLogger.addLogger(\n\t\t\tDebugLogger.create(namespace, this.tryGetBaseLoggerProps(baseLogger)),\n\t\t);\n\t\tmultiSinkLogger.addLogger(ChildLogger.create(baseLogger, namespace));\n\n\t\treturn multiSinkLogger;\n\t}\n\n\tprivate static tryGetBaseLoggerProps(baseLogger?: ITelemetryBaseLogger) {\n\t\tif (baseLogger instanceof TelemetryLogger) {\n\t\t\treturn (baseLogger as any as { properties: ITelemetryLoggerPropertyBags }).properties;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconstructor(\n\t\tprivate readonly debug: IDebugger,\n\t\tprivate readonly debugErr: IDebugger,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t) {\n\t\tsuper(undefined, properties);\n\t}\n\n\t/**\n\t * Send an event to debug loggers\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tconst newEvent: ITelemetryProperties = this.prepareEvent(event);\n\t\tconst isError = newEvent.category === \"error\";\n\t\tlet logger = isError ? this.debugErr : this.debug;\n\n\t\t// Use debug's coloring schema for base of the event\n\t\tconst index = event.eventName.lastIndexOf(TelemetryLogger.eventNamespaceSeparator);\n\t\tconst name = event.eventName.substring(index + 1);\n\t\tif (index > 0) {\n\t\t\tlogger = logger.extend(event.eventName.substring(0, index));\n\t\t}\n\t\tnewEvent.eventName = undefined;\n\n\t\tlet tick = \"\";\n\t\ttick = `tick=${TelemetryLogger.formatTick(performance.now())}`;\n\n\t\t// Extract stack to put it last, but also to avoid escaping '\\n' in it by JSON.stringify below\n\t\tconst stack = newEvent.stack ? newEvent.stack : \"\";\n\t\tnewEvent.stack = undefined;\n\n\t\t// Watch out for circular references - they can come from two sources\n\t\t// 1) error object - we do not control it and should remove it and retry\n\t\t// 2) properties supplied by telemetry caller - that's a bug that should be addressed!\n\t\tlet payload: string;\n\t\ttry {\n\t\t\tpayload = JSON.stringify(newEvent);\n\t\t} catch (error) {\n\t\t\tnewEvent.error = undefined;\n\t\t\tpayload = JSON.stringify(newEvent);\n\t\t}\n\n\t\tif (payload === \"{}\") {\n\t\t\tpayload = \"\";\n\t\t}\n\n\t\t// Force errors out, to help with diagnostics\n\t\tif (isError) {\n\t\t\tlogger.enabled = true;\n\t\t}\n\n\t\t// Print multi-line.\n\t\tlogger(`${name} ${payload} ${tick} ${stack}`);\n\t}\n}\n"]}
|
package/dist/errorLogging.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare function isTaggedTelemetryPropertyValue(x: ITaggedTelemetryProper
|
|
|
62
62
|
* Avoids runtime errors with circular references.
|
|
63
63
|
* Not ideal, as will cut values that are not necessarily circular references.
|
|
64
64
|
* Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)
|
|
65
|
-
*/
|
|
65
|
+
*/
|
|
66
66
|
export declare const getCircularReplacer: () => (key: string, value: any) => any;
|
|
67
67
|
/**
|
|
68
68
|
* Base class for "trusted" errors we create, whose properties can generally be logged to telemetry safely.
|
|
@@ -86,10 +86,10 @@ export declare class LoggingError extends Error implements ILoggingError, Omit<I
|
|
|
86
86
|
*/
|
|
87
87
|
constructor(message: string, props?: ITelemetryProperties, omitPropsFromLogging?: Set<string>);
|
|
88
88
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
* Determines if a given object is an instance of a LoggingError
|
|
90
|
+
* @param object - any object
|
|
91
|
+
* @returns - true if the object is an instance of a LoggingError, false if not.
|
|
92
|
+
*/
|
|
93
93
|
static typeCheck(object: unknown): object is LoggingError;
|
|
94
94
|
/**
|
|
95
95
|
* Add additional properties to be logged
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorLogging.d.ts","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"errorLogging.d.ts","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EACb,4BAA4B,EAC5B,gBAAgB,E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AElB,MAAM,SAAS,GAAG,KAAG,GASlC,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,YACZ,SAAQ,KACR,YAAW,aAAa,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC;IAuB3D,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IArBtC,OAAO,CAAC,gBAAgB,CAAU;IAClC,IAAI,eAAe,WAElB;IACD,wBAAwB,CAAC,EAAE,EAAE,MAAM;IAInC,2FAA2F;IAE3F,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAY;IAE3C;;;;;OAKG;gBAEF,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,oBAAoB,EACX,oBAAoB,GAAE,GAAG,CAAC,MAAM,CAAa;IAa/D;;;;OAIG;WACW,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,YAAY;IAWhE;;OAEG;IACI,sBAAsB,CAAC,KAAK,EAAE,oBAAoB;IAIzD;;OAEG;IACI,sBAAsB,IAAI,oBAAoB;CAUrD;AAED,8DAA8D;AAC9D,eAAO,MAAM,qBAAqB,iBAAiB,CAAC"}
|
package/dist/errorLogging.js
CHANGED
|
@@ -24,9 +24,7 @@ function extractLogSafeErrorProperties(error, sanitizeStack) {
|
|
|
24
24
|
}
|
|
25
25
|
return stackFrames.join("\n");
|
|
26
26
|
};
|
|
27
|
-
const message =
|
|
28
|
-
? error.message
|
|
29
|
-
: String(error);
|
|
27
|
+
const message = typeof (error === null || error === void 0 ? void 0 : error.message) === "string" ? error.message : String(error);
|
|
30
28
|
const safeProps = {
|
|
31
29
|
message,
|
|
32
30
|
};
|
|
@@ -36,7 +34,7 @@ function extractLogSafeErrorProperties(error, sanitizeStack) {
|
|
|
36
34
|
safeProps.errorType = errorType;
|
|
37
35
|
}
|
|
38
36
|
if (typeof stack === "string") {
|
|
39
|
-
const errorName =
|
|
37
|
+
const errorName = typeof name === "string" ? name : undefined;
|
|
40
38
|
safeProps.stack = removeMessageFromStack(stack, errorName);
|
|
41
39
|
}
|
|
42
40
|
}
|
|
@@ -91,9 +89,9 @@ function normalizeError(error, annotations = {}) {
|
|
|
91
89
|
const { canRetry, retryAfterSeconds } = error;
|
|
92
90
|
Object.assign(normalizeError, { canRetry, retryAfterSeconds });
|
|
93
91
|
}
|
|
94
|
-
if (typeof
|
|
92
|
+
if (typeof error !== "object") {
|
|
95
93
|
// This is only interesting for non-objects
|
|
96
|
-
fluidError.addTelemetryProperties({ typeofError: typeof
|
|
94
|
+
fluidError.addTelemetryProperties({ typeofError: typeof error });
|
|
97
95
|
}
|
|
98
96
|
const errorTelemetryProps = LoggingError.typeCheck(error)
|
|
99
97
|
? error.getTelemetryProperties()
|
|
@@ -115,7 +113,7 @@ let stackPopulatedOnCreation;
|
|
|
115
113
|
function generateErrorWithStack() {
|
|
116
114
|
const err = new Error("<<generated stack>>");
|
|
117
115
|
if (stackPopulatedOnCreation === undefined) {
|
|
118
|
-
stackPopulatedOnCreation =
|
|
116
|
+
stackPopulatedOnCreation = err.stack !== undefined;
|
|
119
117
|
}
|
|
120
118
|
if (stackPopulatedOnCreation) {
|
|
121
119
|
return err;
|
|
@@ -140,7 +138,7 @@ exports.generateStack = generateStack;
|
|
|
140
138
|
* @returns A new error object "wrapping" the given error
|
|
141
139
|
*/
|
|
142
140
|
function wrapError(innerError, newErrorFn) {
|
|
143
|
-
const { message, stack
|
|
141
|
+
const { message, stack } = extractLogSafeErrorProperties(innerError, false /* sanitizeStack */);
|
|
144
142
|
const newError = newErrorFn(message);
|
|
145
143
|
if (stack !== undefined) {
|
|
146
144
|
overwriteStack(newError, stack);
|
|
@@ -271,7 +269,7 @@ function getValidTelemetryProps(obj, keysToOmit) {
|
|
|
271
269
|
* Avoids runtime errors with circular references.
|
|
272
270
|
* Not ideal, as will cut values that are not necessarily circular references.
|
|
273
271
|
* Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)
|
|
274
|
-
*/
|
|
272
|
+
*/
|
|
275
273
|
const getCircularReplacer = () => {
|
|
276
274
|
const seen = new WeakSet();
|
|
277
275
|
return (key, value) => {
|
|
@@ -313,18 +311,22 @@ class LoggingError extends Error {
|
|
|
313
311
|
this.addTelemetryProperties(props);
|
|
314
312
|
}
|
|
315
313
|
}
|
|
316
|
-
get errorInstanceId() {
|
|
317
|
-
|
|
314
|
+
get errorInstanceId() {
|
|
315
|
+
return this._errorInstanceId;
|
|
316
|
+
}
|
|
317
|
+
overwriteErrorInstanceId(id) {
|
|
318
|
+
this._errorInstanceId = id;
|
|
319
|
+
}
|
|
318
320
|
/**
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
* Determines if a given object is an instance of a LoggingError
|
|
322
|
+
* @param object - any object
|
|
323
|
+
* @returns - true if the object is an instance of a LoggingError, false if not.
|
|
324
|
+
*/
|
|
323
325
|
static typeCheck(object) {
|
|
324
326
|
if (typeof object === "object" && object !== null) {
|
|
325
|
-
return typeof object.addTelemetryProperties === "function"
|
|
326
|
-
|
|
327
|
-
|
|
327
|
+
return (typeof object.addTelemetryProperties === "function" &&
|
|
328
|
+
typeof object.getTelemetryProperties === "function" &&
|
|
329
|
+
typeof object.errorInstanceId === "string");
|
|
328
330
|
}
|
|
329
331
|
return false;
|
|
330
332
|
}
|
package/dist/errorLogging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorLogging.js","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,+BAAkC;AAClC,qDAK0B;AAG1B,wEAAwE;AACxE,MAAM,eAAe,GAAG,CAAC,KAAU,EAAW,EAAE;IAC5C,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAChF,CAAC,CAAC;AAEF,sEAAsE;AACtE,SAAgB,6BAA6B,CAAC,KAAU,EAAE,aAAsB;IAC5E,MAAM,sBAAsB,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,CAAC;IAED;;OAEG;IACI,sBAAsB;QACzB,MAAM,aAAa,GAAG,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC9E,+EAA+E;QAC/E,uCACO,aAAa,KAChB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,eAAe,EAAE,IAAI,CAAC,gBAAgB,IACxC;IACN,CAAC;CACJ;AAjED,oCAiEC;AAED,8DAA8D;AACjD,QAAA,qBAAqB,GAAG,cAAc,CAAC;AACpD,MAAM,sBAAuB,SAAQ,YAAY;IAK7C,YACI,UAGC;QAED,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAV9B,2EAA2E;QAC3E,2EAA2E;QAC3E,cAAS,GAAG,6BAAqB,CAAC;QAU9B,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YAChC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;SAC1C;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ILoggingError,\n ITaggedTelemetryPropertyType,\n ITelemetryLogger,\n ITelemetryProperties,\n TelemetryEventPropertyType,\n} from \"@fluidframework/common-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n hasErrorInstanceId,\n IFluidErrorBase,\n isFluidError,\n isValidLegacyError,\n} from \"./fluidErrorBase\";\nimport { ITaggedTelemetryPropertyTypeExt, TelemetryEventPropertyTypeExt } from \"./telemetryTypes\";\n\n/** @returns true if value is an object but neither null nor an array */\nconst isRegularObject = (value: any): boolean => {\n return value !== null && !Array.isArray(value) && typeof value === \"object\";\n};\n\n/** Inspect the given error for common \"safe\" props and return them */\nexport function extractLogSafeErrorProperties(error: any, sanitizeStack: boolean) {\n const removeMessageFromStack = (stack: string, errorName?: string) => {\n if (!sanitizeStack) {\n return stack;\n }\n const stackFrames = stack.split(\"\\n\");\n stackFrames.shift(); // Remove \"[ErrorName]: [ErrorMessage]\"\n if (errorName !== undefined) {\n stackFrames.unshift(errorName); // Add \"[ErrorName]\"\n }\n return stackFrames.join(\"\\n\");\n };\n\n const message = (typeof error?.message === \"string\")\n ? error.message as string\n : String(error);\n\n const safeProps: { message: string; errorType?: string; stack?: string; } = {\n message,\n };\n\n if (isRegularObject(error)) {\n const { errorType, stack, name } = error;\n\n if (typeof errorType === \"string\") {\n safeProps.errorType = errorType;\n }\n\n if (typeof stack === \"string\") {\n const errorName = (typeof name === \"string\") ? name : undefined;\n safeProps.stack = removeMessageFromStack(stack, errorName);\n }\n }\n\n return safeProps;\n}\n\n/** type guard for ILoggingError interface */\nexport const isILoggingError = (x: any): x is ILoggingError => typeof x?.getTelemetryProperties === \"function\";\n\n/** Copy props from source onto target, but do not overwrite an existing prop that matches */\nfunction copyProps(target: ITelemetryProperties | LoggingError, source: ITelemetryProperties) {\n for (const key of Object.keys(source)) {\n if (target[key] === undefined) {\n target[key] = source[key];\n }\n }\n}\n\n/** Metadata to annotate an error object when annotating or normalizing it */\nexport interface IFluidErrorAnnotations {\n /** Telemetry props to log with the error */\n props?: ITelemetryProperties;\n}\n\n/** For backwards compatibility with pre-errorInstanceId valid errors */\nfunction patchLegacyError(\n legacyError: Omit<IFluidErrorBase, \"errorInstanceId\">,\n): asserts legacyError is IFluidErrorBase {\n const patchMe: { -readonly [P in \"errorInstanceId\"]?: IFluidErrorBase[P] } = legacyError as any;\n if (patchMe.errorInstanceId === undefined) {\n patchMe.errorInstanceId = uuid();\n }\n}\n\n/**\n * Normalize the given error yielding a valid Fluid Error\n * @returns A valid Fluid Error with any provided annotations applied\n * @param error - The error to normalize\n * @param annotations - Annotations to apply to the normalized error\n */\nexport function normalizeError(\n error: unknown,\n annotations: IFluidErrorAnnotations = {},\n): IFluidErrorBase {\n // Back-compat, while IFluidErrorBase is rolled out\n if (isValidLegacyError(error)) {\n patchLegacyError(error);\n }\n\n if (isFluidError(error)) {\n // We can simply add the telemetry props to the error and return it\n error.addTelemetryProperties(annotations.props ?? {});\n return error;\n }\n\n // We have to construct a new Fluid Error, copying safe properties over\n const { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);\n const fluidError: IFluidErrorBase = new NormalizedLoggingError({\n message,\n stack,\n });\n\n // We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)\n // Anywhere they are set should be on a valid Fluid Error that would have been returned above,\n // but we can't prove it with the types, so adding this defensive measure.\n if (typeof error === \"object\" && error !== null) {\n const { canRetry, retryAfterSeconds } = error as any;\n Object.assign(normalizeError, { canRetry, retryAfterSeconds });\n }\n\n if (typeof (error) !== \"object\") {\n // This is only interesting for non-objects\n fluidError.addTelemetryProperties({ typeofError: typeof (error) });\n }\n\n const errorTelemetryProps = LoggingError.typeCheck(error)\n ? error.getTelemetryProperties()\n : { untrustedOrigin: 1 }; // This will let us filter errors that did not originate from our own codebase\n\n fluidError.addTelemetryProperties({\n ...errorTelemetryProps,\n ...annotations.props,\n });\n\n return fluidError;\n}\n\nlet stackPopulatedOnCreation: boolean | undefined;\n\n/**\n * The purpose of this function is to provide ability to capture stack context quickly.\n * Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.\n * There are scenarios where we generate error with stack, but error is handled in most cases and\n * stack property is not accessed.\n * For such cases it's better to not read stack property right away, but rather delay it until / if it's needed\n * Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.\n * @returns Error object that has stack populated.\n */\nexport function generateErrorWithStack(): Error {\n const err = new Error(\"<<generated stack>>\");\n\n if (stackPopulatedOnCreation === undefined) {\n stackPopulatedOnCreation = (err.stack !== undefined);\n }\n\n if (stackPopulatedOnCreation) {\n return err;\n }\n\n try {\n throw err;\n } catch (e) {\n return e as Error;\n }\n}\n\nexport function generateStack(): string | undefined {\n return generateErrorWithStack().stack;\n}\n\n/**\n * Create a new error using newErrorFn, wrapping and caused by the given unknown error.\n * Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present\n * @param innerError - An error from untrusted/unknown origins\n * @param newErrorFn - callback that will create a new error given the original error's message\n * @returns A new error object \"wrapping\" the given error\n */\nexport function wrapError<T extends LoggingError>(\n innerError: unknown,\n newErrorFn: (message: string) => T,\n): T {\n const {\n message,\n stack,\n } = extractLogSafeErrorProperties(innerError, false /* sanitizeStack */);\n\n const newError = newErrorFn(message);\n\n if (stack !== undefined) {\n overwriteStack(newError, stack);\n }\n\n // Mark external errors with untrustedOrigin flag\n if (isExternalError(innerError)) {\n newError.addTelemetryProperties({ untrustedOrigin: 1 });\n }\n\n // Reuse errorInstanceId\n if (hasErrorInstanceId(innerError)) {\n newError.overwriteErrorInstanceId(innerError.errorInstanceId);\n\n // For \"back-compat\" in the logs\n newError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\n }\n\n // Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties\n // This will include the untrustedOrigin property if the inner error itself was created from an external error\n if (isILoggingError(innerError)) {\n newError.addTelemetryProperties(innerError.getTelemetryProperties());\n }\n\n return newError;\n}\n\n/** The same as wrapError, but also logs the innerError, including the wrapping error's instance id */\nexport function wrapErrorAndLog<T extends LoggingError>(\n innerError: unknown,\n newErrorFn: (message: string) => T,\n logger: ITelemetryLogger,\n) {\n const newError = wrapError(innerError, newErrorFn);\n\n // This will match innerError.errorInstanceId if present (see wrapError)\n const errorInstanceId = newError.errorInstanceId;\n\n // For \"back-compat\" in the logs\n const wrappedByErrorInstanceId = errorInstanceId;\n\n logger.sendTelemetryEvent({\n eventName: \"WrapError\",\n errorInstanceId,\n wrappedByErrorInstanceId,\n }, innerError);\n\n return newError;\n}\n\nfunction overwriteStack(error: IFluidErrorBase | LoggingError, stack: string) {\n // supposedly setting stack on an Error can throw.\n try {\n Object.assign(error, { stack });\n } catch (errorSettingStack) {\n error.addTelemetryProperties({ stack2: stack });\n }\n}\n\n/**\n * True for any error object that is an (optionally normalized) external error\n * False for any error we created and raised within the FF codebase via LoggingError base class,\n * or wrapped in a well-known error type\n */\nexport function isExternalError(e: any): boolean {\n // LoggingErrors are an internal FF error type. However, an external error can be converted\n // into a LoggingError if it is normalized. In this case we must use the untrustedOrigin flag to\n // determine whether the original error was infact external.\n if (LoggingError.typeCheck(e)) {\n if ((e as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {\n return e.getTelemetryProperties().untrustedOrigin === 1;\n }\n return false;\n }\n return !isValidLegacyError(e);\n}\n\n/**\n * Type guard to identify if a particular telemetry property appears to be a tagged telemetry property\n */\nexport function isTaggedTelemetryPropertyValue(\n x: ITaggedTelemetryPropertyTypeExt | TelemetryEventPropertyTypeExt,\n): x is ITaggedTelemetryPropertyType | ITaggedTelemetryPropertyTypeExt {\n return typeof ((x as any)?.tag) === \"string\";\n}\n\n/**\n * Filter serializable telemetry properties\n * @param x - any telemetry prop\n * @returns - as-is if x is primitive. returns stringified if x is an array of primitive.\n * otherwise returns null since this is what we support at the moment.\n */\nfunction filterValidTelemetryProps(x: any, key: string): TelemetryEventPropertyType {\n if (Array.isArray(x) && x.every((val) => isTelemetryEventPropertyValue(val))) {\n return JSON.stringify(x);\n }\n if (isTelemetryEventPropertyValue(x)) {\n return x;\n }\n // We don't support logging arbitrary objects\n console.error(`UnSupported Format of Logging Error Property for key ${key}:`, x);\n return \"REDACTED (arbitrary object)\";\n}\n\n// checking type of x, returns false if x is null\nfunction isTelemetryEventPropertyValue(x: any): x is TelemetryEventPropertyType {\n switch (typeof x) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"undefined\":\n return true;\n default:\n return false;\n }\n}\n/**\n * Walk an object's enumerable properties to find those fit for telemetry.\n */\nfunction getValidTelemetryProps(obj: any, keysToOmit: Set<string>): ITelemetryProperties {\n const props: ITelemetryProperties = {};\n for (const key of Object.keys(obj)) {\n if (keysToOmit.has(key)) {\n continue;\n }\n const val = obj[key];\n\n // ensure only valid props get logged, since props of logging error could be in any shape\n if (isTaggedTelemetryPropertyValue(val)) {\n props[key] = {\n value: filterValidTelemetryProps(val.value, key),\n tag: val.tag,\n };\n } else {\n props[key] = filterValidTelemetryProps(val, key);\n }\n }\n return props;\n}\n\n/**\n * Borrowed from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}\n * Avoids runtime errors with circular references.\n * Not ideal, as will cut values that are not necessarily circular references.\n * Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)\n*/\nexport const getCircularReplacer = () => {\n const seen = new WeakSet();\n return (key: string, value: any): any => {\n if (typeof value === \"object\" && value !== null) {\n if (seen.has(value)) {\n return \"<removed/circular>\";\n }\n seen.add(value);\n }\n return value;\n };\n};\n\n/**\n * Base class for \"trusted\" errors we create, whose properties can generally be logged to telemetry safely.\n * All properties set on the object, or passed in (via the constructor or addTelemetryProperties),\n * will be logged in accordance with their tag, if present.\n *\n * PLEASE take care to avoid setting sensitive data on this object without proper tagging!\n */\nexport class LoggingError extends Error implements ILoggingError, Omit<IFluidErrorBase, \"errorType\"> {\n private _errorInstanceId = uuid();\n get errorInstanceId() { return this._errorInstanceId; }\n overwriteErrorInstanceId(id: string) { this._errorInstanceId = id; }\n\n /** Back-compat to appease isFluidError typeguard in old code that may handle this error */\n // @ts-expect-error - This field shouldn't be referenced in the current version, but needs to exist at runtime.\n private readonly fluidErrorCode: \"-\" = \"-\";\n\n /**\n * Create a new LoggingError\n * @param message - Error message to use for Error base class\n * @param props - telemetry props to include on the error for when it's logged\n * @param omitPropsFromLogging - properties by name to omit from telemetry props\n */\n constructor(\n message: string,\n props?: ITelemetryProperties,\n private readonly omitPropsFromLogging: Set<string> = new Set(),\n ) {\n super(message);\n\n // Don't log this list itself, or the private _errorInstanceId\n omitPropsFromLogging.add(\"omitPropsFromLogging\");\n omitPropsFromLogging.add(\"_errorInstanceId\");\n\n if (props) {\n this.addTelemetryProperties(props);\n }\n }\n\n /**\n * Determines if a given object is an instance of a LoggingError\n * @param object - any object\n * @returns - true if the object is an instance of a LoggingError, false if not.\n */\n public static typeCheck(object: unknown): object is LoggingError {\n if (typeof object === \"object\" && object !== null) {\n return typeof (object as LoggingError).addTelemetryProperties === \"function\"\n && typeof (object as LoggingError).getTelemetryProperties === \"function\"\n && typeof (object as LoggingError).errorInstanceId === \"string\";\n }\n return false;\n }\n\n /**\n * Add additional properties to be logged\n */\n public addTelemetryProperties(props: ITelemetryProperties) {\n copyProps(this, props);\n }\n\n /**\n * Get all properties fit to be logged to telemetry for this error\n */\n public getTelemetryProperties(): ITelemetryProperties {\n const taggableProps = getValidTelemetryProps(this, this.omitPropsFromLogging);\n // Include non-enumerable props that are not returned by getValidTelemetryProps\n return {\n ...taggableProps,\n stack: this.stack,\n message: this.message,\n errorInstanceId: this._errorInstanceId,\n };\n }\n}\n\n/** The Error class used when normalizing an external error */\nexport const NORMALIZED_ERROR_TYPE = \"genericError\";\nclass NormalizedLoggingError extends LoggingError {\n // errorType \"genericError\" is used as a default value throughout the code.\n // Note that this matches ContainerErrorType/DriverErrorType's genericError\n errorType = NORMALIZED_ERROR_TYPE;\n\n constructor(\n errorProps: Pick<IFluidErrorBase,\n | \"message\"\n | \"stack\"\n >,\n ) {\n super(errorProps.message);\n\n if (errorProps.stack !== undefined) {\n overwriteStack(this, errorProps.stack);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errorLogging.js","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,+BAAkC;AAClC,qDAK0B;AAG1B,wEAAwE;AACxE,MAAM,eAAe,GAAG,CAAC,KAAU,EAAW,EAAE;IAC/C,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC7E,CAAC,CAAC;AAEF,sEAAsE;AACtE,SAAgB,6BAA6B,CAAC,KAAU,EAAE,aAAsB;IAC/E,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,SAAk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,CAAC,oBAAoB,CAAC,CAAC;QAC9E,+EAA+E;QAC/E,uCACI,aAAa,KAChB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,eAAe,EAAE,IAAI,CAAC,gBAAgB,IACrC;IACH,CAAC;CACD;AA1ED,oCA0EC;AAED,8DAA8D;AACjD,QAAA,qBAAqB,GAAG,cAAc,CAAC;AACpD,MAAM,sBAAuB,SAAQ,YAAY;IAKhD,YAAY,UAAsD;QACjE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAL3B,2EAA2E;QAC3E,2EAA2E;QAC3E,cAAS,GAAG,6BAAqB,CAAC;QAKjC,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YACnC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;SACvC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tILoggingError,\n\tITaggedTelemetryPropertyType,\n\tITelemetryLogger,\n\tITelemetryProperties,\n\tTelemetryEventPropertyType,\n} from \"@fluidframework/common-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nimport { ITaggedTelemetryPropertyTypeExt, TelemetryEventPropertyTypeExt } from \"./telemetryTypes\";\n\n/** @returns true if value is an object but neither null nor an array */\nconst isRegularObject = (value: any): boolean => {\n\treturn value !== null && !Array.isArray(value) && typeof value === \"object\";\n};\n\n/** Inspect the given error for common \"safe\" props and return them */\nexport function extractLogSafeErrorProperties(error: any, sanitizeStack: boolean) {\n\tconst removeMessageFromStack = (stack: string, errorName?: string) => {\n\t\tif (!sanitizeStack) {\n\t\t\treturn stack;\n\t\t}\n\t\tconst stackFrames = stack.split(\"\\n\");\n\t\tstackFrames.shift(); // Remove \"[ErrorName]: [ErrorMessage]\"\n\t\tif (errorName !== undefined) {\n\t\t\tstackFrames.unshift(errorName); // Add \"[ErrorName]\"\n\t\t}\n\t\treturn stackFrames.join(\"\\n\");\n\t};\n\n\tconst message = typeof error?.message === \"string\" ? (error.message as string) : String(error);\n\n\tconst safeProps: { message: string; errorType?: string; stack?: string } = {\n\t\tmessage,\n\t};\n\n\tif (isRegularObject(error)) {\n\t\tconst { errorType, stack, name } = error;\n\n\t\tif (typeof errorType === \"string\") {\n\t\t\tsafeProps.errorType = errorType;\n\t\t}\n\n\t\tif (typeof stack === \"string\") {\n\t\t\tconst errorName = typeof name === \"string\" ? name : undefined;\n\t\t\tsafeProps.stack = removeMessageFromStack(stack, errorName);\n\t\t}\n\t}\n\n\treturn safeProps;\n}\n\n/** type guard for ILoggingError interface */\nexport const isILoggingError = (x: any): x is ILoggingError =>\n\ttypeof x?.getTelemetryProperties === \"function\";\n\n/** Copy props from source onto target, but do not overwrite an existing prop that matches */\nfunction copyProps(target: ITelemetryProperties | LoggingError, source: ITelemetryProperties) {\n\tfor (const key of Object.keys(source)) {\n\t\tif (target[key] === undefined) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n}\n\n/** Metadata to annotate an error object when annotating or normalizing it */\nexport interface IFluidErrorAnnotations {\n\t/** Telemetry props to log with the error */\n\tprops?: ITelemetryProperties;\n}\n\n/** For backwards compatibility with pre-errorInstanceId valid errors */\nfunction patchLegacyError(\n\tlegacyError: Omit<IFluidErrorBase, \"errorInstanceId\">,\n): asserts legacyError is IFluidErrorBase {\n\tconst patchMe: { -readonly [P in \"errorInstanceId\"]?: IFluidErrorBase[P] } = legacyError as any;\n\tif (patchMe.errorInstanceId === undefined) {\n\t\tpatchMe.errorInstanceId = uuid();\n\t}\n}\n\n/**\n * Normalize the given error yielding a valid Fluid Error\n * @returns A valid Fluid Error with any provided annotations applied\n * @param error - The error to normalize\n * @param annotations - Annotations to apply to the normalized error\n */\nexport function normalizeError(\n\terror: unknown,\n\tannotations: IFluidErrorAnnotations = {},\n): IFluidErrorBase {\n\t// Back-compat, while IFluidErrorBase is rolled out\n\tif (isValidLegacyError(error)) {\n\t\tpatchLegacyError(error);\n\t}\n\n\tif (isFluidError(error)) {\n\t\t// We can simply add the telemetry props to the error and return it\n\t\terror.addTelemetryProperties(annotations.props ?? {});\n\t\treturn error;\n\t}\n\n\t// We have to construct a new Fluid Error, copying safe properties over\n\tconst { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);\n\tconst fluidError: IFluidErrorBase = new NormalizedLoggingError({\n\t\tmessage,\n\t\tstack,\n\t});\n\n\t// We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)\n\t// Anywhere they are set should be on a valid Fluid Error that would have been returned above,\n\t// but we can't prove it with the types, so adding this defensive measure.\n\tif (typeof error === \"object\" && error !== null) {\n\t\tconst { canRetry, retryAfterSeconds } = error as any;\n\t\tObject.assign(normalizeError, { canRetry, retryAfterSeconds });\n\t}\n\n\tif (typeof error !== \"object\") {\n\t\t// This is only interesting for non-objects\n\t\tfluidError.addTelemetryProperties({ typeofError: typeof error });\n\t}\n\n\tconst errorTelemetryProps = LoggingError.typeCheck(error)\n\t\t? error.getTelemetryProperties()\n\t\t: { untrustedOrigin: 1 }; // This will let us filter errors that did not originate from our own codebase\n\n\tfluidError.addTelemetryProperties({\n\t\t...errorTelemetryProps,\n\t\t...annotations.props,\n\t});\n\n\treturn fluidError;\n}\n\nlet stackPopulatedOnCreation: boolean | undefined;\n\n/**\n * The purpose of this function is to provide ability to capture stack context quickly.\n * Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.\n * There are scenarios where we generate error with stack, but error is handled in most cases and\n * stack property is not accessed.\n * For such cases it's better to not read stack property right away, but rather delay it until / if it's needed\n * Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.\n * @returns Error object that has stack populated.\n */\nexport function generateErrorWithStack(): Error {\n\tconst err = new Error(\"<<generated stack>>\");\n\n\tif (stackPopulatedOnCreation === undefined) {\n\t\tstackPopulatedOnCreation = err.stack !== undefined;\n\t}\n\n\tif (stackPopulatedOnCreation) {\n\t\treturn err;\n\t}\n\n\ttry {\n\t\tthrow err;\n\t} catch (e) {\n\t\treturn e as Error;\n\t}\n}\n\nexport function generateStack(): string | undefined {\n\treturn generateErrorWithStack().stack;\n}\n\n/**\n * Create a new error using newErrorFn, wrapping and caused by the given unknown error.\n * Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present\n * @param innerError - An error from untrusted/unknown origins\n * @param newErrorFn - callback that will create a new error given the original error's message\n * @returns A new error object \"wrapping\" the given error\n */\nexport function wrapError<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n): T {\n\tconst { message, stack } = extractLogSafeErrorProperties(innerError, false /* sanitizeStack */);\n\n\tconst newError = newErrorFn(message);\n\n\tif (stack !== undefined) {\n\t\toverwriteStack(newError, stack);\n\t}\n\n\t// Mark external errors with untrustedOrigin flag\n\tif (isExternalError(innerError)) {\n\t\tnewError.addTelemetryProperties({ untrustedOrigin: 1 });\n\t}\n\n\t// Reuse errorInstanceId\n\tif (hasErrorInstanceId(innerError)) {\n\t\tnewError.overwriteErrorInstanceId(innerError.errorInstanceId);\n\n\t\t// For \"back-compat\" in the logs\n\t\tnewError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\n\t}\n\n\t// Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties\n\t// This will include the untrustedOrigin property if the inner error itself was created from an external error\n\tif (isILoggingError(innerError)) {\n\t\tnewError.addTelemetryProperties(innerError.getTelemetryProperties());\n\t}\n\n\treturn newError;\n}\n\n/** The same as wrapError, but also logs the innerError, including the wrapping error's instance id */\nexport function wrapErrorAndLog<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n\tlogger: ITelemetryLogger,\n) {\n\tconst newError = wrapError(innerError, newErrorFn);\n\n\t// This will match innerError.errorInstanceId if present (see wrapError)\n\tconst errorInstanceId = newError.errorInstanceId;\n\n\t// For \"back-compat\" in the logs\n\tconst wrappedByErrorInstanceId = errorInstanceId;\n\n\tlogger.sendTelemetryEvent(\n\t\t{\n\t\t\teventName: \"WrapError\",\n\t\t\terrorInstanceId,\n\t\t\twrappedByErrorInstanceId,\n\t\t},\n\t\tinnerError,\n\t);\n\n\treturn newError;\n}\n\nfunction overwriteStack(error: IFluidErrorBase | LoggingError, stack: string) {\n\t// supposedly setting stack on an Error can throw.\n\ttry {\n\t\tObject.assign(error, { stack });\n\t} catch (errorSettingStack) {\n\t\terror.addTelemetryProperties({ stack2: stack });\n\t}\n}\n\n/**\n * True for any error object that is an (optionally normalized) external error\n * False for any error we created and raised within the FF codebase via LoggingError base class,\n * or wrapped in a well-known error type\n */\nexport function isExternalError(e: any): boolean {\n\t// LoggingErrors are an internal FF error type. However, an external error can be converted\n\t// into a LoggingError if it is normalized. In this case we must use the untrustedOrigin flag to\n\t// determine whether the original error was infact external.\n\tif (LoggingError.typeCheck(e)) {\n\t\tif ((e as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {\n\t\t\treturn e.getTelemetryProperties().untrustedOrigin === 1;\n\t\t}\n\t\treturn false;\n\t}\n\treturn !isValidLegacyError(e);\n}\n\n/**\n * Type guard to identify if a particular telemetry property appears to be a tagged telemetry property\n */\nexport function isTaggedTelemetryPropertyValue(\n\tx: ITaggedTelemetryPropertyTypeExt | TelemetryEventPropertyTypeExt,\n): x is ITaggedTelemetryPropertyType | ITaggedTelemetryPropertyTypeExt {\n\treturn typeof (x as any)?.tag === \"string\";\n}\n\n/**\n * Filter serializable telemetry properties\n * @param x - any telemetry prop\n * @returns - as-is if x is primitive. returns stringified if x is an array of primitive.\n * otherwise returns null since this is what we support at the moment.\n */\nfunction filterValidTelemetryProps(x: any, key: string): TelemetryEventPropertyType {\n\tif (Array.isArray(x) && x.every((val) => isTelemetryEventPropertyValue(val))) {\n\t\treturn JSON.stringify(x);\n\t}\n\tif (isTelemetryEventPropertyValue(x)) {\n\t\treturn x;\n\t}\n\t// We don't support logging arbitrary objects\n\tconsole.error(`UnSupported Format of Logging Error Property for key ${key}:`, x);\n\treturn \"REDACTED (arbitrary object)\";\n}\n\n// checking type of x, returns false if x is null\nfunction isTelemetryEventPropertyValue(x: any): x is TelemetryEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n/**\n * Walk an object's enumerable properties to find those fit for telemetry.\n */\nfunction getValidTelemetryProps(obj: any, keysToOmit: Set<string>): ITelemetryProperties {\n\tconst props: ITelemetryProperties = {};\n\tfor (const key of Object.keys(obj)) {\n\t\tif (keysToOmit.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst val = obj[key];\n\n\t\t// ensure only valid props get logged, since props of logging error could be in any shape\n\t\tif (isTaggedTelemetryPropertyValue(val)) {\n\t\t\tprops[key] = {\n\t\t\t\tvalue: filterValidTelemetryProps(val.value, key),\n\t\t\t\ttag: val.tag,\n\t\t\t};\n\t\t} else {\n\t\t\tprops[key] = filterValidTelemetryProps(val, key);\n\t\t}\n\t}\n\treturn props;\n}\n\n/**\n * Borrowed from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}\n * Avoids runtime errors with circular references.\n * Not ideal, as will cut values that are not necessarily circular references.\n * Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)\n */\nexport const getCircularReplacer = () => {\n\tconst seen = new WeakSet();\n\treturn (key: string, value: any): any => {\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\tif (seen.has(value)) {\n\t\t\t\treturn \"<removed/circular>\";\n\t\t\t}\n\t\t\tseen.add(value);\n\t\t}\n\t\treturn value;\n\t};\n};\n\n/**\n * Base class for \"trusted\" errors we create, whose properties can generally be logged to telemetry safely.\n * All properties set on the object, or passed in (via the constructor or addTelemetryProperties),\n * will be logged in accordance with their tag, if present.\n *\n * PLEASE take care to avoid setting sensitive data on this object without proper tagging!\n */\nexport class LoggingError\n\textends Error\n\timplements ILoggingError, Omit<IFluidErrorBase, \"errorType\">\n{\n\tprivate _errorInstanceId = uuid();\n\tget errorInstanceId() {\n\t\treturn this._errorInstanceId;\n\t}\n\toverwriteErrorInstanceId(id: string) {\n\t\tthis._errorInstanceId = id;\n\t}\n\n\t/** Back-compat to appease isFluidError typeguard in old code that may handle this error */\n\t// @ts-expect-error - This field shouldn't be referenced in the current version, but needs to exist at runtime.\n\tprivate readonly fluidErrorCode: \"-\" = \"-\";\n\n\t/**\n\t * Create a new LoggingError\n\t * @param message - Error message to use for Error base class\n\t * @param props - telemetry props to include on the error for when it's logged\n\t * @param omitPropsFromLogging - properties by name to omit from telemetry props\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\tprops?: ITelemetryProperties,\n\t\tprivate readonly omitPropsFromLogging: Set<string> = new Set(),\n\t) {\n\t\tsuper(message);\n\n\t\t// Don't log this list itself, or the private _errorInstanceId\n\t\tomitPropsFromLogging.add(\"omitPropsFromLogging\");\n\t\tomitPropsFromLogging.add(\"_errorInstanceId\");\n\n\t\tif (props) {\n\t\t\tthis.addTelemetryProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * Determines if a given object is an instance of a LoggingError\n\t * @param object - any object\n\t * @returns - true if the object is an instance of a LoggingError, false if not.\n\t */\n\tpublic static typeCheck(object: unknown): object is LoggingError {\n\t\tif (typeof object === \"object\" && object !== null) {\n\t\t\treturn (\n\t\t\t\ttypeof (object as LoggingError).addTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).getTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).errorInstanceId === \"string\"\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Add additional properties to be logged\n\t */\n\tpublic addTelemetryProperties(props: ITelemetryProperties) {\n\t\tcopyProps(this, props);\n\t}\n\n\t/**\n\t * Get all properties fit to be logged to telemetry for this error\n\t */\n\tpublic getTelemetryProperties(): ITelemetryProperties {\n\t\tconst taggableProps = getValidTelemetryProps(this, this.omitPropsFromLogging);\n\t\t// Include non-enumerable props that are not returned by getValidTelemetryProps\n\t\treturn {\n\t\t\t...taggableProps,\n\t\t\tstack: this.stack,\n\t\t\tmessage: this.message,\n\t\t\terrorInstanceId: this._errorInstanceId,\n\t\t};\n\t}\n}\n\n/** The Error class used when normalizing an external error */\nexport const NORMALIZED_ERROR_TYPE = \"genericError\";\nclass NormalizedLoggingError extends LoggingError {\n\t// errorType \"genericError\" is used as a default value throughout the code.\n\t// Note that this matches ContainerErrorType/DriverErrorType's genericError\n\terrorType = NORMALIZED_ERROR_TYPE;\n\n\tconstructor(errorProps: Pick<IFluidErrorBase, \"message\" | \"stack\">) {\n\t\tsuper(errorProps.message);\n\n\t\tif (errorProps.stack !== undefined) {\n\t\t\toverwriteStack(this, errorProps.stack);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventEmitterWithErrorHandling.d.ts","sourceRoot":"","sources":["../src/eventEmitterWithErrorHandling.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAExF;;;;GAIG;AACH,qBAAa,6BAA6B,
|
|
1
|
+
{"version":3,"file":"eventEmitterWithErrorHandling.d.ts","sourceRoot":"","sources":["../src/eventEmitterWithErrorHandling.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAExF;;;;GAIG;AACH,qBAAa,6BAA6B,CACzC,MAAM,SAAS,MAAM,GAAG,MAAM,CAC7B,SAAQ,iBAAiB,CAAC,MAAM,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,CAAC,SAAS,EAAE,qBAAqB,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI;IAK/E,IAAI,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;CAQlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventEmitterWithErrorHandling.js","sourceRoot":"","sources":["../src/eventEmitterWithErrorHandling.ts"],"names":[],"mappings":";;;AAKA,+DAAwF;AAExF;;;;GAIG;AACH,MAAa,
|
|
1
|
+
{"version":3,"file":"eventEmitterWithErrorHandling.js","sourceRoot":"","sources":["../src/eventEmitterWithErrorHandling.ts"],"names":[],"mappings":";;;AAKA,+DAAwF;AAExF;;;;GAIG;AACH,MAAa,6BAEX,SAAQ,gCAAyB;IAClC,YACkB,YAAoE;QAErF,KAAK,EAAE,CAAC;QAFS,iBAAY,GAAZ,YAAY,CAAwD;IAGtF,CAAC;IAEM,IAAI,CAAC,KAA4B,EAAE,GAAG,IAAW;QACvD,IAAI;YACH,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;SAClC;QAAC,OAAO,KAAK,EAAE;YACf,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;CACD;AAjBD,sEAiBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { TypedEventEmitter, EventEmitterEventType } from \"@fluidframework/common-utils\";\n\n/**\n * Event Emitter helper class\n * Any exceptions thrown by listeners will be caught and raised through \"error\" event.\n * Any exception thrown by \"error\" listeners will propagate to the caller.\n */\nexport class EventEmitterWithErrorHandling<\n\tTEvent extends IEvent = IEvent,\n> extends TypedEventEmitter<TEvent> {\n\tconstructor(\n\t\tprivate readonly errorHandler: (eventName: EventEmitterEventType, error: any) => void,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic emit(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\ttry {\n\t\t\treturn super.emit(event, ...args);\n\t\t} catch (error) {\n\t\t\tthis.errorHandler(event, error);\n\t\t\treturn true;\n\t\t}\n\t}\n}\n"]}
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAC9C,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAEpD,wBAAgB,cAAc,CAC7B,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,EACb,GAAG,IAAI,OAAA,QAOP;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,MAAM,QAW3B"}
|
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKU,QAAA,kBAAkB,GAAG,WAAW,CAAC;AACjC,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD,SAAgB,cAAc,CAC7B,OAAqB,EACrB,MAAwB,EACxB,KAAa,EACb,GAAG,IAAI;IAEP,IAAI;QACH,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;KAC7B;IAAC,OAAO,KAAK,EAAE;QACf,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;KACtE;AACF,CAAC;AAXD,wCAWC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAClC,MAAwB,EACxB,OAAqB,EACrB,SAAkB,EAClB,QAAiB,EACjB,kBAA2B;IAE3B,IAAI;QACH,IAAI,SAAS,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,0BAAkB,EAAE,QAAQ,CAAC,CAAC;SAC3C;aAAM;YACN,OAAO,CAAC,IAAI,CAAC,6BAAqB,EAAE,kBAAkB,CAAC,CAAC;SACxD;KACD;IAAC,OAAO,KAAK,EAAE;QACf,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,EAAE,KAAK,CAAC,CAAC;KACxE;AACF,CAAC;AAhBD,kDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\n\nexport const connectedEventName = \"connected\";\nexport const disconnectedEventName = \"disconnected\";\n\nexport function safeRaiseEvent(\n\temitter: EventEmitter,\n\tlogger: ITelemetryLogger,\n\tevent: string,\n\t...args\n) {\n\ttry {\n\t\temitter.emit(event, ...args);\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseEventError\", event }, error);\n\t}\n}\n\n/**\n * Raises events pertaining to the connection\n * @param logger - The logger to log telemetry\n * @param emitter - The event emitter instance\n * @param connected - A boolean tracking whether the connection was in a connected state or not\n * @param clientId - The connected/disconnected clientId\n * @param disconnectedReason - The reason for the connection to be disconnected (Used for telemetry purposes only)\n */\nexport function raiseConnectedEvent(\n\tlogger: ITelemetryLogger,\n\temitter: EventEmitter,\n\tconnected: boolean,\n\tclientId?: string,\n\tdisconnectedReason?: string,\n) {\n\ttry {\n\t\tif (connected) {\n\t\t\temitter.emit(connectedEventName, clientId);\n\t\t} else {\n\t\t\temitter.emit(disconnectedEventName, disconnectedReason);\n\t\t}\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseConnectedEventError\" }, error);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidErrorBase.d.ts","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"fluidErrorBase.d.ts","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,KAAK;IAC7C,8GAA8G;IAC9G,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC,qEAAqE;IACrE,sBAAsB,IAAI,oBAAoB,CAAC;IAC/C,iFAAiF;IACjF,sBAAsB,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC9D;AAMD,eAAO,MAAM,kBAAkB,MAAO,GAAG;qBAA2B,MAAM;CACnC,CAAC;AAExC,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,eAAe,CAOzD;AAED,wDAAwD;AACxD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAMxF"}
|
package/dist/fluidErrorBase.js
CHANGED
|
@@ -11,17 +11,17 @@ const hasErrorInstanceId = (x) => typeof (x === null || x === void 0 ? void 0 :
|
|
|
11
11
|
exports.hasErrorInstanceId = hasErrorInstanceId;
|
|
12
12
|
/** type guard for IFluidErrorBase interface */
|
|
13
13
|
function isFluidError(e) {
|
|
14
|
-
return typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
14
|
+
return (typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
15
15
|
typeof (e === null || e === void 0 ? void 0 : e.message) === "string" &&
|
|
16
16
|
(0, exports.hasErrorInstanceId)(e) &&
|
|
17
|
-
hasTelemetryPropFunctions(e);
|
|
17
|
+
hasTelemetryPropFunctions(e));
|
|
18
18
|
}
|
|
19
19
|
exports.isFluidError = isFluidError;
|
|
20
20
|
/** type guard for old standard of valid/known errors */
|
|
21
21
|
function isValidLegacyError(e) {
|
|
22
|
-
return typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
22
|
+
return (typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
23
23
|
typeof (e === null || e === void 0 ? void 0 : e.message) === "string" &&
|
|
24
|
-
hasTelemetryPropFunctions(e);
|
|
24
|
+
hasTelemetryPropFunctions(e));
|
|
25
25
|
}
|
|
26
26
|
exports.isValidLegacyError = isValidLegacyError;
|
|
27
27
|
//# sourceMappingURL=fluidErrorBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidErrorBase.js","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAuCH,MAAM,yBAAyB,GAAG,CAAC,CAAM,EAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"fluidErrorBase.js","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAuCH,MAAM,yBAAyB,GAAG,CAAC,CAAM,EAAW,EAAE,CACrD,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,sBAAsB,CAAA,KAAK,UAAU;IAC/C,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,sBAAsB,CAAA,KAAK,UAAU,CAAC;AAE1C,MAAM,kBAAkB,GAAG,CAAC,CAAM,EAAoC,EAAE,CAC9E,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,eAAe,CAAA,KAAK,QAAQ,CAAC;AAD3B,QAAA,kBAAkB,sBACS;AAExC,+CAA+C;AAC/C,SAAgB,YAAY,CAAC,CAAM;IAClC,OAAO,CACN,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,SAAS,CAAA,KAAK,QAAQ;QAChC,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,CAAA,KAAK,QAAQ;QAC9B,IAAA,0BAAkB,EAAC,CAAC,CAAC;QACrB,yBAAyB,CAAC,CAAC,CAAC,CAC5B,CAAC;AACH,CAAC;AAPD,oCAOC;AAED,wDAAwD;AACxD,SAAgB,kBAAkB,CAAC,CAAM;IACxC,OAAO,CACN,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,SAAS,CAAA,KAAK,QAAQ;QAChC,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,CAAA,KAAK,QAAQ;QAC9B,yBAAyB,CAAC,CAAC,CAAC,CAC5B,CAAC;AACH,CAAC;AAND,gDAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/common-definitions\";\n\n/**\n * All normalized errors flowing through the Fluid Framework adhere to this readonly interface.\n * It features errorType and errorInstanceId on top of Error's members as readonly,\n * and a getter/setter for telemetry props to be included when the error is logged.\n */\nexport interface IFluidErrorBase extends Error {\n\t/** Classification of what type of error this is, used programmatically by consumers to interpret the error */\n\treadonly errorType: string;\n\n\t/**\n\t * Error's message property, made readonly.\n\t * Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry\n\t * Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead.\n\t */\n\treadonly message: string;\n\n\t/** Error's stack property, made readonly */\n\treadonly stack?: string;\n\n\t/** Error's name property, made readonly */\n\treadonly name: string;\n\n\t/**\n\t * A Guid identifying this error instance.\n\t * Useful in telemetry for deduping multiple logging events arising from the same error,\n\t * or correlating an error with an inner error that caused it, in case of error wrapping.\n\t */\n\treadonly errorInstanceId: string;\n\n\t/** Get the telemetry properties stashed on this error for logging */\n\tgetTelemetryProperties(): ITelemetryProperties;\n\t/** Add telemetry properties to this error which will be logged with the error */\n\taddTelemetryProperties: (props: ITelemetryProperties) => void;\n}\n\nconst hasTelemetryPropFunctions = (x: any): boolean =>\n\ttypeof x?.getTelemetryProperties === \"function\" &&\n\ttypeof x?.addTelemetryProperties === \"function\";\n\nexport const hasErrorInstanceId = (x: any): x is { errorInstanceId: string } =>\n\ttypeof x?.errorInstanceId === \"string\";\n\n/** type guard for IFluidErrorBase interface */\nexport function isFluidError(e: any): e is IFluidErrorBase {\n\treturn (\n\t\ttypeof e?.errorType === \"string\" &&\n\t\ttypeof e?.message === \"string\" &&\n\t\thasErrorInstanceId(e) &&\n\t\thasTelemetryPropFunctions(e)\n\t);\n}\n\n/** type guard for old standard of valid/known errors */\nexport function isValidLegacyError(e: any): e is Omit<IFluidErrorBase, \"errorInstanceId\"> {\n\treturn (\n\t\ttypeof e?.errorType === \"string\" &&\n\t\ttypeof e?.message === \"string\" &&\n\t\thasTelemetryPropFunctions(e)\n\t);\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export { MonitoringContext, IConfigProviderBase, sessionStorageConfigProvider, m
|
|
|
6
6
|
export { DebugLogger } from "./debugLogger";
|
|
7
7
|
export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, IFluidErrorAnnotations, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, wrapError, wrapErrorAndLog, } from "./errorLogging";
|
|
8
8
|
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling";
|
|
9
|
-
export { connectedEventName, disconnectedEventName, raiseConnectedEvent, safeRaiseEvent } from "./events";
|
|
10
|
-
export { hasErrorInstanceId, IFluidErrorBase, isFluidError, isValidLegacyError } from "./fluidErrorBase";
|
|
9
|
+
export { connectedEventName, disconnectedEventName, raiseConnectedEvent, safeRaiseEvent, } from "./events";
|
|
10
|
+
export { hasErrorInstanceId, IFluidErrorBase, isFluidError, isValidLegacyError, } from "./fluidErrorBase";
|
|
11
11
|
export { BaseTelemetryNullLogger, ChildLogger, IPerformanceEventMarkers, ITelemetryLoggerPropertyBag, ITelemetryLoggerPropertyBags, MultiSinkLogger, PerformanceEvent, TaggedLoggerAdapter, TelemetryDataTag, TelemetryEventPropertyTypes, TelemetryLogger, TelemetryNullLogger, TelemetryUTLogger, } from "./logger";
|
|
12
12
|
export { MockLogger } from "./mockLogger";
|
|
13
13
|
export { ThresholdCounter } from "./thresholdCounter";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,yBAAyB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,WAAW,EACX,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,2BAA2B,EAC3B,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACN,6BAA6B,EAC7B,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,GACvB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mCAQkB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mCAQkB;AALjB,sHAAA,4BAA4B,OAAA;AAC5B,gHAAA,sBAAsB,OAAA;AAGtB,mHAAA,yBAAyB,OAAA;AAE1B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,+CAcwB;AAbvB,6HAAA,6BAA6B,OAAA;AAC7B,sHAAA,sBAAsB,OAAA;AACtB,6GAAA,aAAa,OAAA;AACb,mHAAA,mBAAmB,OAAA;AAEnB,+GAAA,eAAe,OAAA;AACf,+GAAA,eAAe,OAAA;AACf,8HAAA,8BAA8B,OAAA;AAC9B,4GAAA,YAAY,OAAA;AACZ,qHAAA,qBAAqB,OAAA;AACrB,8GAAA,cAAc,OAAA;AACd,yGAAA,SAAS,OAAA;AACT,+GAAA,eAAe,OAAA;AAEhB,iFAAgF;AAAvE,8IAAA,6BAA6B,OAAA;AACtC,mCAKkB;AAJjB,4GAAA,kBAAkB,OAAA;AAClB,+GAAA,qBAAqB,OAAA;AACrB,6GAAA,mBAAmB,OAAA;AACnB,wGAAA,cAAc,OAAA;AAEf,mDAK0B;AAJzB,oHAAA,kBAAkB,OAAA;AAElB,8GAAA,YAAY,OAAA;AACZ,oHAAA,kBAAkB,OAAA;AAEnB,mCAckB;AAbjB,iHAAA,uBAAuB,OAAA;AACvB,qGAAA,WAAW,OAAA;AAIX,yGAAA,eAAe,OAAA;AACf,0GAAA,gBAAgB,OAAA;AAChB,6GAAA,mBAAmB,OAAA;AACnB,0GAAA,gBAAgB,OAAA;AAEhB,yGAAA,eAAe,OAAA;AACf,6GAAA,mBAAmB,OAAA;AACnB,2GAAA,iBAAiB,OAAA;AAElB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,iCAAqC;AAA5B,mGAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport {\n\tMonitoringContext,\n\tIConfigProviderBase,\n\tsessionStorageConfigProvider,\n\tmixinMonitoringContext,\n\tIConfigProvider,\n\tConfigTypes,\n\tloggerToMonitoringContext,\n} from \"./config\";\nexport { DebugLogger } from \"./debugLogger\";\nexport {\n\textractLogSafeErrorProperties,\n\tgenerateErrorWithStack,\n\tgenerateStack,\n\tgetCircularReplacer,\n\tIFluidErrorAnnotations,\n\tisExternalError,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n\tLoggingError,\n\tNORMALIZED_ERROR_TYPE,\n\tnormalizeError,\n\twrapError,\n\twrapErrorAndLog,\n} from \"./errorLogging\";\nexport { EventEmitterWithErrorHandling } from \"./eventEmitterWithErrorHandling\";\nexport {\n\tconnectedEventName,\n\tdisconnectedEventName,\n\traiseConnectedEvent,\n\tsafeRaiseEvent,\n} from \"./events\";\nexport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nexport {\n\tBaseTelemetryNullLogger,\n\tChildLogger,\n\tIPerformanceEventMarkers,\n\tITelemetryLoggerPropertyBag,\n\tITelemetryLoggerPropertyBags,\n\tMultiSinkLogger,\n\tPerformanceEvent,\n\tTaggedLoggerAdapter,\n\tTelemetryDataTag,\n\tTelemetryEventPropertyTypes,\n\tTelemetryLogger,\n\tTelemetryNullLogger,\n\tTelemetryUTLogger,\n} from \"./logger\";\nexport { MockLogger } from \"./mockLogger\";\nexport { ThresholdCounter } from \"./thresholdCounter\";\nexport { SampledTelemetryHelper } from \"./sampledTelemetryHelper\";\nexport { logIfFalse } from \"./utils\";\nexport {\n\tTelemetryEventPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryErrorEventExt,\n\tITelemetryPerformanceEventExt,\n\tITelemetryLoggerExt,\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryPropertiesExt,\n} from \"./telemetryTypes\";\n"]}
|