@fluidframework/telemetry-utils 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
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 +18 -5
- package/dist/config.js.map +1 -1
- package/dist/debugLogger.d.ts.map +1 -1
- package/dist/debugLogger.js +12 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/errorLogging.d.ts +8 -7
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js +23 -20
- 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 +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +15 -4
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +69 -11
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.d.ts +12 -2
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +24 -2
- 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 +81 -0
- package/dist/telemetryTypes.d.ts.map +1 -0
- package/dist/telemetryTypes.js +7 -0
- package/dist/telemetryTypes.js.map +1 -0
- 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 +18 -5
- package/lib/config.js.map +1 -1
- package/lib/debugLogger.d.ts.map +1 -1
- package/lib/debugLogger.js +13 -2
- package/lib/debugLogger.js.map +1 -1
- package/lib/errorLogging.d.ts +8 -7
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js +23 -20
- 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 +3 -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 +15 -4
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +69 -12
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.d.ts +12 -2
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +24 -2
- 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 +81 -0
- package/lib/telemetryTypes.d.ts.map +1 -0
- package/lib/telemetryTypes.js +6 -0
- package/lib/telemetryTypes.js.map +1 -0
- 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 +49 -48
- package/prettier.config.cjs +1 -1
- package/src/config.ts +185 -173
- package/src/debugLogger.ts +128 -111
- package/src/errorLogging.ts +306 -300
- package/src/eventEmitterWithErrorHandling.ts +16 -12
- package/src/events.ts +26 -26
- package/src/fluidErrorBase.ts +42 -38
- package/src/index.ts +29 -9
- package/src/logger.ts +568 -500
- package/src/mockLogger.ts +118 -88
- package/src/packageVersion.ts +1 -1
- package/src/sampledTelemetryHelper.ts +122 -122
- package/src/telemetryTypes.ts +96 -0
- package/src/thresholdCounter.ts +34 -34
- package/src/utils.ts +15 -15
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
package/lib/errorLogging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorLogging.js","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACH,kBAAkB,EAElB,YAAY,EACZ,kBAAkB,GACrB,MAAM,kBAAkB,CAAC;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,MAAM,UAAU,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;SACvD;QACD,OAAO,WAAW,CAAC,IAAI,CAAC,IAA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AqB,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\";\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 value (loosely) appears to be a tagged telemetry property\n */\nexport function isTaggedTelemetryPropertyValue(x: any): x is ITaggedTelemetryPropertyType {\n return typeof (x?.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,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACN,kBAAkB,EAElB,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;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,MAAM,UAAU,6BAA6B,CAAC,KAAU,EAAE,aAAsB;IAC/E,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,SAAkB,EAAE,EAAE;QACpE,IAAI,CAAC,aAAa,EAAE;YACnB,OAAO,KAAK,CAAC;SACb;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;YAC5B,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB;SACpD;QACD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAA,KAAK,QAAQ,CAAC,CAAC,CAAE,KAAK,CAAC,OAAkB,CAAC,CAAC,CAAC,MAAM,CAAC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AC,gBAAgB,GAAG,EAAE,CAAC;IAC5B,CAAC;IA4BD;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,MAAe;QACtC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;YAClD,OAAO,CACN,OAAQ,MAAuB,CAAC,sBAAsB,KAAK,UAAU;gBACrE,OAAQ,MAAuB,CAAC,sBAAsB,KAAK,UAAU;gBACrE,OAAQ,MAAuB,CAAC,eAAe,KAAK,QAAQ,CAC5D,CAAC;SACF;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;OAEG;IACI,sBAAsB,CAAC,KAA2B;QACxD,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACI,sBAAsB;QAC5B,MAAM,aAAa,GAAG,sBAAsB,CAAC,IAAI,EAAE,IAAI,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;AAED,8DAA8D;AAC9D,MAAM,CAAC,MAAM,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,qBAAqB,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,OAAO,EAAE,iBAAiB,EAAyB,MAAM,8BAA8B,CAAC;AAExF;;;;GAIG;AACH,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"eventEmitterWithErrorHandling.js","sourceRoot":"","sources":["../src/eventEmitterWithErrorHandling.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAyB,MAAM,8BAA8B,CAAC;AAExF;;;;GAIG;AACH,MAAM,OAAO,6BAEX,SAAQ,iBAAyB;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","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/lib/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/lib/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;AAKH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAEpD,MAAM,UAAU,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;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAAwB,EACxB,OAAqB,EACrB,SAAkB,EAClB,QAAiB,EACjB,kBAA2B;IAE3B,IAAI;QACH,IAAI,SAAS,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;SAC3C;aAAM;YACN,OAAO,CAAC,IAAI,CAAC,qBAAqB,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","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/lib/fluidErrorBase.js
CHANGED
|
@@ -7,15 +7,15 @@ const hasTelemetryPropFunctions = (x) => typeof (x === null || x === void 0 ? vo
|
|
|
7
7
|
export const hasErrorInstanceId = (x) => typeof (x === null || x === void 0 ? void 0 : x.errorInstanceId) === "string";
|
|
8
8
|
/** type guard for IFluidErrorBase interface */
|
|
9
9
|
export function isFluidError(e) {
|
|
10
|
-
return typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
10
|
+
return (typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
11
11
|
typeof (e === null || e === void 0 ? void 0 : e.message) === "string" &&
|
|
12
12
|
hasErrorInstanceId(e) &&
|
|
13
|
-
hasTelemetryPropFunctions(e);
|
|
13
|
+
hasTelemetryPropFunctions(e));
|
|
14
14
|
}
|
|
15
15
|
/** type guard for old standard of valid/known errors */
|
|
16
16
|
export function isValidLegacyError(e) {
|
|
17
|
-
return typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
17
|
+
return (typeof (e === null || e === void 0 ? void 0 : e.errorType) === "string" &&
|
|
18
18
|
typeof (e === null || e === void 0 ? void 0 : e.message) === "string" &&
|
|
19
|
-
hasTelemetryPropFunctions(e);
|
|
19
|
+
hasTelemetryPropFunctions(e));
|
|
20
20
|
}
|
|
21
21
|
//# 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;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAM,EAAoC,EAAE,CAC9E,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,eAAe,CAAA,KAAK,QAAQ,CAAC;AAExC,+CAA+C;AAC/C,MAAM,UAAU,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,kBAAkB,CAAC,CAAC,CAAC;QACrB,yBAAyB,CAAC,CAAC,CAAC,CAC5B,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,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","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/lib/index.d.ts
CHANGED
|
@@ -6,11 +6,12 @@ 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";
|
|
14
14
|
export { SampledTelemetryHelper } from "./sampledTelemetryHelper";
|
|
15
15
|
export { logIfFalse } from "./utils";
|
|
16
|
+
export { TelemetryEventPropertyTypeExt, ITelemetryEventExt, ITelemetryGenericEventExt, ITelemetryErrorEventExt, ITelemetryPerformanceEventExt, ITelemetryLoggerExt, ITaggedTelemetryPropertyTypeExt, ITelemetryPropertiesExt, } from "./telemetryTypes";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/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/lib/index.js
CHANGED
|
@@ -6,8 +6,8 @@ export { sessionStorageConfigProvider, mixinMonitoringContext, loggerToMonitorin
|
|
|
6
6
|
export { DebugLogger } from "./debugLogger";
|
|
7
7
|
export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, 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, isFluidError, isValidLegacyError } from "./fluidErrorBase";
|
|
9
|
+
export { connectedEventName, disconnectedEventName, raiseConnectedEvent, safeRaiseEvent, } from "./events";
|
|
10
|
+
export { hasErrorInstanceId, isFluidError, isValidLegacyError, } from "./fluidErrorBase";
|
|
11
11
|
export { BaseTelemetryNullLogger, ChildLogger, MultiSinkLogger, PerformanceEvent, TaggedLoggerAdapter, TelemetryDataTag, TelemetryLogger, TelemetryNullLogger, TelemetryUTLogger, } from "./logger";
|
|
12
12
|
export { MockLogger } from "./mockLogger";
|
|
13
13
|
export { ThresholdCounter } from "./thresholdCounter";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAGN,4BAA4B,EAC5B,sBAAsB,EAGtB,yBAAyB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EAEnB,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,EAElB,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,WAAW,EAIX,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAEhB,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","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"]}
|
package/lib/logger.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryBaseEvent, ITelemetryBaseLogger, ITelemetryErrorEvent, ITelemetryGenericEvent, ITelemetryLogger, ITelemetryPerformanceEvent, ITelemetryProperties, TelemetryEventPropertyType, ITaggedTelemetryPropertyType, TelemetryEventCategory } from "@fluidframework/common-definitions";
|
|
6
|
+
import { ITaggedTelemetryPropertyTypeExt, ITelemetryGenericEventExt, ITelemetryLoggerExt, ITelemetryPerformanceEventExt, TelemetryEventPropertyTypeExt } from "./telemetryTypes";
|
|
6
7
|
/**
|
|
7
8
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
8
9
|
* Please do not modify existing entries for backwards compatibility.
|
|
@@ -26,7 +27,7 @@ export interface ITelemetryLoggerPropertyBags {
|
|
|
26
27
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
27
28
|
* Creates sub-logger that appends properties to all events
|
|
28
29
|
*/
|
|
29
|
-
export declare abstract class TelemetryLogger implements
|
|
30
|
+
export declare abstract class TelemetryLogger implements ITelemetryLoggerExt {
|
|
30
31
|
protected readonly namespace?: string | undefined;
|
|
31
32
|
protected readonly properties?: ITelemetryLoggerPropertyBags | undefined;
|
|
32
33
|
static readonly eventNamespaceSeparator = ":";
|
|
@@ -60,14 +61,14 @@ export declare abstract class TelemetryLogger implements ITelemetryLogger {
|
|
|
60
61
|
* @param event - the event to send
|
|
61
62
|
* @param error - optional error object to log
|
|
62
63
|
*/
|
|
63
|
-
sendTelemetryEvent(event:
|
|
64
|
+
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: any): void;
|
|
64
65
|
/**
|
|
65
66
|
* Send a telemetry event with the logger
|
|
66
67
|
*
|
|
67
68
|
* @param event - the event to send
|
|
68
69
|
* @param error - optional error object to log
|
|
69
70
|
*/
|
|
70
|
-
protected sendTelemetryEventCore(event:
|
|
71
|
+
protected sendTelemetryEventCore(event: ITelemetryGenericEventExt & {
|
|
71
72
|
category: TelemetryEventCategory;
|
|
72
73
|
}, error?: any): void;
|
|
73
74
|
/**
|
|
@@ -83,7 +84,7 @@ export declare abstract class TelemetryLogger implements ITelemetryLogger {
|
|
|
83
84
|
* @param event - Event to send
|
|
84
85
|
* @param error - optional error object to log
|
|
85
86
|
*/
|
|
86
|
-
sendPerformanceEvent(event:
|
|
87
|
+
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: any): void;
|
|
87
88
|
protected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent;
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
@@ -218,4 +219,14 @@ export declare class TelemetryNullLogger implements ITelemetryLogger {
|
|
|
218
219
|
sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void;
|
|
219
220
|
sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void;
|
|
220
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Takes in value, and does one of 4 things.
|
|
224
|
+
* if value is of primitive type - returns the original value.
|
|
225
|
+
* If the value is an array of primitives - returns a stringified version of the array.
|
|
226
|
+
* If the value is an object of type ITaggedTelemetryPropertyType - returns the object
|
|
227
|
+
* with its values recursively converted to base property Type.
|
|
228
|
+
* If none of these cases are reached - returns an error string
|
|
229
|
+
* @param x - value passed in to convert to a base property type
|
|
230
|
+
*/
|
|
231
|
+
export declare function convertToBasePropertyType(x: TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt): TelemetryEventPropertyType | ITaggedTelemetryPropertyType;
|
|
221
232
|
//# sourceMappingURL=logger.d.ts.map
|
package/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,0BAA0B,EAC1B,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,MAAM,oCAAoC,CAAC;AAS5C,OAAO,EACN,+BAA+B,EAE/B,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,oBAAY,gBAAgB;IAC3B,4FAA4F;IAC5F,YAAY,iBAAiB;IAC7B,8EAA8E;IAC9E,QAAQ,aAAa;CACrB;AAED,oBAAY,2BAA2B,GAAG,0BAA0B,GAAG,4BAA4B,CAAC;AAEpG,MAAM,WAAW,2BAA2B;IAC3C,CAAC,KAAK,EAAE,MAAM,GAAG,2BAA2B,GAAG,CAAC,MAAM,2BAA2B,CAAC,CAAC;CACnF;AACD,MAAM,WAAW,4BAA4B;IAC5C,GAAG,CAAC,EAAE,2BAA2B,CAAC;IAClC,KAAK,CAAC,EAAE,2BAA2B,CAAC;CACpC;AAED;;;;GAIG;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GAAG,IAAI;IAG/D,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,oBAAoB,GAAG,IAAI;IAGnE,UAAU,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,oBAAoB,GAAG,IAAI;IAIzE,OAAO,CAAC,WAAW;CASnB;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,oBAAoB;IACnE;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CAG7C;AAED;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,gBAAgB;IACpD,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IACtC,kBAAkB,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IACpE,cAAc,CAAC,KAAK,EAAE,oBAAoB,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAC9D,oBAAoB,CAAC,KAAK,EAAE,0BAA0B,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;CACjF;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACxC,CAAC,EAAE,6BAA6B,GAAG,+BAA+B,GAChE,0BAA0B,GAAG,4BAA4B,CAO3D"}
|
package/lib/logger.js
CHANGED
|
@@ -2,9 +2,20 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
6
|
+
var t = {};
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
10
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
11
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
12
|
+
t[p[i]] = s[p[i]];
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
5
16
|
import { performance } from "@fluidframework/common-utils";
|
|
6
|
-
import { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext
|
|
7
|
-
import { isILoggingError, extractLogSafeErrorProperties, generateStack, } from "./errorLogging";
|
|
17
|
+
import { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext } from "./config";
|
|
18
|
+
import { isILoggingError, extractLogSafeErrorProperties, generateStack, isTaggedTelemetryPropertyValue, } from "./errorLogging";
|
|
8
19
|
/**
|
|
9
20
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
10
21
|
* Please do not modify existing entries for backwards compatibility.
|
|
@@ -91,7 +102,7 @@ export class TelemetryLogger {
|
|
|
91
102
|
* @param error - optional error object to log
|
|
92
103
|
*/
|
|
93
104
|
sendTelemetryEventCore(event, error) {
|
|
94
|
-
const newEvent =
|
|
105
|
+
const newEvent = convertToBaseEvent(event);
|
|
95
106
|
if (error !== undefined) {
|
|
96
107
|
TelemetryLogger.prepareErrorObject(newEvent, error, false);
|
|
97
108
|
}
|
|
@@ -172,7 +183,7 @@ export class TaggedLoggerAdapter {
|
|
|
172
183
|
};
|
|
173
184
|
for (const key of Object.keys(eventWithTagsMaybe)) {
|
|
174
185
|
const taggableProp = eventWithTagsMaybe[key];
|
|
175
|
-
const { value, tag } =
|
|
186
|
+
const { value, tag } = typeof taggableProp === "object"
|
|
176
187
|
? taggableProp
|
|
177
188
|
: { value: taggableProp, tag: undefined };
|
|
178
189
|
switch (tag) {
|
|
@@ -298,6 +309,7 @@ export class MultiSinkLogger extends TelemetryLogger {
|
|
|
298
309
|
*/
|
|
299
310
|
export class PerformanceEvent {
|
|
300
311
|
constructor(logger, event, markers = { end: true, cancel: "generic" }) {
|
|
312
|
+
var _a;
|
|
301
313
|
this.logger = logger;
|
|
302
314
|
this.markers = markers;
|
|
303
315
|
this.startTime = performance.now();
|
|
@@ -305,7 +317,7 @@ export class PerformanceEvent {
|
|
|
305
317
|
if (this.markers.start) {
|
|
306
318
|
this.reportEvent("start");
|
|
307
319
|
}
|
|
308
|
-
if (typeof window === "object" && window != null && window.performance) {
|
|
320
|
+
if (typeof window === "object" && window != null && ((_a = window.performance) === null || _a === void 0 ? void 0 : _a.mark)) {
|
|
309
321
|
this.startMark = `${event.eventName}-start`;
|
|
310
322
|
window.performance.mark(this.startMark);
|
|
311
323
|
}
|
|
@@ -337,7 +349,9 @@ export class PerformanceEvent {
|
|
|
337
349
|
throw error;
|
|
338
350
|
}
|
|
339
351
|
}
|
|
340
|
-
get duration() {
|
|
352
|
+
get duration() {
|
|
353
|
+
return performance.now() - this.startTime;
|
|
354
|
+
}
|
|
341
355
|
reportProgress(props, eventNameSuffix = "update") {
|
|
342
356
|
this.reportEvent(eventNameSuffix, props);
|
|
343
357
|
}
|
|
@@ -391,15 +405,12 @@ export class PerformanceEvent {
|
|
|
391
405
|
* It can be used in places where logger instance is required, but events should be not send over.
|
|
392
406
|
*/
|
|
393
407
|
export class TelemetryUTLogger {
|
|
394
|
-
send(event) {
|
|
395
|
-
}
|
|
396
|
-
sendTelemetryEvent(event, error) {
|
|
397
|
-
}
|
|
408
|
+
send(event) { }
|
|
409
|
+
sendTelemetryEvent(event, error) { }
|
|
398
410
|
sendErrorEvent(event, error) {
|
|
399
411
|
this.reportError("errorEvent in UT logger!", event, error);
|
|
400
412
|
}
|
|
401
|
-
sendPerformanceEvent(event, error) {
|
|
402
|
-
}
|
|
413
|
+
sendPerformanceEvent(event, error) { }
|
|
403
414
|
logGenericError(eventName, error) {
|
|
404
415
|
this.reportError(`genericError in UT logger!`, { eventName }, error);
|
|
405
416
|
}
|
|
@@ -446,4 +457,50 @@ export class TelemetryNullLogger {
|
|
|
446
457
|
sendErrorEvent(event, error) { }
|
|
447
458
|
sendPerformanceEvent(event, error) { }
|
|
448
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Takes in an event object, and converts all of its values to a basePropertyType.
|
|
462
|
+
* In the case of an invalid property type, the value will be converted to an error string.
|
|
463
|
+
* @param event - Event with fields you want to stringify.
|
|
464
|
+
*/
|
|
465
|
+
function convertToBaseEvent(_a) {
|
|
466
|
+
var { category, eventName } = _a, props = __rest(_a, ["category", "eventName"]);
|
|
467
|
+
const newEvent = { category, eventName };
|
|
468
|
+
for (const key of Object.keys(props)) {
|
|
469
|
+
newEvent[key] = convertToBasePropertyType(props[key]);
|
|
470
|
+
}
|
|
471
|
+
return newEvent;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Takes in value, and does one of 4 things.
|
|
475
|
+
* if value is of primitive type - returns the original value.
|
|
476
|
+
* If the value is an array of primitives - returns a stringified version of the array.
|
|
477
|
+
* If the value is an object of type ITaggedTelemetryPropertyType - returns the object
|
|
478
|
+
* with its values recursively converted to base property Type.
|
|
479
|
+
* If none of these cases are reached - returns an error string
|
|
480
|
+
* @param x - value passed in to convert to a base property type
|
|
481
|
+
*/
|
|
482
|
+
export function convertToBasePropertyType(x) {
|
|
483
|
+
return isTaggedTelemetryPropertyValue(x)
|
|
484
|
+
? {
|
|
485
|
+
value: convertToBasePropertyTypeUntagged(x.value),
|
|
486
|
+
tag: x.tag,
|
|
487
|
+
}
|
|
488
|
+
: convertToBasePropertyTypeUntagged(x);
|
|
489
|
+
}
|
|
490
|
+
function convertToBasePropertyTypeUntagged(x) {
|
|
491
|
+
switch (typeof x) {
|
|
492
|
+
case "string":
|
|
493
|
+
case "number":
|
|
494
|
+
case "boolean":
|
|
495
|
+
case "undefined":
|
|
496
|
+
return x;
|
|
497
|
+
case "object":
|
|
498
|
+
// We assume this is an array based on the input types
|
|
499
|
+
return JSON.stringify(x);
|
|
500
|
+
default:
|
|
501
|
+
// should never reach this case based on the input types
|
|
502
|
+
console.error(`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`);
|
|
503
|
+
return `INVALID PROPERTY (typed as ${typeof x})`;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
449
506
|
//# sourceMappingURL=logger.js.map
|