@fluidframework/telemetry-utils 0.57.1 → 0.58.0-55561
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/dist/errorLogging.d.ts +17 -3
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js +50 -16
- package/dist/errorLogging.js.map +1 -1
- package/dist/fluidErrorBase.d.ts +5 -6
- package/dist/fluidErrorBase.d.ts.map +1 -1
- package/dist/fluidErrorBase.js +1 -2
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/mockLogger.d.ts +2 -2
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +18 -15
- package/dist/mockLogger.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/errorLogging.d.ts +17 -3
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js +47 -15
- package/lib/errorLogging.js.map +1 -1
- package/lib/fluidErrorBase.d.ts +5 -6
- package/lib/fluidErrorBase.d.ts.map +1 -1
- package/lib/fluidErrorBase.js +1 -2
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/mockLogger.d.ts +2 -2
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +18 -15
- package/lib/mockLogger.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +3 -3
- package/src/errorLogging.ts +65 -25
- package/src/fluidErrorBase.ts +6 -9
- package/src/mockLogger.ts +18 -16
- package/src/packageVersion.ts +1 -1
package/dist/errorLogging.d.ts
CHANGED
|
@@ -43,9 +43,19 @@ export declare function generateStack(): string | undefined;
|
|
|
43
43
|
* @param newErrorFn - callback that will create a new error given the original error's message
|
|
44
44
|
* @returns A new error object "wrapping" the given error
|
|
45
45
|
*/
|
|
46
|
-
export declare function wrapError<T extends
|
|
46
|
+
export declare function wrapError<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T): T;
|
|
47
47
|
/** The same as wrapError, but also logs the innerError, including the wrapping error's instance id */
|
|
48
|
-
export declare function wrapErrorAndLog<T extends
|
|
48
|
+
export declare function wrapErrorAndLog<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T, logger: ITelemetryLogger): T;
|
|
49
|
+
/**
|
|
50
|
+
* True for any error object that is either external itself or is a wrapped/normalized external error
|
|
51
|
+
* False for any error we created and raised within the FF codebase.
|
|
52
|
+
*/
|
|
53
|
+
export declare function originatedAsExternalError(e: any): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* True for any error object that is an (optionally normalized) external error
|
|
56
|
+
* False for any error we created and raised within the FF codebase, or wrapped in a well-known error type
|
|
57
|
+
*/
|
|
58
|
+
export declare function isExternalError(e: any): boolean;
|
|
49
59
|
/**
|
|
50
60
|
* Type guard to identify if a particular value (loosely) appears to be a tagged telemetry property
|
|
51
61
|
*/
|
|
@@ -66,7 +76,11 @@ export declare const getCircularReplacer: () => (key: string, value: any) => any
|
|
|
66
76
|
*/
|
|
67
77
|
export declare class LoggingError extends Error implements ILoggingError, Pick<IFluidErrorBase, "errorInstanceId"> {
|
|
68
78
|
private readonly omitPropsFromLogging;
|
|
69
|
-
|
|
79
|
+
private _errorInstanceId;
|
|
80
|
+
get errorInstanceId(): string;
|
|
81
|
+
overwriteErrorInstanceId(id: string): void;
|
|
82
|
+
/** Back-compat to appease isFluidError typeguard in old code that may handle this error */
|
|
83
|
+
private fluidErrorCode;
|
|
70
84
|
/**
|
|
71
85
|
* Create a new LoggingError
|
|
72
86
|
* @param message - Error message to use for Error base class
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorLogging.d.ts","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,aAAa,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|
-
exports.LoggingError = exports.getCircularReplacer = exports.isTaggedTelemetryPropertyValue = exports.wrapErrorAndLog = exports.wrapError = exports.generateStack = exports.generateErrorWithStack = exports.normalizeError = exports.isILoggingError = exports.extractLogSafeErrorProperties = void 0;
|
|
7
|
+
exports.LoggingError = exports.getCircularReplacer = exports.isTaggedTelemetryPropertyValue = exports.isExternalError = exports.originatedAsExternalError = exports.wrapErrorAndLog = exports.wrapError = exports.generateStack = exports.generateErrorWithStack = exports.normalizeError = exports.isILoggingError = exports.extractLogSafeErrorProperties = void 0;
|
|
8
8
|
const uuid_1 = require("uuid");
|
|
9
9
|
const fluidErrorBase_1 = require("./fluidErrorBase");
|
|
10
10
|
/** @returns true if value is an object but neither null nor an array */
|
|
@@ -54,13 +54,16 @@ function copyProps(target, source) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
/** For backwards compatibility with pre-
|
|
58
|
-
function
|
|
57
|
+
/** For backwards compatibility with pre-errorInstanceId valid errors */
|
|
58
|
+
function patchLegacyError(legacyError) {
|
|
59
59
|
const patchMe = legacyError;
|
|
60
|
-
if (patchMe.
|
|
61
|
-
patchMe.
|
|
60
|
+
if (patchMe.errorInstanceId === undefined) {
|
|
61
|
+
patchMe.errorInstanceId = uuid_1.v4();
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
// errorType "genericError" is used as a default value throughout the code.
|
|
65
|
+
// Note that this matches ContainerErrorType/DriverErrorType's genericError
|
|
66
|
+
const defaultErrorTypeForNormalize = "genericError";
|
|
64
67
|
/**
|
|
65
68
|
* Normalize the given error yielding a valid Fluid Error
|
|
66
69
|
* @returns A valid Fluid Error with any provided annotations applied
|
|
@@ -71,7 +74,7 @@ function normalizeError(error, annotations = {}) {
|
|
|
71
74
|
var _a;
|
|
72
75
|
// Back-compat, while IFluidErrorBase is rolled out
|
|
73
76
|
if (fluidErrorBase_1.isValidLegacyError(error)) {
|
|
74
|
-
|
|
77
|
+
patchLegacyError(error);
|
|
75
78
|
}
|
|
76
79
|
if (fluidErrorBase_1.isFluidError(error)) {
|
|
77
80
|
// We can simply add the telemetry props to the error and return it
|
|
@@ -81,8 +84,7 @@ function normalizeError(error, annotations = {}) {
|
|
|
81
84
|
// We have to construct a new Fluid Error, copying safe properties over
|
|
82
85
|
const { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);
|
|
83
86
|
const fluidError = new SimpleFluidError({
|
|
84
|
-
errorType:
|
|
85
|
-
fluidErrorCode: "",
|
|
87
|
+
errorType: defaultErrorTypeForNormalize,
|
|
86
88
|
message,
|
|
87
89
|
stack,
|
|
88
90
|
});
|
|
@@ -138,7 +140,14 @@ function wrapError(innerError, newErrorFn) {
|
|
|
138
140
|
if (stack !== undefined) {
|
|
139
141
|
overwriteStack(newError, stack);
|
|
140
142
|
}
|
|
143
|
+
// Mark external errors with untrustedOrigin flag
|
|
144
|
+
if (originatedAsExternalError(innerError)) {
|
|
145
|
+
newError.addTelemetryProperties({ untrustedOrigin: 1 });
|
|
146
|
+
}
|
|
147
|
+
// Reuse errorInstanceId
|
|
141
148
|
if (fluidErrorBase_1.hasErrorInstanceId(innerError)) {
|
|
149
|
+
newError.overwriteErrorInstanceId(innerError.errorInstanceId);
|
|
150
|
+
// For "back-compat" in the logs
|
|
142
151
|
newError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });
|
|
143
152
|
}
|
|
144
153
|
return newError;
|
|
@@ -147,11 +156,13 @@ exports.wrapError = wrapError;
|
|
|
147
156
|
/** The same as wrapError, but also logs the innerError, including the wrapping error's instance id */
|
|
148
157
|
function wrapErrorAndLog(innerError, newErrorFn, logger) {
|
|
149
158
|
const newError = wrapError(innerError, newErrorFn);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
// This will match innerError.errorInstanceId if present (see wrapError)
|
|
160
|
+
const errorInstanceId = newError.errorInstanceId;
|
|
161
|
+
// For "back-compat" in the logs
|
|
162
|
+
const wrappedByErrorInstanceId = errorInstanceId;
|
|
153
163
|
logger.sendTelemetryEvent({
|
|
154
164
|
eventName: "WrapError",
|
|
165
|
+
errorInstanceId,
|
|
155
166
|
wrappedByErrorInstanceId,
|
|
156
167
|
}, innerError);
|
|
157
168
|
return newError;
|
|
@@ -166,6 +177,24 @@ function overwriteStack(error, stack) {
|
|
|
166
177
|
error.addTelemetryProperties({ stack2: stack });
|
|
167
178
|
}
|
|
168
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* True for any error object that is either external itself or is a wrapped/normalized external error
|
|
182
|
+
* False for any error we created and raised within the FF codebase.
|
|
183
|
+
*/
|
|
184
|
+
function originatedAsExternalError(e) {
|
|
185
|
+
return !fluidErrorBase_1.isValidLegacyError(e) || (e.getTelemetryProperties().untrustedOrigin === 1);
|
|
186
|
+
}
|
|
187
|
+
exports.originatedAsExternalError = originatedAsExternalError;
|
|
188
|
+
/**
|
|
189
|
+
* True for any error object that is an (optionally normalized) external error
|
|
190
|
+
* False for any error we created and raised within the FF codebase, or wrapped in a well-known error type
|
|
191
|
+
*/
|
|
192
|
+
function isExternalError(e) {
|
|
193
|
+
return !fluidErrorBase_1.isValidLegacyError(e) ||
|
|
194
|
+
(e.getTelemetryProperties().untrustedOrigin === 1 &&
|
|
195
|
+
e.errorType === defaultErrorTypeForNormalize);
|
|
196
|
+
}
|
|
197
|
+
exports.isExternalError = isExternalError;
|
|
169
198
|
/**
|
|
170
199
|
* Type guard to identify if a particular value (loosely) appears to be a tagged telemetry property
|
|
171
200
|
*/
|
|
@@ -241,13 +270,19 @@ class LoggingError extends Error {
|
|
|
241
270
|
constructor(message, props, omitPropsFromLogging = new Set()) {
|
|
242
271
|
super(message);
|
|
243
272
|
this.omitPropsFromLogging = omitPropsFromLogging;
|
|
244
|
-
this.
|
|
245
|
-
|
|
273
|
+
this._errorInstanceId = uuid_1.v4();
|
|
274
|
+
/** Back-compat to appease isFluidError typeguard in old code that may handle this error */
|
|
275
|
+
// @ts-expect-error - This field shouldn't be referenced in the current version, but needs to exist at runtime.
|
|
276
|
+
this.fluidErrorCode = "-";
|
|
277
|
+
// Don't log this list itself, or the private _errorInstanceId
|
|
246
278
|
omitPropsFromLogging.add("omitPropsFromLogging");
|
|
279
|
+
omitPropsFromLogging.add("_errorInstanceId");
|
|
247
280
|
if (props) {
|
|
248
281
|
this.addTelemetryProperties(props);
|
|
249
282
|
}
|
|
250
283
|
}
|
|
284
|
+
get errorInstanceId() { return this._errorInstanceId; }
|
|
285
|
+
overwriteErrorInstanceId(id) { this._errorInstanceId = id; }
|
|
251
286
|
/**
|
|
252
287
|
* Add additional properties to be logged
|
|
253
288
|
*/
|
|
@@ -259,8 +294,8 @@ class LoggingError extends Error {
|
|
|
259
294
|
*/
|
|
260
295
|
getTelemetryProperties() {
|
|
261
296
|
const taggableProps = getValidTelemetryProps(this, this.omitPropsFromLogging);
|
|
262
|
-
// Include non-enumerable props
|
|
263
|
-
return Object.assign(Object.assign({}, taggableProps), { stack: this.stack, message: this.message });
|
|
297
|
+
// Include non-enumerable props that are not returned by getValidTelemetryProps
|
|
298
|
+
return Object.assign(Object.assign({}, taggableProps), { stack: this.stack, message: this.message, errorInstanceId: this._errorInstanceId });
|
|
264
299
|
}
|
|
265
300
|
}
|
|
266
301
|
exports.LoggingError = LoggingError;
|
|
@@ -269,7 +304,6 @@ class SimpleFluidError extends LoggingError {
|
|
|
269
304
|
constructor(errorProps) {
|
|
270
305
|
super(errorProps.message);
|
|
271
306
|
this.errorType = errorProps.errorType;
|
|
272
|
-
this.fluidErrorCode = errorProps.fluidErrorCode;
|
|
273
307
|
if (errorProps.stack !== undefined) {
|
|
274
308
|
overwriteStack(this, errorProps.stack);
|
|
275
309
|
}
|
package/dist/errorLogging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorLogging.js","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,+BAAkC;AAClC,qDAK0B;AAE1B,wE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AQ,KAAK;IAGnC;;;;;OAKG;IACH,YACI,OAAe,EACf,KAA4B,EACX,uBAAoC,IAAI,GAAG,EAAE;QAE9D,KAAK,CAAC,OAAO,CAAC,CAAC;QAFE,yBAAoB,GAApB,oBAAoB,CAAyB;QAXzD,oBAAe,GAAG,SAAI,EAAE,CAAC;QAe9B,oCAAoC;QACpC,oBAAoB,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAEjD,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;SACtC;IACL,CAAC;IAED;;OAEG;IACI,sBAAsB,CAAC,KAA2B;QACrD,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACI,sBAAsB;QACzB,MAAM,aAAa,GAAG,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC9E,oGAAoG;QACpG,uCACO,aAAa,KAChB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,IACvB;IACN,CAAC;CACJ;AA3CD,oCA2CC;AAED,uEAAuE;AACvE,MAAM,gBAAiB,SAAQ,YAAY;IAIvC,YACI,UAIa;QAEb,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;QAChD,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} from \"@fluidframework/common-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n hasErrorInstanceId,\n IFluidErrorBase,\n isFluidError,\n isValidLegacyError,\n} from \"./fluidErrorBase\";\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-fluidErrorCode valid errors */\nfunction patchWithErrorCode(\n legacyError: Omit<IFluidErrorBase, \"fluidErrorCode\">,\n): asserts legacyError is IFluidErrorBase {\n const patchMe: { -readonly [P in \"fluidErrorCode\"]?: IFluidErrorBase[P] } = legacyError as any;\n if (patchMe.fluidErrorCode === undefined) {\n patchMe.fluidErrorCode = \"<error predates fluidErrorCode>\";\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 patchWithErrorCode(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 SimpleFluidError({\n errorType: \"genericError\", // Match Container/Driver generic error type\n fluidErrorCode: \"\",\n message,\n stack,\n });\n\n fluidError.addTelemetryProperties({\n ...annotations.props,\n untrustedOrigin: 1, // This will let us filter to errors not originated by our own code\n });\n\n if (typeof(error) !== \"object\") {\n // This is only interesting for non-objects\n fluidError.addTelemetryProperties({ typeofError: typeof(error) });\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 */\n export 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, wrapping and caused by the given unknown error.\n * Copies the inner error's message and stack over but otherwise uses newErrorFn to define the error.\n * The inner error's instance id will also be logged for telemetry analysis.\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 */\n export function wrapError<T extends IFluidErrorBase>(\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 if (hasErrorInstanceId(innerError)) {\n newError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\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 IFluidErrorBase>(\n innerError: unknown,\n newErrorFn: (message: string) => T,\n logger: ITelemetryLogger,\n) {\n const newError = wrapError(innerError, newErrorFn);\n const wrappedByErrorInstanceId = hasErrorInstanceId(newError)\n ? newError.errorInstanceId\n : undefined;\n\n logger.sendTelemetryEvent({\n eventName: \"WrapError\",\n wrappedByErrorInstanceId,\n }, innerError);\n\n return newError;\n}\n\nfunction overwriteStack(error: IFluidErrorBase, 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 * Type guard to identify if a particular value (loosely) appears to be a tagged telemetry property\n */\nexport function isTaggedTelemetryPropertyValue(x: any): x is ITaggedTelemetryPropertyType {\n return (typeof(x?.value) !== \"object\" && typeof(x?.tag) === \"string\");\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 switch (typeof val) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"undefined\":\n props[key] = val;\n break;\n default: {\n if (isTaggedTelemetryPropertyValue(val)) {\n props[key] = val;\n } else {\n // We don't support logging arbitrary objects\n props[key] = \"REDACTED (arbitrary object)\";\n }\n break;\n }\n }\n }\n return props;\n}\n\n/**\n * Borrowed from 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 // eslint-disable-next-line @typescript-eslint/no-unsafe-return\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 getTelemetryProperties),\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, Pick<IFluidErrorBase, \"errorInstanceId\"> {\n readonly errorInstanceId = uuid();\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 either\n omitPropsFromLogging.add(\"omitPropsFromLogging\");\n\n if (props) {\n this.addTelemetryProperties(props);\n }\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 inherited from Error that are not returned by getValidTelemetryProps\n return {\n ...taggableProps,\n stack: this.stack,\n message: this.message,\n };\n }\n}\n\n/** Simple implementation of IFluidErrorBase, extending LoggingError */\nclass SimpleFluidError extends LoggingError implements IFluidErrorBase {\n readonly errorType: string;\n readonly fluidErrorCode: string;\n\n constructor(\n errorProps: Omit<IFluidErrorBase,\n | \"getTelemetryProperties\"\n | \"addTelemetryProperties\"\n | \"errorInstanceId\"\n | \"name\">,\n ) {\n super(errorProps.message);\n this.errorType = errorProps.errorType;\n this.fluidErrorCode = errorProps.fluidErrorCode;\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;;;AAQH,+BAAkC;AAClC,qDAK0B;AAE1B,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,GAAG,CAAC,KAAa,EAAE,SAAkB,EAAE,EAAE;QACjE,IAAI,CAAC,aAAa,EAAE;YAChB,OAAO,KAAK,CAAC;SAChB;QACD,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,uCAAuC;QAC5D,IAAI,SAAS,KAAK,SAAS,EAAE;YACzB,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB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U,CAAC,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACtC,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} from \"@fluidframework/common-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n hasErrorInstanceId,\n IFluidErrorBase,\n isFluidError,\n isValidLegacyError,\n} from \"./fluidErrorBase\";\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// errorType \"genericError\" is used as a default value throughout the code.\n// Note that this matches ContainerErrorType/DriverErrorType's genericError\nconst defaultErrorTypeForNormalize = \"genericError\";\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 SimpleFluidError({\n errorType: defaultErrorTypeForNormalize,\n message,\n stack,\n });\n\n fluidError.addTelemetryProperties({\n ...annotations.props,\n untrustedOrigin: 1, // This will let us filter to errors not originated by our own code\n });\n\n if (typeof(error) !== \"object\") {\n // This is only interesting for non-objects\n fluidError.addTelemetryProperties({ typeofError: typeof(error) });\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 */\n export 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, wrapping and caused by the given unknown error.\n * Copies the inner error's message and stack over but otherwise uses newErrorFn to define the error.\n * The inner error's instance id will also be logged for telemetry analysis.\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 (originatedAsExternalError(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 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 either external itself or is a wrapped/normalized external error\n * False for any error we created and raised within the FF codebase.\n */\nexport function originatedAsExternalError(e: any): boolean {\n return !isValidLegacyError(e) || (e.getTelemetryProperties().untrustedOrigin === 1);\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, or wrapped in a well-known error type\n */\nexport function isExternalError(e: any): boolean {\n return !isValidLegacyError(e) ||\n (e.getTelemetryProperties().untrustedOrigin === 1 &&\n e.errorType === defaultErrorTypeForNormalize);\n}\n\n/**\n * Type guard to identify if a particular value (loosely) appears to be a tagged telemetry property\n */\nexport function isTaggedTelemetryPropertyValue(x: any): x is ITaggedTelemetryPropertyType {\n return (typeof(x?.value) !== \"object\" && typeof(x?.tag) === \"string\");\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 switch (typeof val) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"undefined\":\n props[key] = val;\n break;\n default: {\n if (isTaggedTelemetryPropertyValue(val)) {\n props[key] = val;\n } else {\n // We don't support logging arbitrary objects\n props[key] = \"REDACTED (arbitrary object)\";\n }\n break;\n }\n }\n }\n return props;\n}\n\n/**\n * Borrowed from 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 // eslint-disable-next-line @typescript-eslint/no-unsafe-return\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 getTelemetryProperties),\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, Pick<IFluidErrorBase, \"errorInstanceId\"> {\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 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 * 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/** Simple implementation of IFluidErrorBase, extending LoggingError */\nclass SimpleFluidError extends LoggingError implements IFluidErrorBase {\n readonly errorType: string;\n\n constructor(\n errorProps: Pick<IFluidErrorBase,\n | \"message\"\n | \"stack\"\n | \"errorType\"\n >,\n ) {\n super(errorProps.message);\n this.errorType = errorProps.errorType;\n if (errorProps.stack !== undefined) {\n overwriteStack(this, errorProps.stack);\n }\n }\n}\n"]}
|
package/dist/fluidErrorBase.d.ts
CHANGED
|
@@ -5,18 +5,17 @@
|
|
|
5
5
|
import { ITelemetryProperties } from "@fluidframework/common-definitions";
|
|
6
6
|
/**
|
|
7
7
|
* All normalized errors flowing through the Fluid Framework adhere to this readonly interface.
|
|
8
|
-
* It features errorType
|
|
8
|
+
* It features errorType and errorInstanceId on top of Error's members as readonly,
|
|
9
9
|
* and a getter/setter for telemetry props to be included when the error is logged.
|
|
10
10
|
*/
|
|
11
11
|
export interface IFluidErrorBase extends Error {
|
|
12
12
|
/** Classification of what type of error this is, used programmatically by consumers to interpret the error */
|
|
13
13
|
readonly errorType: string;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Error's message property, made readonly.
|
|
16
|
+
* Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry
|
|
17
|
+
* Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead.
|
|
17
18
|
*/
|
|
18
|
-
readonly fluidErrorCode: string;
|
|
19
|
-
/** The free-form error message */
|
|
20
19
|
readonly message: string;
|
|
21
20
|
/** Error's stack property, made readonly */
|
|
22
21
|
readonly stack?: string;
|
|
@@ -39,5 +38,5 @@ export declare const hasErrorInstanceId: (x: any) => x is {
|
|
|
39
38
|
/** type guard for IFluidErrorBase interface */
|
|
40
39
|
export declare function isFluidError(e: any): e is IFluidErrorBase;
|
|
41
40
|
/** type guard for old standard of valid/known errors */
|
|
42
|
-
export declare function isValidLegacyError(e: any): e is Omit<IFluidErrorBase, "
|
|
41
|
+
export declare function isValidLegacyError(e: any): e is Omit<IFluidErrorBase, "errorInstanceId">;
|
|
43
42
|
//# sourceMappingURL=fluidErrorBase.d.ts.map
|
|
@@ -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;IAC1C,8GAA8G;IAC9G,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B
|
|
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;IAC1C,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;CACjE;AAMD,eAAO,MAAM,kBAAkB,MAAO,GAAG;qBAA2B,MAAM;CAChC,CAAC;AAE3C,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,eAAe,CAKzD;AAED,wDAAwD;AACxD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAIxF"}
|
package/dist/fluidErrorBase.js
CHANGED
|
@@ -12,9 +12,8 @@ exports.hasErrorInstanceId = hasErrorInstanceId;
|
|
|
12
12
|
/** type guard for IFluidErrorBase interface */
|
|
13
13
|
function isFluidError(e) {
|
|
14
14
|
return typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
15
|
-
typeof (e === null || e === void 0 ? void 0 : e.fluidErrorCode) === "string" &&
|
|
16
15
|
typeof (e === null || e === void 0 ? void 0 : e.message) === "string" &&
|
|
17
|
-
|
|
16
|
+
exports.hasErrorInstanceId(e) &&
|
|
18
17
|
hasTelemetryPropFunctions(e);
|
|
19
18
|
}
|
|
20
19
|
exports.isFluidError = isFluidError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidErrorBase.js","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"fluidErrorBase.js","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAuCH,MAAM,yBAAyB,GAAG,CAAC,CAAM,EAAW,EAAE,CAClD,QAAO,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,sBAAsB,CAAA,KAAK,UAAU;IAC/C,QAAO,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,sBAAsB,CAAA,KAAK,UAAU,CAAC;AAE7C,MAAM,kBAAkB,GAAG,CAAC,CAAM,EAAoC,EAAE,CAC3E,QAAO,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,eAAe,CAAA,KAAK,QAAQ,CAAC;AAD9B,QAAA,kBAAkB,sBACY;AAE3C,+CAA+C;AAC/C,SAAgB,YAAY,CAAC,CAAM;IAC/B,OAAO,QAAO,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,SAAS,CAAA,KAAK,QAAQ;QACnC,QAAO,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,CAAA,KAAK,QAAQ;QAC9B,0BAAkB,CAAC,CAAC,CAAC;QACrB,yBAAyB,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AALD,oCAKC;AAED,wDAAwD;AACxD,SAAgB,kBAAkB,CAAC,CAAM;IACrC,OAAO,QAAO,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,SAAS,CAAA,KAAK,QAAQ;QACnC,QAAO,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,CAAA,KAAK,QAAQ;QAC9B,yBAAyB,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAJD,gDAIC","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 /** Classification of what type of error this is, used programmatically by consumers to interpret the error */\n readonly errorType: string;\n\n /**\n * Error's message property, made readonly.\n * Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry\n * Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead.\n */\n readonly message: string;\n\n /** Error's stack property, made readonly */\n readonly stack?: string;\n\n /** Error's name property, made readonly */\n readonly name: string;\n\n /**\n * A Guid identifying this error instance.\n * Useful in telemetry for deduping multiple logging events arising from the same error,\n * or correlating an error with an inner error that caused it, in case of error wrapping.\n */\n readonly errorInstanceId: string;\n\n /** Get the telemetry properties stashed on this error for logging */\n getTelemetryProperties(): ITelemetryProperties;\n /** Add telemetry properties to this error which will be logged with the error */\n addTelemetryProperties: (props: ITelemetryProperties) => void;\n}\n\nconst hasTelemetryPropFunctions = (x: any): boolean =>\n typeof x?.getTelemetryProperties === \"function\" &&\n typeof x?.addTelemetryProperties === \"function\";\n\nexport const hasErrorInstanceId = (x: any): x is { errorInstanceId: string } =>\n typeof x?.errorInstanceId === \"string\";\n\n/** type guard for IFluidErrorBase interface */\nexport function isFluidError(e: any): e is IFluidErrorBase {\n return typeof e?.errorType === \"string\" &&\n typeof e?.message === \"string\" &&\n hasErrorInstanceId(e) &&\n hasTelemetryPropFunctions(e);\n}\n\n/** type guard for old standard of valid/known errors */\nexport function isValidLegacyError(e: any): e is Omit<IFluidErrorBase, \"errorInstanceId\"> {\n return typeof e?.errorType === \"string\" &&\n typeof e?.message === \"string\" &&\n hasTelemetryPropFunctions(e);\n}\n"]}
|
package/dist/mockLogger.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class MockLogger extends TelemetryLogger implements ITelemetryLog
|
|
|
21
21
|
*/
|
|
22
22
|
matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
|
|
23
23
|
/** Asserts that matchEvents is true, and prints the actual/expected output if not */
|
|
24
|
-
assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): void;
|
|
24
|
+
assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
|
|
25
25
|
/**
|
|
26
26
|
* Search events logged since the last time matchEvents was called, looking for any of the given
|
|
27
27
|
* expected events.
|
|
@@ -32,7 +32,7 @@ export declare class MockLogger extends TelemetryLogger implements ITelemetryLog
|
|
|
32
32
|
*/
|
|
33
33
|
matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
|
|
34
34
|
/** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */
|
|
35
|
-
assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): void;
|
|
35
|
+
assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
|
|
36
36
|
private getMatchedEventsCount;
|
|
37
37
|
/**
|
|
38
38
|
* Ensure the expected event is a strict subset of the actual event
|
package/dist/mockLogger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockLogger.d.ts","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"mockLogger.d.ts","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAAgB,YAAW,gBAAgB;IACvE,MAAM,EAAE,mBAAmB,EAAE,CAAM;;IAInC,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAItC;;;;;;OAMG;IACH,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAO7E,qFAAqF;IACrF,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAYrF;;;;;;;OAOG;IACH,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAK/E,uFAAuF;IACvF,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAYxF,OAAO,CAAC,qBAAqB;IAkB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;CAI7B"}
|
package/dist/mockLogger.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.MockLogger = void 0;
|
|
8
|
-
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
8
|
const logger_1 = require("./logger");
|
|
10
9
|
/**
|
|
11
10
|
* The MockLogger records events sent to it, and then can walk back over those events
|
|
@@ -33,14 +32,16 @@ class MockLogger extends logger_1.TelemetryLogger {
|
|
|
33
32
|
return unmatchedExpectedEventCount === 0;
|
|
34
33
|
}
|
|
35
34
|
/** Asserts that matchEvents is true, and prints the actual/expected output if not */
|
|
36
|
-
assertMatch(expectedEvents) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
assertMatch(expectedEvents, message) {
|
|
36
|
+
const actualEvents = this.events;
|
|
37
|
+
if (!this.matchEvents(expectedEvents)) {
|
|
38
|
+
throw new Error(`${message}
|
|
39
|
+
expected:
|
|
40
|
+
${JSON.stringify(expectedEvents)}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
actual:
|
|
43
|
+
${JSON.stringify(actualEvents)}`);
|
|
44
|
+
}
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* Search events logged since the last time matchEvents was called, looking for any of the given
|
|
@@ -55,14 +56,16 @@ class MockLogger extends logger_1.TelemetryLogger {
|
|
|
55
56
|
return matchedExpectedEventCount > 0;
|
|
56
57
|
}
|
|
57
58
|
/** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */
|
|
58
|
-
assertMatchAny(expectedEvents) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
assertMatchAny(expectedEvents, message) {
|
|
60
|
+
const actualEvents = this.events;
|
|
61
|
+
if (!this.matchAnyEvent(expectedEvents)) {
|
|
62
|
+
throw new Error(`${message}
|
|
63
|
+
expected:
|
|
64
|
+
${JSON.stringify(expectedEvents)}
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
actual:
|
|
67
|
+
${JSON.stringify(actualEvents)}`);
|
|
68
|
+
}
|
|
66
69
|
}
|
|
67
70
|
getMatchedEventsCount(expectedEvents) {
|
|
68
71
|
let iExpectedEvent = 0;
|
package/dist/mockLogger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH
|
|
1
|
+
{"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAA2C;AAE3C;;;GAGG;AACH,MAAa,UAAW,SAAQ,wBAAe;IAG3C;QAAgB,KAAK,EAAE,CAAC;QAFxB,WAAM,GAA0B,EAAE,CAAC;IAEV,CAAC;IAE1B,IAAI,CAAC,KAA0B;QAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,cAAuD;QAC/D,MAAM,yBAAyB,GAAG,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAC7E,2DAA2D;QAC3D,MAAM,2BAA2B,GAAG,cAAc,CAAC,MAAM,GAAG,yBAAyB,CAAC;QACtF,OAAO,2BAA2B,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,qFAAqF;IACrF,WAAW,CAAC,cAAuD,EAAE,OAAgB;QACjF,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO;;EAEpC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC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AAC;CACJ;AAvFD,gCAuFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { TelemetryLogger } from \"./logger\";\n\n/**\n * The MockLogger records events sent to it, and then can walk back over those events\n * searching for a set of expected events to match against the logged events.\n */\nexport class MockLogger extends TelemetryLogger implements ITelemetryLogger {\n events: ITelemetryBaseEvent[] = [];\n\n constructor() { super(); }\n\n send(event: ITelemetryBaseEvent): void {\n this.events.push(event);\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n // How many expected events were left over? Hopefully none.\n const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n return unmatchedExpectedEventCount === 0;\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEvents(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for any of the given\n * expected events.\n * @param expectedEvents - events that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.\n * @returns if any of the expected events is found.\n */\n matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n return matchedExpectedEventCount > 0;\n }\n\n /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */\n assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchAnyEvent(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n private getMatchedEventsCount(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): number {\n let iExpectedEvent = 0;\n this.events.forEach((event) => {\n if (iExpectedEvent < expectedEvents.length &&\n MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])\n ) {\n // We found the next expected event; increment\n ++iExpectedEvent;\n }\n });\n\n // Remove the events so far; next call will just compare subsequent events from here\n this.events = [];\n\n // Return the count of matched events.\n return iExpectedEvent;\n }\n\n /**\n * Ensure the expected event is a strict subset of the actual event\n */\n private static eventsMatch(actual: ITelemetryBaseEvent, expected: Omit<ITelemetryBaseEvent, \"category\">): boolean {\n const masked = { ...actual, ...expected };\n return JSON.stringify(masked) === JSON.stringify(actual);\n }\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/telemetry-utils";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "0.58.0-55561";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,oCAAoC,CAAC;AACzD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,oCAAoC,CAAC;AACzD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/telemetry-utils";
|
|
11
|
-
exports.pkgVersion = "0.
|
|
11
|
+
exports.pkgVersion = "0.58.0-55561";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,iCAAiC,CAAC;AAC5C,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,iCAAiC,CAAC;AAC5C,QAAA,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/telemetry-utils\";\nexport const pkgVersion = \"0.58.0-55561\";\n"]}
|
package/lib/errorLogging.d.ts
CHANGED
|
@@ -43,9 +43,19 @@ export declare function generateStack(): string | undefined;
|
|
|
43
43
|
* @param newErrorFn - callback that will create a new error given the original error's message
|
|
44
44
|
* @returns A new error object "wrapping" the given error
|
|
45
45
|
*/
|
|
46
|
-
export declare function wrapError<T extends
|
|
46
|
+
export declare function wrapError<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T): T;
|
|
47
47
|
/** The same as wrapError, but also logs the innerError, including the wrapping error's instance id */
|
|
48
|
-
export declare function wrapErrorAndLog<T extends
|
|
48
|
+
export declare function wrapErrorAndLog<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T, logger: ITelemetryLogger): T;
|
|
49
|
+
/**
|
|
50
|
+
* True for any error object that is either external itself or is a wrapped/normalized external error
|
|
51
|
+
* False for any error we created and raised within the FF codebase.
|
|
52
|
+
*/
|
|
53
|
+
export declare function originatedAsExternalError(e: any): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* True for any error object that is an (optionally normalized) external error
|
|
56
|
+
* False for any error we created and raised within the FF codebase, or wrapped in a well-known error type
|
|
57
|
+
*/
|
|
58
|
+
export declare function isExternalError(e: any): boolean;
|
|
49
59
|
/**
|
|
50
60
|
* Type guard to identify if a particular value (loosely) appears to be a tagged telemetry property
|
|
51
61
|
*/
|
|
@@ -66,7 +76,11 @@ export declare const getCircularReplacer: () => (key: string, value: any) => any
|
|
|
66
76
|
*/
|
|
67
77
|
export declare class LoggingError extends Error implements ILoggingError, Pick<IFluidErrorBase, "errorInstanceId"> {
|
|
68
78
|
private readonly omitPropsFromLogging;
|
|
69
|
-
|
|
79
|
+
private _errorInstanceId;
|
|
80
|
+
get errorInstanceId(): string;
|
|
81
|
+
overwriteErrorInstanceId(id: string): void;
|
|
82
|
+
/** Back-compat to appease isFluidError typeguard in old code that may handle this error */
|
|
83
|
+
private fluidErrorCode;
|
|
70
84
|
/**
|
|
71
85
|
* Create a new LoggingError
|
|
72
86
|
* @param message - Error message to use for Error base class
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorLogging.d.ts","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,aAAa,EACb,4BAA4B,EAC5B,gBAAgB,EAChB,oBAAoB,EACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAEH,eAAe,EAGlB,MAAM,kBAAkB,CAAC;AAO1B,sEAAsE;AACtE,wBAAgB,6BAA6B,CAAC,KAA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