🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

@fluidframework/telemetry-utils

Package Overview
Dependencies
Maintainers
1
Versions
670
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluidframework/telemetry-utils - npm Package Compare versions

Comparing version
2.100.0
to
2.101.0
+2
-2
api-report/telemetry-utils.legacy.beta.api.md

@@ -37,5 +37,5 @@ ## Beta API Report File for "@fluidframework/telemetry-utils"

// @deprecated
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
// @deprecated
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
}

@@ -42,0 +42,0 @@

# @fluidframework/telemetry-utils
## 2.101.0
Dependency updates only.
## 2.100.0

@@ -4,0 +8,0 @@

@@ -1,1 +0,1 @@

{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEnF;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC3D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAC9C,SAAS,CAAC,I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AG,iBAAiB,CAAC,CAAC,CAAC,CAGjC;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,oBAAoB,GAAG,kBAAkB,EAC5F,MAAM,EAAE,CAAC,GACP,iBAAiB,CAAC,CAAC,CAAC,CAKtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,oBAAoB,GAAG,kBAAkB,EACzF,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,GAC7C,iBAAiB,CAAC,CAAC,CAAC,CAkBtB;AAOD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAC5C,iBAAiB,CAEnB;AAED;;KAEK;AACL,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,IAAI;KAClD,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAC9B,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,MAAM,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAC3E,SAAS;CACZ,CAAC;AAEF;;;;;;;;;;KAUK;AACL,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,MAAM,EAC7D,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,EACrC,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACzB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CA6BtB"}

@@ -8,2 +8,3 @@ "use strict";

exports.createConfigBasedOptionsProxy = exports.createChildMonitoringContext = exports.mixinMonitoringContext = exports.loggerToMonitoringContext = exports.loggerIsMonitoringContext = exports.CachedConfigProvider = exports.wrapConfigProviderWithDefaults = exports.inMemoryConfigProvider = exports.sessionStorageConfigProvider = void 0;
const core_interfaces_1 = require("@fluidframework/core-interfaces");
const internal_1 = require("@fluidframework/core-utils/internal");

@@ -206,3 +207,3 @@ const logger_js_1 = require("./logger.js");

}),
});
}, core_interfaces_1.LogLevel.info);
return parsed;

@@ -209,0 +210,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,kEAA2D;AAE3D,2CAAkE;AAgBlE;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG,IAAI,eAAI,CAAsB,GAAG,EAAE,CAC9E,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE;YAC1C,YAAY,EAAE,CAAC,IAAY,EAA2B,EAAE;gBACvD,IAAI,CAAC;oBACJ,OAAO,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,GAAG,CAAC;gBACpE,CAAC;gBAAC,MAAM,CAAC;oBACR,OAAO,SAAS,CAAC;gBAClB,CAAC;YACF,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC3B,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC;AAaF,SAAS,eAAe,CAAC,IAAY;IACpC,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC,CAAC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C;IAEH,OAAO,IAAI,KAAK,CAAa,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAC/C,GAAG,EAAE,CAAC,CAAC,EAAE,IAAsB,EAAW,EAAE;YAC3C,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,yDAAyD;QACzD,sDAAsD;QACtD,oDAAoD;QACpD,0BAA0B;QAC1B,OAAO,EAAE,GAAwB,EAAE;YAClC,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAC7D,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAlCD,sEAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tConfigTypes,\n\tIConfigProviderBase,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger, tagCodeArtifacts } from \"./logger.js\";\nimport type { ITelemetryLoggerExt, TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Creates a wrapper on top of an existing config provider which allows for\n * specifying feature gates if not present in the original provider.\n *\n * @param original - the original config provider\n * @param defaults - default feature gate configs to be used if not specified by the original provider\n * @returns A config provider that looks for any requested feature gates in the original provider and falls\n * back to the values specified in the `defaults` feature gates if they're not present in the original.\n *\n * @internal\n */\nexport const wrapConfigProviderWithDefaults = (\n\toriginal: IConfigProviderBase | undefined,\n\tdefaults: Record<string, ConfigTypes>,\n): IConfigProviderBase => ({\n\tgetRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],\n});\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tpublic constructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic getBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tpublic getNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tpublic getString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tpublic getBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tpublic getNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tpublic getStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tpublic getRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send({\n\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\t// Since this is an internal context, assume that any external logger type\n\t// (`ITelemetryLoggerExt`) is just the internal `TelemetryLoggerExt` type.\n\t// `extractTelemetryLoggerExt` can be used to extract the internal type, but\n\t// we'll just \"cast\" it here.\n\tlogger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\t// Cast is similar to `extractTelemetryLoggerExt` but preserves other\n\t// logger types rather than just returning `TelemetryLoggerExt`.\n\tmc.logger = logger as L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n\n/**\n * @internal\n * */\nexport type OptionConfigReaders<T extends object> = {\n\t[K in keyof T]?: K extends string\n\t\t? (config: IConfigProvider, name: `Fluid.${string}.${K}`) => T[K] | undefined\n\t\t: undefined;\n};\n\n/**\n * Creates a proxy object that allows for reading configuration values from a IConfigProviderBase,\n * and default to the provided options if the configuration value is not present.\n *\n * @param config - the configuration provider to read values from.\n * @param namespace - the namespace to use when reading configuration values.\n * @param configReaders - a mapping of option keys to configuration value readers.\n * @param defaultOptions - the default options to use if the configuration value is not present.\n *\n * @internal\n * */\nexport function createConfigBasedOptionsProxy<T extends object>(\n\tconfig: IConfigProviderBase,\n\tnamespace: `Fluid.${string}`,\n\tconfigReaders: OptionConfigReaders<T>,\n\tdefaultOptions?: Partial<T>,\n): Readonly<Partial<T>> {\n\tconst realConfig =\n\t\tconfig instanceof CachedConfigProvider\n\t\t\t? config\n\t\t\t: new CachedConfigProvider(undefined, config);\n\n\tconst keys = new Set<string>([\n\t\t...Object.keys(defaultOptions ?? {}),\n\t\t...Object.keys(configReaders),\n\t]);\n\n\treturn new Proxy<Partial<T>>(Object.freeze({}), {\n\t\tget: (_, prop: string & keyof T): unknown => {\n\t\t\tconst reader = configReaders[prop];\n\t\t\tconst value = reader?.(realConfig, `${namespace}.${prop}`);\n\t\t\tif (value !== undefined) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\treturn defaultOptions?.[prop];\n\t\t},\n\t\thas: (_, prop: string): boolean => keys.has(prop),\n\t\t// we don't want the keys of this object to be enumerable\n\t\t// as accessing them will trigger a config read, which\n\t\t// should only happen when the value is accessed via\n\t\t// a previously known key.\n\t\townKeys: (): (string | symbol)[] => {\n\t\t\tthrow new TypeError(\"OptionsProxy keys are not enumerable\");\n\t\t},\n\t});\n}\n"]}
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,qEAA2D;AAC3D,kEAA2D;AAE3D,2CAAkE;AAgBlE;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG,IAAI,eAAI,CAAsB,GAAG,EAAE,CAC9E,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE;YAC1C,YAAY,EAAE,CAAC,IAAY,EAA2B,EAAE;gBACvD,IAAI,CAAC;oBACJ,OAAO,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,GAAG,CAAC;gBACpE,CAAC;gBAAC,MAA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EACrC,cAA2B;IAE3B,MAAM,UAAU,GACf,MAAM,YAAY,oBAAoB;QACrC,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,IAAI,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAEhD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAS;QAC5B,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC;QACpC,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;KAC7B,CAAC,CAAC;IAEH,OAAO,IAAI,KAAK,CAAa,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAC/C,GAAG,EAAE,CAAC,CAAC,EAAE,IAAsB,EAAW,EAAE;YAC3C,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,yDAAyD;QACzD,sDAAsD;QACtD,oDAAoD;QACpD,0BAA0B;QAC1B,OAAO,EAAE,GAAwB,EAAE;YAClC,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAC7D,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAlCD,sEAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tConfigTypes,\n\tIConfigProviderBase,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger, tagCodeArtifacts } from \"./logger.js\";\nimport type { ITelemetryLoggerExt, TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Creates a wrapper on top of an existing config provider which allows for\n * specifying feature gates if not present in the original provider.\n *\n * @param original - the original config provider\n * @param defaults - default feature gate configs to be used if not specified by the original provider\n * @returns A config provider that looks for any requested feature gates in the original provider and falls\n * back to the values specified in the `defaults` feature gates if they're not present in the original.\n *\n * @internal\n */\nexport const wrapConfigProviderWithDefaults = (\n\toriginal: IConfigProviderBase | undefined,\n\tdefaults: Record<string, ConfigTypes>,\n): IConfigProviderBase => ({\n\tgetRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],\n});\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tpublic constructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic getBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tpublic getNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tpublic getString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tpublic getBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tpublic getNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tpublic getStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tpublic getRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tLogLevel.info,\n\t\t\t\t\t);\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\t// Since this is an internal context, assume that any external logger type\n\t// (`ITelemetryLoggerExt`) is just the internal `TelemetryLoggerExt` type.\n\t// `extractTelemetryLoggerExt` can be used to extract the internal type, but\n\t// we'll just \"cast\" it here.\n\tlogger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\t// Cast is similar to `extractTelemetryLoggerExt` but preserves other\n\t// logger types rather than just returning `TelemetryLoggerExt`.\n\tmc.logger = logger as L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n\n/**\n * @internal\n * */\nexport type OptionConfigReaders<T extends object> = {\n\t[K in keyof T]?: K extends string\n\t\t? (config: IConfigProvider, name: `Fluid.${string}.${K}`) => T[K] | undefined\n\t\t: undefined;\n};\n\n/**\n * Creates a proxy object that allows for reading configuration values from a IConfigProviderBase,\n * and default to the provided options if the configuration value is not present.\n *\n * @param config - the configuration provider to read values from.\n * @param namespace - the namespace to use when reading configuration values.\n * @param configReaders - a mapping of option keys to configuration value readers.\n * @param defaultOptions - the default options to use if the configuration value is not present.\n *\n * @internal\n * */\nexport function createConfigBasedOptionsProxy<T extends object>(\n\tconfig: IConfigProviderBase,\n\tnamespace: `Fluid.${string}`,\n\tconfigReaders: OptionConfigReaders<T>,\n\tdefaultOptions?: Partial<T>,\n): Readonly<Partial<T>> {\n\tconst realConfig =\n\t\tconfig instanceof CachedConfigProvider\n\t\t\t? config\n\t\t\t: new CachedConfigProvider(undefined, config);\n\n\tconst keys = new Set<string>([\n\t\t...Object.keys(defaultOptions ?? {}),\n\t\t...Object.keys(configReaders),\n\t]);\n\n\treturn new Proxy<Partial<T>>(Object.freeze({}), {\n\t\tget: (_, prop: string & keyof T): unknown => {\n\t\t\tconst reader = configReaders[prop];\n\t\t\tconst value = reader?.(realConfig, `${namespace}.${prop}`);\n\t\t\tif (value !== undefined) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\treturn defaultOptions?.[prop];\n\t\t},\n\t\thas: (_, prop: string): boolean => keys.has(prop),\n\t\t// we don't want the keys of this object to be enumerable\n\t\t// as accessing them will trigger a config read, which\n\t\t// should only happen when the value is accessed via\n\t\t// a previously known key.\n\t\townKeys: (): (string | symbol)[] => {\n\t\t\tthrow new TypeError(\"OptionsProxy keys are not enumerable\");\n\t\t},\n\t});\n}\n"]}

@@ -7,3 +7,3 @@ /*!

import type { ITelemetryLoggerExt, ITelemetryPropertiesExt, TelemetryLoggerExt, TelemetryEventPropertyTypeExt } from "./telemetryTypes.js";
import type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryPerformanceEventExt, TelemetryEventCategory } from "./telemetryTypesUndeprecated.js";
import type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryPerformanceEventExt } from "./telemetryTypesUndeprecated.js";
/**

@@ -123,6 +123,6 @@ * Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
/**

@@ -133,7 +133,5 @@ * Send a telemetry event with the logger

* @param error - optional error object to log
* @param logLevel - optional level of the log.
* @param logLevel - level of the log.
*/
protected sendTelemetryEventCore(event: ITelemetryGenericEventExt & {
category: TelemetryEventCategory;
}, error?: unknown, logLevel?: LogLevel): void;
private sendTelemetryEventCore;
/**

@@ -151,6 +149,6 @@ * Send an error telemetry event with the logger

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
protected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent;

@@ -279,3 +277,3 @@ private extendProperties;

*/
send(event: ITelemetryBaseEvent): void;
send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;
}

@@ -307,2 +305,3 @@ /**

private readonly emitLogs;
private readonly logLevel;
/**

@@ -316,5 +315,7 @@ * Creates an instance of {@link PerformanceEvent} and starts measurements

* but measurements will still be performed and any specified markers will be generated.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns An instance of {@link PerformanceEvent}
*/
static start(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean): PerformanceEvent;
static start(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): PerformanceEvent;
/**

@@ -328,2 +329,4 @@ * Measure a synchronous task

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -336,3 +339,3 @@ *

*/
static timedExec<T>(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number): T;
static timedExec<T>(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): T;
/**

@@ -347,2 +350,4 @@ * Measure an asynchronous task

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -355,3 +360,3 @@ *

*/
static timedExecAsync<T>(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, sampleThreshold?: number): Promise<T>;
static timedExecAsync<T>(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): Promise<T>;
get duration(): number;

@@ -361,3 +366,3 @@ private event?;

private startMark?;
protected constructor(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean);
private constructor();
reportProgress(props?: ITelemetryPropertiesExt, eventNameSuffix?: string): void;

@@ -364,0 +369,0 @@ private autoEnd;

@@ -1,1 +0,1 @@

{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,QAAQ,EACR,KAAK,MAAM,EACX,KAAK,8BAA8B,EACnC,MAAM,iCAAiC,CAAC;AAazC,OAAO,KAAK,EAEX,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,MAAM,iCAAiC,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,mBAAmB,CAErF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,SAAS;IACf,iBAAiB,CAAC,EAAE,IAAI,CAAC;CACzB,GACD,EAAE,EAEF,KAAK,EACF,mBAAmB,GACnB,kBAAkB,GAClB,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,GAChE,kBAAkB,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,CAEtF;AAED;;;;;;GAMG;AACH,oBAAY,gBAAgB;IAC3B;;OAE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BAAyB,CACxC,CAAC,EAAE,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAC,GACtE,8BAA8B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAOzE;AA0BD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,OAAO,gGAIsB,8BAA8B,SAGlE,CAAC,UACE,CAAC,2CAGc,8BAA8B;;SAG3C,CAAC;;;SAID,CAAC;oDAoB0B,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,gBAAgB,oEAGa,8BAA8B,YAG/D,CAAC,2CAGc,8BAA8B;;SAG3C,iBAAiB,YAAY;;;SAI7B,iBAAiB,YAAY;oDAG6C,CAAC"}

@@ -137,7 +137,7 @@ "use strict";

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendTelemetryEvent(event, error, logLevel = core_interfaces_1.LogLevel.default) {
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? core_interfaces_1.LogLevel.error : logLevel);
sendTelemetryEvent(event, error, logLevel) {
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? core_interfaces_1.LogLevel.essential : (logLevel ?? core_interfaces_1.LogLevel.essential));
}

@@ -149,3 +149,3 @@ /**

* @param error - optional error object to log
* @param logLevel - optional level of the log.
* @param logLevel - level of the log.
*/

@@ -176,3 +176,3 @@ sendTelemetryEventCore(event, error, logLevel) {

category: "error",
}, error, core_interfaces_1.LogLevel.error);
}, error, core_interfaces_1.LogLevel.essential);
}

@@ -184,6 +184,6 @@ /**

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendPerformanceEvent(event, error, logLevel = core_interfaces_1.LogLevel.default) {
sendPerformanceEvent(event, error, logLevel) {
const perfEvent = {

@@ -193,3 +193,3 @@ ...event,

};
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? core_interfaces_1.LogLevel.error : logLevel);
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? core_interfaces_1.LogLevel.essential : (logLevel ?? core_interfaces_1.LogLevel.essential));
}

@@ -376,4 +376,4 @@ prepareEvent(event) {

shouldFilterOutEvent(event, logLevel) {
const eventLogLevel = logLevel ?? core_interfaces_1.LogLevel.default;
const configLogLevel = this.baseLogger.minLogLevel ?? core_interfaces_1.LogLevel.default;
const eventLogLevel = logLevel ?? core_interfaces_1.LogLevel.essential;
const configLogLevel = this.baseLogger.minLogLevel ?? core_interfaces_1.LogLevel.info;
// Filter out in case event log level is below what is wanted in config.

@@ -391,3 +391,3 @@ return eventLogLevel < configLogLevel;

}
this.baseLogger.send(this.prepareEvent(event), logLevel);
this.baseLogger.send(this.prepareEvent(event), logLevel ?? core_interfaces_1.LogLevel.essential);
}

@@ -435,3 +435,3 @@ }

this.loggers = loggers;
this._minLogLevelOfAllLoggers = core_interfaces_1.LogLevel.default;
this._minLogLevelOfAllLoggers = core_interfaces_1.LogLevel.info;
this.calculateMinLogLevel();

@@ -446,3 +446,3 @@ }

for (const logger of this.loggers) {
logLevels.push(logger.minLogLevel ?? core_interfaces_1.LogLevel.default);
logLevels.push(logger.minLogLevel ?? core_interfaces_1.LogLevel.info);
}

@@ -468,6 +468,6 @@ this._minLogLevelOfAllLoggers = Math.min(...logLevels);

*/
send(event) {
send(event, logLevel) {
const newEvent = this.prepareEvent(event);
for (const logger of this.loggers) {
logger.send(newEvent);
logger.send(newEvent, logLevel ?? core_interfaces_1.LogLevel.essential);
}

@@ -491,6 +491,8 @@ }

* but measurements will still be performed and any specified markers will be generated.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns An instance of {@link PerformanceEvent}
*/
static start(logger, event, markers, emitLogs = true) {
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs);
static start(logger, event, markers, emitLogs = true, logLevel) {
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs, logLevel);
}

@@ -505,2 +507,4 @@ /**

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -513,4 +517,4 @@ *

*/
static timedExec(logger, event, callback, markers, sampleThreshold = 1) {
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
static timedExec(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
try {

@@ -535,2 +539,4 @@ const ret = callback(perfEvent);

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -543,4 +549,4 @@ *

*/
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1) {
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
try {

@@ -559,6 +565,7 @@ const ret = await callback(perfEvent);

}
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true) {
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true, logLevel) {
this.logger = logger;
this.markers = markers;
this.emitLogs = emitLogs;
this.logLevel = logLevel;
this.startTime = (0, client_utils_1.performanceNow)();

@@ -626,3 +633,3 @@ this.event = { ...event };

}
this.logger.sendPerformanceEvent(event, error);
this.logger.sendPerformanceEvent(event, error, this.logLevel);
}

@@ -629,0 +636,0 @@ static shouldReport(event, sampleThreshold) {

@@ -1,1 +0,1 @@

{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,qEAMyC;AAEzC,2CAIqB;AACrB,uDAK2B;AAe3B;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,MAA0B;IAC/D,OAAO,MAAwC,CAAC;AACjD,CAAC;AAFD,sDAEC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,yBAAyB,CAMxC,KAGkE;IAElE,OAAO,KAAsC,CAAC;AAC/C,CAAC;AAZD,8DAYC;AAED;;;;;;GAMG;AACH,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC3B;;OAEG;IACH,iDAA6B,CAAA;IAC7B;;OAEG;IACH,yCAAqB,CAAA;AACtB,CAAC,EATW,gBAAgB,gCAAhB,gBAAgB,QAS3B;AA6BD;;;;;;;;;GASG;AACH,kDAAkD;AAClD,SAAgB,gBAAgB,CAAC,GAA8B;IAC9D,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACvC,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACtC,CAAC;AAND,4CAMC;AAED,iBAAiB;AACjB,qDAAqD;AACrD;;GAEG;AACH,SAAgB,UAAU,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,KAAK,C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MAAS,EAaR,EAAE,CAAC,IAAA,eAAO,EAAmC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAnBzE,QAAA,gBAAgB,oBAmByD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport {\n\ttype ITelemetryBaseEvent,\n\ttype ITelemetryBaseLogger,\n\tLogLevel,\n\ttype Tagged,\n\ttype TelemetryBaseEventPropertyType,\n} from \"@fluidframework/core-interfaces\";\n\nimport {\n\tCachedConfigProvider,\n\tloggerIsMonitoringContext,\n\tmixinMonitoringContext,\n} from \"./config.js\";\nimport {\n\textractLogSafeErrorProperties,\n\tgenerateStack,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n} from \"./errorLogging.js\";\nimport type {\n\tITelemetryEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n\tTelemetryLoggerExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes.js\";\nimport type {\n\tITelemetryErrorEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.\n * @internal\n */\nexport function toITelemetryLoggerExt(logger: TelemetryLoggerExt): ITelemetryLoggerExt {\n\treturn logger as unknown as ITelemetryLoggerExt;\n}\n\n/**\n * Un-type-erase the {@link ITelemetryLoggerExt}.\n * @remarks\n * This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.\n *\n * @typeParam options - options for the extraction, currently only supports making\n * the output possibly undefined (when `PossiblyUndefined: true`), which is useful\n * for cases where we want to allow passing `undefined` through.\n *\n * @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will\n * be when the breaking change is made. At that time, use of this helper will be\n * required.\n *\n * @internal\n */\nexport function extractTelemetryLoggerExt<\n\toptions extends {\n\t\tPossiblyUndefined?: true;\n\t} = // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty object without PossiblyUndefined is the correct type\n\t{},\n>(\n\tinput:\n\t\t| ITelemetryLoggerExt\n\t\t| TelemetryLoggerExt\n\t\t| (options[\"PossiblyUndefined\"] extends true ? undefined : never),\n): TelemetryLoggerExt | (options[\"PossiblyUndefined\"] extends true ? undefined : never) {\n\treturn input as unknown as TelemetryLoggerExt;\n}\n\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n *\n * @privateRemarks Please do not modify existing entries, to maintain backwards compatibility.\n *\n * @internal\n */\nexport enum TelemetryDataTag {\n\t/**\n\t * Data containing terms or IDs from code packages that may have been dynamically loaded\n\t */\n\tCodeArtifact = \"CodeArtifact\",\n\t/**\n\t * Personal data of a variety of classifications that pertains to the user\n\t */\n\tUserData = \"UserData\",\n}\n\n/**\n * @legacy\n * @beta\n */\nexport type TelemetryEventPropertyTypes = ITelemetryPropertiesExt[string];\n\n/**\n * @legacy\n * @beta\n */\nexport type ITelemetryLoggerPropertyBag = Record<\n\tstring,\n\tTelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes)\n>;\n\n/**\n * @legacy\n * @beta\n *\n * @privateRemarks\n * This is exposed to support {@link createChildLogger} properties parameter.\n */\nexport interface ITelemetryLoggerPropertyBags {\n\tall?: ITelemetryLoggerPropertyBag;\n\terror?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * Attempts to parse number from string.\n * If it fails, it will return the original string.\n *\n * @remarks\n * Used to make telemetry data typed (and support math operations, like comparison),\n * in places where we do expect numbers (like contentsize/duration property in http header).\n *\n * @internal\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function numberFromString(str: string | null | undefined): string | number | undefined {\n\tif (str === undefined || str === null) {\n\t\treturn undefined;\n\t}\n\tconst num = Number(str);\n\treturn Number.isNaN(num) ? str : num;\n}\n\n// TODO: add docs\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function formatTick(tick: number): number {\n\treturn Math.floor(tick);\n}\n\n/**\n * String used to concatenate the namespace of parent loggers and their child loggers.\n * @internal\n */\nexport const eventNamespaceSeparator = \":\";\n\n/**\n * TelemetryLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport abstract class TelemetryLogger implements TelemetryLoggerExt {\n\t/**\n\t * {@inheritDoc eventNamespaceSeparator}\n\t */\n\tpublic static readonly eventNamespaceSeparator = eventNamespaceSeparator;\n\n\tpublic static sanitizePkgName(name: string): string {\n\t\treturn name.replace(\"@\", \"\").replace(\"/\", \"-\");\n\t}\n\n\t/**\n\t * Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied\n\t * over from the error object, along with other telemetry properties if it's an ILoggingError.\n\t * @param event - Event being logged\n\t * @param error - Error to extract info from\n\t * @param fetchStack - Whether to fetch the current callstack if error.stack is undefined\n\t */\n\tpublic static prepareErrorObject(\n\t\tevent: ITelemetryBaseEvent,\n\t\terror: unknown,\n\t\tfetchStack: boolean,\n\t): void {\n\t\tconst { message, errorType, stack } = extractLogSafeErrorProperties(\n\t\t\terror,\n\t\t\ttrue /* sanitizeStack */,\n\t\t);\n\t\t// First, copy over error message, stack, and errorType directly (overwrite if present on event)\n\t\tevent.stack = stack;\n\t\tevent.error = message; // Note that the error message goes on the 'error' field\n\t\tevent.errorType = errorType;\n\n\t\tif (isILoggingError(error)) {\n\t\t\t// Add any other telemetry properties from the LoggingError\n\t\t\tconst telemetryProp = error.getTelemetryProperties();\n\t\t\tfor (const key of Object.keys(telemetryProp)) {\n\t\t\t\tif (event[key] !== undefined) {\n\t\t\t\t\t// Don't overwrite existing properties on the event\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tevent[key] = telemetryProp[key];\n\t\t\t}\n\t\t}\n\n\t\t// Collect stack if we were not able to extract it from error\n\t\tif (event.stack === undefined && fetchStack) {\n\t\t\tevent.stack = generateStack();\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprotected readonly namespace?: string,\n\t\tprotected readonly properties?: ITelemetryLoggerPropertyBags,\n\t) {}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic abstract send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log. It category of event is set as error,\n\t * then the logLevel will be upgraded to be an error.\n\t */\n\tpublic sendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default,\n\t): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{ ...event, category: event.category ?? \"generic\" },\n\t\t\terror,\n\t\t\tevent.category === \"error\" ? LogLevel.error : logLevel,\n\t\t);\n\t}\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log.\n\t */\n\tprotected sendTelemetryEventCore(\n\t\tevent: ITelemetryGenericEventExt & { category: TelemetryEventCategory },\n\t\terror?: unknown,\n\t\tlogLevel?: LogLevel,\n\t): void {\n\t\tconst newEvent = convertToBaseEvent(event);\n\t\tif (error !== undefined) {\n\t\t\tTelemetryLogger.prepareErrorObject(newEvent, error, false);\n\t\t}\n\n\t\t// Will include Nan & Infinity, but probably we do not care\n\t\tif (typeof newEvent.duration === \"number\") {\n\t\t\tnewEvent.duration = formatTick(newEvent.duration);\n\t\t}\n\n\t\tthis.send(newEvent, logLevel);\n\t}\n\n\t/**\n\t * Send an error telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{\n\t\t\t\t// ensure the error field has some value,\n\t\t\t\t// this can and will be overridden by event, or error\n\t\t\t\terror: event.eventName,\n\t\t\t\t...event,\n\t\t\t\tcategory: \"error\",\n\t\t\t},\n\t\t\terror,\n\t\t\tLogLevel.error,\n\t\t);\n\t}\n\n\t/**\n\t * Send a performance telemetry event with the logger\n\t *\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log. It category of event is set as error,\n\t * then the logLevel will be upgraded to be an error.\n\t */\n\tpublic sendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default,\n\t): void {\n\t\tconst perfEvent = {\n\t\t\t...event,\n\t\t\tcategory: event.category ?? \"performance\",\n\t\t};\n\n\t\tthis.sendTelemetryEventCore(\n\t\t\tperfEvent,\n\t\t\terror,\n\t\t\tperfEvent.category === \"error\" ? LogLevel.error : logLevel,\n\t\t);\n\t}\n\n\tprotected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent {\n\t\tconst includeErrorProps = event.category === \"error\" || event.error !== undefined;\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\t...event,\n\t\t};\n\t\tif (this.namespace !== undefined) {\n\t\t\tnewEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;\n\t\t}\n\t\treturn this.extendProperties(newEvent, includeErrorProps);\n\t}\n\n\tprivate extendProperties<\n\t\tT extends ITelemetryLoggerPropertyBag = ITelemetryLoggerPropertyBag,\n\t>(toExtend: T, includeErrorProps: boolean): T {\n\t\tconst eventLike: ITelemetryLoggerPropertyBag = toExtend;\n\t\tif (this.properties) {\n\t\t\tconst properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];\n\t\t\tproperties.push(this.properties.all);\n\t\t\tif (includeErrorProps) {\n\t\t\t\tproperties.push(this.properties.error);\n\t\t\t}\n\t\t\tfor (const props of properties) {\n\t\t\t\tif (props !== undefined) {\n\t\t\t\t\tfor (const [key, getterOrValue] of Object.entries(props)) {\n\t\t\t\t\t\tif (eventLike[key] !== undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If this throws, hopefully it is handled elsewhere\n\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\ttypeof getterOrValue === \"function\" ? getterOrValue() : getterOrValue;\n\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\teventLike[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn toExtend;\n\t}\n}\n\n/**\n * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from\n * container-runtime. Issue: #8191\n * TaggedLoggerAdapter class can add tag handling to your logger.\n *\n * @internal\n */\nexport class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n\tpublic constructor(private readonly logger: ITelemetryBaseLogger) {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(eventWithTagsMaybe: ITelemetryBaseEvent): void {\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\tcategory: eventWithTagsMaybe.category,\n\t\t\teventName: eventWithTagsMaybe.eventName,\n\t\t};\n\t\tfor (const [key, taggableProp] of Object.entries(eventWithTagsMaybe)) {\n\t\t\tconst { value, tag } =\n\t\t\t\ttypeof taggableProp === \"object\"\n\t\t\t\t\t? taggableProp\n\t\t\t\t\t: { value: taggableProp, tag: undefined };\n\t\t\tswitch (tag) {\n\t\t\t\tcase undefined: {\n\t\t\t\t\t// No tag means we can log plainly\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"PackageData\": // For back-compat\n\t\t\t\tcase TelemetryDataTag.CodeArtifact: {\n\t\t\t\t\t// For Microsoft applications, CodeArtifact is safe for now\n\t\t\t\t\t// (we don't load 3P code in 1P apps)\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TelemetryDataTag.UserData: {\n\t\t\t\t\t// Strip out anything tagged explicitly as UserData.\n\t\t\t\t\t// Alternate strategy would be to hash these props\n\t\t\t\t\tnewEvent[key] = \"REDACTED (UserData)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\t// If we encounter a tag we don't recognize\n\t\t\t\t\t// then we must assume we should scrub.\n\t\t\t\t\tnewEvent[key] = \"REDACTED (unknown tag)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.logger.send(newEvent);\n\t}\n}\n\nfunction toEitherTelemetryLoggerExt(\n\tlogger: TelemetryLoggerExt,\n): TelemetryLoggerExt & ITelemetryLoggerExt {\n\treturn logger as TelemetryLoggerExt & ITelemetryLoggerExt;\n}\n\n/**\n * Create a child logger based on the provided props object.\n *\n * @remarks\n * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.\n *\n * @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.\n *\n * @internal\n *\n * @privateRemarks\n * Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for\n * easier internal usage without needing to type erase or un-type-erase the\n * logger.\n *\n * If always creating a child logger for direct external exposure, consider\n * using {@link createChildLogger} from /legacy API instead, which returns\n * exactly an {@link ITelemetryLoggerExt}.\n */\nexport function createChildLogger(props?: {\n\tlogger?: ITelemetryBaseLogger;\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n}): TelemetryLoggerExt & ITelemetryLoggerExt {\n\treturn toEitherTelemetryLoggerExt(\n\t\tChildLogger.create(props?.logger, props?.namespace, props?.properties),\n\t);\n}\n\n/**\n * ChildLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events.\n */\nexport class ChildLogger extends TelemetryLogger {\n\t/**\n\t * Create child logger\n\t * @param baseLogger - Base logger to use to output events. If undefined, proper child logger\n\t * is created, but it does not send telemetry events anywhere.\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t */\n\tpublic static create(\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// if we are creating a child of a child, rather than nest, which will increase\n\t\t// the callstack overhead, just generate a new logger that includes everything from the previous\n\t\tif (baseLogger instanceof ChildLogger) {\n\t\t\tconst combinedProperties: ITelemetryLoggerPropertyBags = {};\n\t\t\tfor (const extendedProps of [baseLogger.properties, properties]) {\n\t\t\t\tif (extendedProps !== undefined) {\n\t\t\t\t\tif (extendedProps.all !== undefined) {\n\t\t\t\t\t\tcombinedProperties.all = {\n\t\t\t\t\t\t\t...combinedProperties.all,\n\t\t\t\t\t\t\t...extendedProps.all,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (extendedProps.error !== undefined) {\n\t\t\t\t\t\tcombinedProperties.error = {\n\t\t\t\t\t\t\t...combinedProperties.error,\n\t\t\t\t\t\t\t...extendedProps.error,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst combinedNamespace =\n\t\t\t\tbaseLogger.namespace === undefined\n\t\t\t\t\t? namespace\n\t\t\t\t\t: namespace === undefined\n\t\t\t\t\t\t? baseLogger.namespace\n\t\t\t\t\t\t: `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;\n\n\t\t\tconst child = new ChildLogger(\n\t\t\t\tbaseLogger.baseLogger,\n\t\t\t\tcombinedNamespace,\n\t\t\t\tcombinedProperties,\n\t\t\t);\n\n\t\t\tif (!loggerIsMonitoringContext(child) && loggerIsMonitoringContext(baseLogger)) {\n\t\t\t\tmixinMonitoringContext(child, baseLogger.config);\n\t\t\t}\n\t\t\treturn child;\n\t\t}\n\n\t\treturn new ChildLogger(baseLogger ?? { send(): void {} }, namespace, properties);\n\t}\n\n\tprivate constructor(\n\t\tprotected readonly baseLogger: ITelemetryBaseLogger,\n\t\tnamespace: string | undefined,\n\t\tproperties: ITelemetryLoggerPropertyBags | undefined,\n\t) {\n\t\tsuper(namespace, properties);\n\n\t\t// propagate the monitoring context\n\t\tif (loggerIsMonitoringContext(baseLogger)) {\n\t\t\tmixinMonitoringContext(this, new CachedConfigProvider(this, baseLogger.config));\n\t\t}\n\t}\n\n\tpublic get minLogLevel(): LogLevel | undefined {\n\t\treturn this.baseLogger.minLogLevel;\n\t}\n\n\tprivate shouldFilterOutEvent(event: ITelemetryBaseEvent, logLevel?: LogLevel): boolean {\n\t\tconst eventLogLevel = logLevel ?? LogLevel.default;\n\t\tconst configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.default;\n\t\t// Filter out in case event log level is below what is wanted in config.\n\t\treturn eventLogLevel < configLogLevel;\n\t}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tif (this.shouldFilterOutEvent(event, logLevel)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.baseLogger.send(this.prepareEvent(event), logLevel);\n\t}\n}\n\n/**\n * Input properties for {@link createMultiSinkLogger}.\n *\n * @internal\n */\nexport interface MultiSinkLoggerProperties {\n\t/**\n\t * Will be prefixed to all event names.\n\t */\n\tnamespace?: string;\n\n\t/**\n\t * Default properties that will be applied to all events flowing through this logger.\n\t */\n\tproperties?: ITelemetryLoggerPropertyBags;\n\n\t/**\n\t * The base loggers that this logger will forward the logs to, after it processes them.\n\t */\n\tloggers?: (ITelemetryBaseLogger | undefined)[];\n\n\t/**\n\t * If true, the logger will attempt to copy the custom properties (if they are of a known type, i.e. one from this package) of all the base loggers passed to it, to apply them itself to logs that flow through.\n\t */\n\ttryInheritProperties?: true;\n}\n\n/**\n * Create a logger which logs to multiple other loggers based on the provided props object.\n *\n * @internal\n */\nexport function createMultiSinkLogger(props: MultiSinkLoggerProperties): TelemetryLoggerExt {\n\treturn new MultiSinkLogger(\n\t\tprops.namespace,\n\t\tprops.properties,\n\t\tprops.loggers?.filter((l): l is ITelemetryBaseLogger => l !== undefined),\n\t\tprops.tryInheritProperties,\n\t);\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n\tprotected loggers: ITelemetryBaseLogger[];\n\t// This is minimum of minLlogLevel of all loggers.\n\tprivate _minLogLevelOfAllLoggers: LogLevel;\n\n\t/**\n\t * Create multiple sink logger (i.e. logger that sends events to multiple sinks)\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param loggers - The list of loggers to use as sinks\n\t * @param tryInheritProperties - Will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n\t */\n\tpublic constructor(\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t\tloggers: ITelemetryBaseLogger[] = [],\n\t\ttryInheritProperties?: true,\n\t) {\n\t\tlet realProperties = properties === undefined ? undefined : { ...properties };\n\t\tif (tryInheritProperties === true) {\n\t\t\tconst merge = (realProperties ??= {});\n\t\t\tloggers\n\t\t\t\t.filter((l): l is this => l instanceof TelemetryLogger)\n\t\t\t\t.map((l) => l.properties ?? {})\n\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t.forEach((cv) => {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t\tObject.keys(cv).forEach((k) => {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\tmerge[k] = { ...cv[k], ...merge?.[k] };\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\n\t\tsuper(namespace, realProperties);\n\t\tthis.loggers = loggers;\n\t\tthis._minLogLevelOfAllLoggers = LogLevel.default;\n\t\tthis.calculateMinLogLevel();\n\t}\n\n\tpublic get minLogLevel(): LogLevel {\n\t\treturn this._minLogLevelOfAllLoggers;\n\t}\n\n\tprivate calculateMinLogLevel(): void {\n\t\tif (this.loggers.length > 0) {\n\t\t\tconst logLevels: LogLevel[] = [];\n\t\t\tfor (const logger of this.loggers) {\n\t\t\t\tlogLevels.push(logger.minLogLevel ?? LogLevel.default);\n\t\t\t}\n\t\t\tthis._minLogLevelOfAllLoggers = Math.min(...logLevels) as LogLevel;\n\t\t}\n\t}\n\n\t/**\n\t * Add logger to send all events to\n\t * @param logger - Logger to add\n\t */\n\tpublic addLogger(logger?: ITelemetryBaseLogger): void {\n\t\tif (logger !== undefined && logger !== null) {\n\t\t\tthis.loggers.push(logger);\n\t\t\t// Update in case the logLevel of added logger is less than the current.\n\t\t\tthis.calculateMinLogLevel();\n\t\t}\n\t}\n\n\t/**\n\t * Send an event to the loggers\n\t *\n\t * @param event - the event to send to all the registered logger\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tconst newEvent = this.prepareEvent(event);\n\t\tfor (const logger of this.loggers) {\n\t\t\tlogger.send(newEvent);\n\t\t}\n\t}\n}\n\n/**\n * Describes what events {@link PerformanceEvent} should log.\n *\n * @remarks\n * By default, all events are logged, but the client can override this behavior.\n *\n * For example, there is rarely a need to record a start event, as we're really after\n * success / failure tracking, including duration (on success).\n *\n * @internal\n */\nexport interface IPerformanceEventMarkers {\n\tstart?: true;\n\tend?: true;\n\tcancel?: \"generic\" | \"error\"; // tells wether to issue \"generic\" or \"error\" category cancel event\n}\n\n/**\n * Helper class to log performance events.\n *\n * @internal\n */\nexport class PerformanceEvent {\n\t/**\n\t * Creates an instance of {@link PerformanceEvent} and starts measurements\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,\n\t * but measurements will still be performed and any specified markers will be generated.\n\t * @returns An instance of {@link PerformanceEvent}\n\t */\n\tpublic static start(\n\t\tlogger: TelemetryLoggerExt | ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\temitLogs: boolean = true,\n\t): PerformanceEvent {\n\t\treturn new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs);\n\t}\n\n\t/**\n\t * Measure a synchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static timedExec<T>(\n\t\tlogger: TelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tcallback: (event: PerformanceEvent) => T,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t): T {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t);\n\t\ttry {\n\t\t\tconst ret = callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Measure an asynchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static async timedExecAsync<T>(\n\t\tlogger: TelemetryLoggerExt | ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tcallback: (event: PerformanceEvent) => Promise<T>,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t): Promise<T> {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t);\n\t\ttry {\n\t\t\tconst ret = await callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic get duration(): number {\n\t\treturn performanceNow() - this.startTime;\n\t}\n\n\tprivate event?: ITelemetryGenericEventExt;\n\tprivate readonly startTime = performanceNow();\n\tprivate startMark?: string;\n\n\tprotected constructor(\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tprivate readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n\t\tprivate readonly emitLogs: boolean = true,\n\t) {\n\t\tthis.event = { ...event };\n\t\tif (this.markers.start) {\n\t\t\tthis.reportEvent(\"start\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof window === \"object\" &&\n\t\t\twindow?.performance?.mark !== undefined &&\n\t\t\twindow?.performance?.mark !== null\n\t\t) {\n\t\t\tthis.startMark = `${event.eventName}-start`;\n\t\t\twindow.performance.mark(this.startMark);\n\t\t}\n\t}\n\n\tpublic reportProgress(\n\t\tprops?: ITelemetryPropertiesExt,\n\t\teventNameSuffix: string = \"update\",\n\t): void {\n\t\tthis.reportEvent(eventNameSuffix, props);\n\t}\n\n\tprivate autoEnd(): void {\n\t\t// Event might have been cancelled or ended in the callback\n\t\tif (this.event && this.markers.end) {\n\t\t\tthis.reportEvent(\"end\");\n\t\t}\n\t\tthis.performanceEndMark();\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\tpublic end(props?: ITelemetryPropertiesExt): void {\n\t\tthis.reportEvent(\"end\", props);\n\t\tthis.performanceEndMark();\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\tprivate performanceEndMark(): void {\n\t\tif (this.startMark !== undefined && this.event) {\n\t\t\tconst endMark = `${this.event.eventName}-end`;\n\t\t\twindow.performance.mark(endMark);\n\t\t\twindow.performance.measure(`${this.event.eventName}`, this.startMark, endMark);\n\t\t\tthis.startMark = undefined;\n\t\t}\n\t}\n\n\tpublic cancel(props?: ITelemetryPropertiesExt, error?: unknown): void {\n\t\tif (this.markers.cancel !== undefined) {\n\t\t\tthis.reportEvent(\"cancel\", { category: this.markers.cancel, ...props }, error);\n\t\t}\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\t/**\n\t * Report the event, if it hasn't already been reported.\n\t */\n\tpublic reportEvent(\n\t\teventNameSuffix: string,\n\t\tprops?: ITelemetryPropertiesExt,\n\t\terror?: unknown,\n\t): void {\n\t\t// If the caller invokes cancel or end directly inside the callback for timedExec[Async],\n\t\t// then it's possible to come back through reportEvent twice. Only the first time counts.\n\t\tif (!this.event) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.emitLogs) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst event: ITelemetryPerformanceEventExt = { ...this.event, ...props };\n\t\tevent.eventName = `${event.eventName}_${eventNameSuffix}`;\n\t\tif (eventNameSuffix !== \"start\") {\n\t\t\tevent.duration = this.duration;\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(event, error);\n\t}\n\n\tprivate static readonly eventHits = new Map<string, number>();\n\tprivate static shouldReport(\n\t\tevent: ITelemetryGenericEventExt,\n\t\tsampleThreshold: number,\n\t): boolean {\n\t\tconst eventKey = `.${event.category}.${event.eventName}`;\n\t\tconst hitCount = PerformanceEvent.eventHits.get(eventKey) ?? 0;\n\t\tPerformanceEvent.eventHits.set(eventKey, hitCount >= sampleThreshold ? 1 : hitCount + 1);\n\t\treturn hitCount % sampleThreshold === 0;\n\t}\n}\n\n/**\n * Takes in an event object, and converts all of its values to a basePropertyType.\n * In the case of an invalid property type, the value will be converted to an error string.\n * @param event - Event with fields you want to stringify.\n */\nfunction convertToBaseEvent({\n\tcategory,\n\teventName,\n\t...props\n}: ITelemetryEventExt): ITelemetryBaseEvent {\n\tconst newEvent: ITelemetryBaseEvent = { category, eventName };\n\tfor (const key of Object.keys(props)) {\n\t\tnewEvent[key] = convertToBasePropertyType(props[key]);\n\t}\n\treturn newEvent;\n}\n\n/**\n * Takes in value, and does one of 4 things.\n * if value is of primitive type - returns the original value.\n * If the value is a flat array or object - returns a stringified version of the array/object.\n * If the value is an object of type Tagged<TelemetryBaseEventPropertyType> - returns the object\n * with its values recursively converted to base property Type.\n * If none of these cases are reached - returns an error string\n * @param x - value passed in to convert to a base property type\n */\nexport function convertToBasePropertyType(\n\tx: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>,\n): TelemetryBaseEventPropertyType | Tagged<TelemetryBaseEventPropertyType> {\n\treturn isTaggedTelemetryPropertyValue(x)\n\t\t? {\n\t\t\t\tvalue: convertToBasePropertyTypeUntagged(x.value),\n\t\t\t\ttag: x.tag,\n\t\t\t}\n\t\t: convertToBasePropertyTypeUntagged(x);\n}\n\nfunction convertToBasePropertyTypeUntagged(\n\tx: TelemetryEventPropertyTypeExt,\n): TelemetryBaseEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\": {\n\t\t\treturn x;\n\t\t}\n\t\tcase \"object\": {\n\t\t\t// We assume this is an array or flat object based on the input types\n\t\t\treturn JSON.stringify(x);\n\t\t}\n\t\tdefault: {\n\t\t\t// should never reach this case based on the input types\n\t\t\tconsole.error(\n\t\t\t\t`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`,\n\t\t\t);\n\t\t\treturn `INVALID PROPERTY (typed as ${typeof x})`;\n\t\t}\n\t}\n}\n\n/**\n * Tags all given `values` with the same `tag`.\n *\n * @param tag - The tag with which all `values` will be annotated.\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagData(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged.\n *\n * @internal\n */\nexport const tagData = <\n\tT extends TelemetryDataTag,\n\tV extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\ttag: T,\n\tvalues: V,\n): {\n\t[P in keyof V]:\n\t\t| (V[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<V[P]>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<V[P], undefined>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t\t})\n\t\t| (V[P] extends undefined ? undefined : never);\n} =>\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\tObject.entries(values)\n\t\t.filter((e) => e[1] !== undefined)\n\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t.reduce((pv, cv) => {\n\t\t\tconst [key, value] = cv;\n\t\t\t// The ternary form is less legible in this case.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tpv[key] = () => {\n\t\t\t\t\treturn { tag, value: value() };\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tpv[key] = { tag, value };\n\t\t\t}\n\t\t\treturn pv;\n\t\t}, {}) as ReturnType<typeof tagData>;\n\n/**\n * Tags all provided `values` as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagCodeArtifacts(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @see {@link tagData}\n *\n * @internal\n */\nexport const tagCodeArtifacts = <\n\tT extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\tvalues: T,\n): {\n\t[P in keyof T]:\n\t\t| (T[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<T[P]>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<T[P], undefined>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t\t})\n\t\t| (T[P] extends undefined ? undefined : never);\n} => tagData<TelemetryDataTag.CodeArtifact, T>(TelemetryD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GAsBG;AACI,MAAM,gBAAgB,GAAG,CAM/B,MAAS,EAaR,EAAE,CAAC,IAAA,eAAO,EAAmC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAnBzE,QAAA,gBAAgB,oBAmByD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport {\n\ttype ITelemetryBaseEvent,\n\ttype ITelemetryBaseLogger,\n\tLogLevel,\n\ttype Tagged,\n\ttype TelemetryBaseEventPropertyType,\n} from \"@fluidframework/core-interfaces\";\n\nimport {\n\tCachedConfigProvider,\n\tloggerIsMonitoringContext,\n\tmixinMonitoringContext,\n} from \"./config.js\";\nimport {\n\textractLogSafeErrorProperties,\n\tgenerateStack,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n} from \"./errorLogging.js\";\nimport type {\n\tITelemetryEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n\tTelemetryLoggerExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes.js\";\nimport type {\n\tITelemetryErrorEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.\n * @internal\n */\nexport function toITelemetryLoggerExt(logger: TelemetryLoggerExt): ITelemetryLoggerExt {\n\treturn logger as unknown as ITelemetryLoggerExt;\n}\n\n/**\n * Un-type-erase the {@link ITelemetryLoggerExt}.\n * @remarks\n * This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.\n *\n * @typeParam options - options for the extraction, currently only supports making\n * the output possibly undefined (when `PossiblyUndefined: true`), which is useful\n * for cases where we want to allow passing `undefined` through.\n *\n * @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will\n * be when the breaking change is made. At that time, use of this helper will be\n * required.\n *\n * @internal\n */\nexport function extractTelemetryLoggerExt<\n\toptions extends {\n\t\tPossiblyUndefined?: true;\n\t} = // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty object without PossiblyUndefined is the correct type\n\t{},\n>(\n\tinput:\n\t\t| ITelemetryLoggerExt\n\t\t| TelemetryLoggerExt\n\t\t| (options[\"PossiblyUndefined\"] extends true ? undefined : never),\n): TelemetryLoggerExt | (options[\"PossiblyUndefined\"] extends true ? undefined : never) {\n\treturn input as unknown as TelemetryLoggerExt;\n}\n\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n *\n * @privateRemarks Please do not modify existing entries, to maintain backwards compatibility.\n *\n * @internal\n */\nexport enum TelemetryDataTag {\n\t/**\n\t * Data containing terms or IDs from code packages that may have been dynamically loaded\n\t */\n\tCodeArtifact = \"CodeArtifact\",\n\t/**\n\t * Personal data of a variety of classifications that pertains to the user\n\t */\n\tUserData = \"UserData\",\n}\n\n/**\n * @legacy\n * @beta\n */\nexport type TelemetryEventPropertyTypes = ITelemetryPropertiesExt[string];\n\n/**\n * @legacy\n * @beta\n */\nexport type ITelemetryLoggerPropertyBag = Record<\n\tstring,\n\tTelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes)\n>;\n\n/**\n * @legacy\n * @beta\n *\n * @privateRemarks\n * This is exposed to support {@link createChildLogger} properties parameter.\n */\nexport interface ITelemetryLoggerPropertyBags {\n\tall?: ITelemetryLoggerPropertyBag;\n\terror?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * Attempts to parse number from string.\n * If it fails, it will return the original string.\n *\n * @remarks\n * Used to make telemetry data typed (and support math operations, like comparison),\n * in places where we do expect numbers (like contentsize/duration property in http header).\n *\n * @internal\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function numberFromString(str: string | null | undefined): string | number | undefined {\n\tif (str === undefined || str === null) {\n\t\treturn undefined;\n\t}\n\tconst num = Number(str);\n\treturn Number.isNaN(num) ? str : num;\n}\n\n// TODO: add docs\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function formatTick(tick: number): number {\n\treturn Math.floor(tick);\n}\n\n/**\n * String used to concatenate the namespace of parent loggers and their child loggers.\n * @internal\n */\nexport const eventNamespaceSeparator = \":\";\n\n/**\n * TelemetryLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport abstract class TelemetryLogger implements TelemetryLoggerExt {\n\t/**\n\t * {@inheritDoc eventNamespaceSeparator}\n\t */\n\tpublic static readonly eventNamespaceSeparator = eventNamespaceSeparator;\n\n\tpublic static sanitizePkgName(name: string): string {\n\t\treturn name.replace(\"@\", \"\").replace(\"/\", \"-\");\n\t}\n\n\t/**\n\t * Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied\n\t * over from the error object, along with other telemetry properties if it's an ILoggingError.\n\t * @param event - Event being logged\n\t * @param error - Error to extract info from\n\t * @param fetchStack - Whether to fetch the current callstack if error.stack is undefined\n\t */\n\tpublic static prepareErrorObject(\n\t\tevent: ITelemetryBaseEvent,\n\t\terror: unknown,\n\t\tfetchStack: boolean,\n\t): void {\n\t\tconst { message, errorType, stack } = extractLogSafeErrorProperties(\n\t\t\terror,\n\t\t\ttrue /* sanitizeStack */,\n\t\t);\n\t\t// First, copy over error message, stack, and errorType directly (overwrite if present on event)\n\t\tevent.stack = stack;\n\t\tevent.error = message; // Note that the error message goes on the 'error' field\n\t\tevent.errorType = errorType;\n\n\t\tif (isILoggingError(error)) {\n\t\t\t// Add any other telemetry properties from the LoggingError\n\t\t\tconst telemetryProp = error.getTelemetryProperties();\n\t\t\tfor (const key of Object.keys(telemetryProp)) {\n\t\t\t\tif (event[key] !== undefined) {\n\t\t\t\t\t// Don't overwrite existing properties on the event\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tevent[key] = telemetryProp[key];\n\t\t\t}\n\t\t}\n\n\t\t// Collect stack if we were not able to extract it from error\n\t\tif (event.stack === undefined && fetchStack) {\n\t\t\tevent.stack = generateStack();\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprotected readonly namespace?: string,\n\t\tprotected readonly properties?: ITelemetryLoggerPropertyBags,\n\t) {}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic abstract send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log. If the event's category is `error`,\n\t * the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tpublic sendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{ ...event, category: event.category ?? \"generic\" },\n\t\t\terror,\n\t\t\tevent.category === \"error\" ? LogLevel.essential : (logLevel ?? LogLevel.essential),\n\t\t);\n\t}\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - level of the log.\n\t */\n\tprivate sendTelemetryEventCore(\n\t\tevent: ITelemetryGenericEventExt & { category: TelemetryEventCategory },\n\t\terror: unknown,\n\t\tlogLevel: LogLevel,\n\t): void {\n\t\tconst newEvent = convertToBaseEvent(event);\n\t\tif (error !== undefined) {\n\t\t\tTelemetryLogger.prepareErrorObject(newEvent, error, false);\n\t\t}\n\n\t\t// Will include Nan & Infinity, but probably we do not care\n\t\tif (typeof newEvent.duration === \"number\") {\n\t\t\tnewEvent.duration = formatTick(newEvent.duration);\n\t\t}\n\n\t\tthis.send(newEvent, logLevel);\n\t}\n\n\t/**\n\t * Send an error telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{\n\t\t\t\t// ensure the error field has some value,\n\t\t\t\t// this can and will be overridden by event, or error\n\t\t\t\terror: event.eventName,\n\t\t\t\t...event,\n\t\t\t\tcategory: \"error\",\n\t\t\t},\n\t\t\terror,\n\t\t\tLogLevel.essential,\n\t\t);\n\t}\n\n\t/**\n\t * Send a performance telemetry event with the logger\n\t *\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log. If the event's category is `error`,\n\t * the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tpublic sendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void {\n\t\tconst perfEvent = {\n\t\t\t...event,\n\t\t\tcategory: event.category ?? \"performance\",\n\t\t};\n\n\t\tthis.sendTelemetryEventCore(\n\t\t\tperfEvent,\n\t\t\terror,\n\t\t\tperfEvent.category === \"error\" ? LogLevel.essential : (logLevel ?? LogLevel.essential),\n\t\t);\n\t}\n\n\tprotected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent {\n\t\tconst includeErrorProps = event.category === \"error\" || event.error !== undefined;\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\t...event,\n\t\t};\n\t\tif (this.namespace !== undefined) {\n\t\t\tnewEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;\n\t\t}\n\t\treturn this.extendProperties(newEvent, includeErrorProps);\n\t}\n\n\tprivate extendProperties<\n\t\tT extends ITelemetryLoggerPropertyBag = ITelemetryLoggerPropertyBag,\n\t>(toExtend: T, includeErrorProps: boolean): T {\n\t\tconst eventLike: ITelemetryLoggerPropertyBag = toExtend;\n\t\tif (this.properties) {\n\t\t\tconst properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];\n\t\t\tproperties.push(this.properties.all);\n\t\t\tif (includeErrorProps) {\n\t\t\t\tproperties.push(this.properties.error);\n\t\t\t}\n\t\t\tfor (const props of properties) {\n\t\t\t\tif (props !== undefined) {\n\t\t\t\t\tfor (const [key, getterOrValue] of Object.entries(props)) {\n\t\t\t\t\t\tif (eventLike[key] !== undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If this throws, hopefully it is handled elsewhere\n\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\ttypeof getterOrValue === \"function\" ? getterOrValue() : getterOrValue;\n\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\teventLike[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn toExtend;\n\t}\n}\n\n/**\n * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from\n * container-runtime. Issue: #8191\n * TaggedLoggerAdapter class can add tag handling to your logger.\n *\n * @internal\n */\nexport class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n\tpublic constructor(private readonly logger: ITelemetryBaseLogger) {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(eventWithTagsMaybe: ITelemetryBaseEvent): void {\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\tcategory: eventWithTagsMaybe.category,\n\t\t\teventName: eventWithTagsMaybe.eventName,\n\t\t};\n\t\tfor (const [key, taggableProp] of Object.entries(eventWithTagsMaybe)) {\n\t\t\tconst { value, tag } =\n\t\t\t\ttypeof taggableProp === \"object\"\n\t\t\t\t\t? taggableProp\n\t\t\t\t\t: { value: taggableProp, tag: undefined };\n\t\t\tswitch (tag) {\n\t\t\t\tcase undefined: {\n\t\t\t\t\t// No tag means we can log plainly\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"PackageData\": // For back-compat\n\t\t\t\tcase TelemetryDataTag.CodeArtifact: {\n\t\t\t\t\t// For Microsoft applications, CodeArtifact is safe for now\n\t\t\t\t\t// (we don't load 3P code in 1P apps)\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TelemetryDataTag.UserData: {\n\t\t\t\t\t// Strip out anything tagged explicitly as UserData.\n\t\t\t\t\t// Alternate strategy would be to hash these props\n\t\t\t\t\tnewEvent[key] = \"REDACTED (UserData)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\t// If we encounter a tag we don't recognize\n\t\t\t\t\t// then we must assume we should scrub.\n\t\t\t\t\tnewEvent[key] = \"REDACTED (unknown tag)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.logger.send(newEvent);\n\t}\n}\n\nfunction toEitherTelemetryLoggerExt(\n\tlogger: TelemetryLoggerExt,\n): TelemetryLoggerExt & ITelemetryLoggerExt {\n\treturn logger as TelemetryLoggerExt & ITelemetryLoggerExt;\n}\n\n/**\n * Create a child logger based on the provided props object.\n *\n * @remarks\n * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.\n *\n * @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.\n *\n * @internal\n *\n * @privateRemarks\n * Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for\n * easier internal usage without needing to type erase or un-type-erase the\n * logger.\n *\n * If always creating a child logger for direct external exposure, consider\n * using {@link createChildLogger} from /legacy API instead, which returns\n * exactly an {@link ITelemetryLoggerExt}.\n */\nexport function createChildLogger(props?: {\n\tlogger?: ITelemetryBaseLogger;\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n}): TelemetryLoggerExt & ITelemetryLoggerExt {\n\treturn toEitherTelemetryLoggerExt(\n\t\tChildLogger.create(props?.logger, props?.namespace, props?.properties),\n\t);\n}\n\n/**\n * ChildLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events.\n */\nexport class ChildLogger extends TelemetryLogger {\n\t/**\n\t * Create child logger\n\t * @param baseLogger - Base logger to use to output events. If undefined, proper child logger\n\t * is created, but it does not send telemetry events anywhere.\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t */\n\tpublic static create(\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// if we are creating a child of a child, rather than nest, which will increase\n\t\t// the callstack overhead, just generate a new logger that includes everything from the previous\n\t\tif (baseLogger instanceof ChildLogger) {\n\t\t\tconst combinedProperties: ITelemetryLoggerPropertyBags = {};\n\t\t\tfor (const extendedProps of [baseLogger.properties, properties]) {\n\t\t\t\tif (extendedProps !== undefined) {\n\t\t\t\t\tif (extendedProps.all !== undefined) {\n\t\t\t\t\t\tcombinedProperties.all = {\n\t\t\t\t\t\t\t...combinedProperties.all,\n\t\t\t\t\t\t\t...extendedProps.all,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (extendedProps.error !== undefined) {\n\t\t\t\t\t\tcombinedProperties.error = {\n\t\t\t\t\t\t\t...combinedProperties.error,\n\t\t\t\t\t\t\t...extendedProps.error,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst combinedNamespace =\n\t\t\t\tbaseLogger.namespace === undefined\n\t\t\t\t\t? namespace\n\t\t\t\t\t: namespace === undefined\n\t\t\t\t\t\t? baseLogger.namespace\n\t\t\t\t\t\t: `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;\n\n\t\t\tconst child = new ChildLogger(\n\t\t\t\tbaseLogger.baseLogger,\n\t\t\t\tcombinedNamespace,\n\t\t\t\tcombinedProperties,\n\t\t\t);\n\n\t\t\tif (!loggerIsMonitoringContext(child) && loggerIsMonitoringContext(baseLogger)) {\n\t\t\t\tmixinMonitoringContext(child, baseLogger.config);\n\t\t\t}\n\t\t\treturn child;\n\t\t}\n\n\t\treturn new ChildLogger(baseLogger ?? { send(): void {} }, namespace, properties);\n\t}\n\n\tprivate constructor(\n\t\tprotected readonly baseLogger: ITelemetryBaseLogger,\n\t\tnamespace: string | undefined,\n\t\tproperties: ITelemetryLoggerPropertyBags | undefined,\n\t) {\n\t\tsuper(namespace, properties);\n\n\t\t// propagate the monitoring context\n\t\tif (loggerIsMonitoringContext(baseLogger)) {\n\t\t\tmixinMonitoringContext(this, new CachedConfigProvider(this, baseLogger.config));\n\t\t}\n\t}\n\n\tpublic get minLogLevel(): LogLevel | undefined {\n\t\treturn this.baseLogger.minLogLevel;\n\t}\n\n\tprivate shouldFilterOutEvent(event: ITelemetryBaseEvent, logLevel?: LogLevel): boolean {\n\t\tconst eventLogLevel = logLevel ?? LogLevel.essential;\n\t\tconst configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.info;\n\t\t// Filter out in case event log level is below what is wanted in config.\n\t\treturn eventLogLevel < configLogLevel;\n\t}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tif (this.shouldFilterOutEvent(event, logLevel)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.baseLogger.send(this.prepareEvent(event), logLevel ?? LogLevel.essential);\n\t}\n}\n\n/**\n * Input properties for {@link createMultiSinkLogger}.\n *\n * @internal\n */\nexport interface MultiSinkLoggerProperties {\n\t/**\n\t * Will be prefixed to all event names.\n\t */\n\tnamespace?: string;\n\n\t/**\n\t * Default properties that will be applied to all events flowing through this logger.\n\t */\n\tproperties?: ITelemetryLoggerPropertyBags;\n\n\t/**\n\t * The base loggers that this logger will forward the logs to, after it processes them.\n\t */\n\tloggers?: (ITelemetryBaseLogger | undefined)[];\n\n\t/**\n\t * If true, the logger will attempt to copy the custom properties (if they are of a known type, i.e. one from this package) of all the base loggers passed to it, to apply them itself to logs that flow through.\n\t */\n\ttryInheritProperties?: true;\n}\n\n/**\n * Create a logger which logs to multiple other loggers based on the provided props object.\n *\n * @internal\n */\nexport function createMultiSinkLogger(props: MultiSinkLoggerProperties): TelemetryLoggerExt {\n\treturn new MultiSinkLogger(\n\t\tprops.namespace,\n\t\tprops.properties,\n\t\tprops.loggers?.filter((l): l is ITelemetryBaseLogger => l !== undefined),\n\t\tprops.tryInheritProperties,\n\t);\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n\tprotected loggers: ITelemetryBaseLogger[];\n\t// This is minimum of minLlogLevel of all loggers.\n\tprivate _minLogLevelOfAllLoggers: LogLevel;\n\n\t/**\n\t * Create multiple sink logger (i.e. logger that sends events to multiple sinks)\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param loggers - The list of loggers to use as sinks\n\t * @param tryInheritProperties - Will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n\t */\n\tpublic constructor(\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t\tloggers: ITelemetryBaseLogger[] = [],\n\t\ttryInheritProperties?: true,\n\t) {\n\t\tlet realProperties = properties === undefined ? undefined : { ...properties };\n\t\tif (tryInheritProperties === true) {\n\t\t\tconst merge = (realProperties ??= {});\n\t\t\tloggers\n\t\t\t\t.filter((l): l is this => l instanceof TelemetryLogger)\n\t\t\t\t.map((l) => l.properties ?? {})\n\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t.forEach((cv) => {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t\tObject.keys(cv).forEach((k) => {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\tmerge[k] = { ...cv[k], ...merge?.[k] };\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\n\t\tsuper(namespace, realProperties);\n\t\tthis.loggers = loggers;\n\t\tthis._minLogLevelOfAllLoggers = LogLevel.info;\n\t\tthis.calculateMinLogLevel();\n\t}\n\n\tpublic get minLogLevel(): LogLevel {\n\t\treturn this._minLogLevelOfAllLoggers;\n\t}\n\n\tprivate calculateMinLogLevel(): void {\n\t\tif (this.loggers.length > 0) {\n\t\t\tconst logLevels: LogLevel[] = [];\n\t\t\tfor (const logger of this.loggers) {\n\t\t\t\tlogLevels.push(logger.minLogLevel ?? LogLevel.info);\n\t\t\t}\n\t\t\tthis._minLogLevelOfAllLoggers = Math.min(...logLevels) as LogLevel;\n\t\t}\n\t}\n\n\t/**\n\t * Add logger to send all events to\n\t * @param logger - Logger to add\n\t */\n\tpublic addLogger(logger?: ITelemetryBaseLogger): void {\n\t\tif (logger !== undefined && logger !== null) {\n\t\t\tthis.loggers.push(logger);\n\t\t\t// Update in case the logLevel of added logger is less than the current.\n\t\t\tthis.calculateMinLogLevel();\n\t\t}\n\t}\n\n\t/**\n\t * Send an event to the loggers\n\t *\n\t * @param event - the event to send to all the registered logger\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tconst newEvent = this.prepareEvent(event);\n\t\tfor (const logger of this.loggers) {\n\t\t\tlogger.send(newEvent, logLevel ?? LogLevel.essential);\n\t\t}\n\t}\n}\n\n/**\n * Describes what events {@link PerformanceEvent} should log.\n *\n * @remarks\n * By default, all events are logged, but the client can override this behavior.\n *\n * For example, there is rarely a need to record a start event, as we're really after\n * success / failure tracking, including duration (on success).\n *\n * @internal\n */\nexport interface IPerformanceEventMarkers {\n\tstart?: true;\n\tend?: true;\n\tcancel?: \"generic\" | \"error\"; // tells wether to issue \"generic\" or \"error\" category cancel event\n}\n\n/**\n * Helper class to log performance events.\n *\n * @internal\n */\nexport class PerformanceEvent {\n\t/**\n\t * Creates an instance of {@link PerformanceEvent} and starts measurements\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,\n\t * but measurements will still be performed and any specified markers will be generated.\n\t * @param logLevel - optional {@link LogLevel} for events emitted by this performance event.\n\t * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.\n\t * @returns An instance of {@link PerformanceEvent}\n\t */\n\tpublic static start(\n\t\tlogger: TelemetryLoggerExt | ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\temitLogs: boolean = true,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): PerformanceEvent {\n\t\treturn new PerformanceEvent(\n\t\t\textractTelemetryLoggerExt(logger),\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\temitLogs,\n\t\t\tlogLevel,\n\t\t);\n\t}\n\n\t/**\n\t * Measure a synchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @param logLevel - optional {@link LogLevel} for events emitted by this performance event.\n\t * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static timedExec<T>(\n\t\tlogger: TelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tcallback: (event: PerformanceEvent) => T,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): T {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t\tlogLevel,\n\t\t);\n\t\ttry {\n\t\t\tconst ret = callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Measure an asynchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @param logLevel - optional {@link LogLevel} for events emitted by this performance event.\n\t * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static async timedExecAsync<T>(\n\t\tlogger: TelemetryLoggerExt | ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tcallback: (event: PerformanceEvent) => Promise<T>,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): Promise<T> {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t\tlogLevel,\n\t\t);\n\t\ttry {\n\t\t\tconst ret = await callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic get duration(): number {\n\t\treturn performanceNow() - this.startTime;\n\t}\n\n\tprivate event?: ITelemetryGenericEventExt;\n\tprivate readonly startTime = performanceNow();\n\tprivate startMark?: string;\n\n\tprivate constructor(\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tprivate readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n\t\tprivate readonly emitLogs: boolean = true,\n\t\tprivate readonly logLevel: typeof LogLevel.verbose | typeof LogLevel.info | undefined,\n\t) {\n\t\tthis.event = { ...event };\n\t\tif (this.markers.start) {\n\t\t\tthis.reportEvent(\"start\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof window === \"object\" &&\n\t\t\twindow?.performance?.mark !== undefined &&\n\t\t\twindow?.performance?.mark !== null\n\t\t) {\n\t\t\tthis.startMark = `${event.eventName}-start`;\n\t\t\twindow.performance.mark(this.startMark);\n\t\t}\n\t}\n\n\tpublic reportProgress(\n\t\tprops?: ITelemetryPropertiesExt,\n\t\teventNameSuffix: string = \"update\",\n\t): void {\n\t\tthis.reportEvent(eventNameSuffix, props);\n\t}\n\n\tprivate autoEnd(): void {\n\t\t// Event might have been cancelled or ended in the callback\n\t\tif (this.event && this.markers.end) {\n\t\t\tthis.reportEvent(\"end\");\n\t\t}\n\t\tthis.performanceEndMark();\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\tpublic end(props?: ITelemetryPropertiesExt): void {\n\t\tthis.reportEvent(\"end\", props);\n\t\tthis.performanceEndMark();\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\tprivate performanceEndMark(): void {\n\t\tif (this.startMark !== undefined && this.event) {\n\t\t\tconst endMark = `${this.event.eventName}-end`;\n\t\t\twindow.performance.mark(endMark);\n\t\t\twindow.performance.measure(`${this.event.eventName}`, this.startMark, endMark);\n\t\t\tthis.startMark = undefined;\n\t\t}\n\t}\n\n\tpublic cancel(props?: ITelemetryPropertiesExt, error?: unknown): void {\n\t\tif (this.markers.cancel !== undefined) {\n\t\t\tthis.reportEvent(\"cancel\", { category: this.markers.cancel, ...props }, error);\n\t\t}\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\t/**\n\t * Report the event, if it hasn't already been reported.\n\t */\n\tpublic reportEvent(\n\t\teventNameSuffix: string,\n\t\tprops?: ITelemetryPropertiesExt,\n\t\terror?: unknown,\n\t): void {\n\t\t// If the caller invokes cancel or end directly inside the callback for timedExec[Async],\n\t\t// then it's possible to come back through reportEvent twice. Only the first time counts.\n\t\tif (!this.event) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.emitLogs) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst event: ITelemetryPerformanceEventExt = { ...this.event, ...props };\n\t\tevent.eventName = `${event.eventName}_${eventNameSuffix}`;\n\t\tif (eventNameSuffix !== \"start\") {\n\t\t\tevent.duration = this.duration;\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(event, error, this.logLevel);\n\t}\n\n\tprivate static readonly eventHits = new Map<string, number>();\n\tprivate static shouldReport(\n\t\tevent: ITelemetryGenericEventExt,\n\t\tsampleThreshold: number,\n\t): boolean {\n\t\tconst eventKey = `.${event.category}.${event.eventName}`;\n\t\tconst hitCount = PerformanceEvent.eventHits.get(eventKey) ?? 0;\n\t\tPerformanceEvent.eventHits.set(eventKey, hitCount >= sampleThreshold ? 1 : hitCount + 1);\n\t\treturn hitCount % sampleThreshold === 0;\n\t}\n}\n\n/**\n * Takes in an event object, and converts all of its values to a basePropertyType.\n * In the case of an invalid property type, the value will be converted to an error string.\n * @param event - Event with fields you want to stringify.\n */\nfunction convertToBaseEvent({\n\tcategory,\n\teventName,\n\t...props\n}: ITelemetryEventExt): ITelemetryBaseEvent {\n\tconst newEvent: ITelemetryBaseEvent = { category, eventName };\n\tfor (const key of Object.keys(props)) {\n\t\tnewEvent[key] = convertToBasePropertyType(props[key]);\n\t}\n\treturn newEvent;\n}\n\n/**\n * Takes in value, and does one of 4 things.\n * if value is of primitive type - returns the original value.\n * If the value is a flat array or object - returns a stringified version of the array/object.\n * If the value is an object of type Tagged<TelemetryBaseEventPropertyType> - returns the object\n * with its values recursively converted to base property Type.\n * If none of these cases are reached - returns an error string\n * @param x - value passed in to convert to a base property type\n */\nexport function convertToBasePropertyType(\n\tx: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>,\n): TelemetryBaseEventPropertyType | Tagged<TelemetryBaseEventPropertyType> {\n\treturn isTaggedTelemetryPropertyValue(x)\n\t\t? {\n\t\t\t\tvalue: convertToBasePropertyTypeUntagged(x.value),\n\t\t\t\ttag: x.tag,\n\t\t\t}\n\t\t: convertToBasePropertyTypeUntagged(x);\n}\n\nfunction convertToBasePropertyTypeUntagged(\n\tx: TelemetryEventPropertyTypeExt,\n): TelemetryBaseEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\": {\n\t\t\treturn x;\n\t\t}\n\t\tcase \"object\": {\n\t\t\t// We assume this is an array or flat object based on the input types\n\t\t\treturn JSON.stringify(x);\n\t\t}\n\t\tdefault: {\n\t\t\t// should never reach this case based on the input types\n\t\t\tconsole.error(\n\t\t\t\t`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`,\n\t\t\t);\n\t\t\treturn `INVALID PROPERTY (typed as ${typeof x})`;\n\t\t}\n\t}\n}\n\n/**\n * Tags all given `values` with the same `tag`.\n *\n * @param tag - The tag with which all `values` will be annotated.\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagData(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged.\n *\n * @internal\n */\nexport const tagData = <\n\tT extends TelemetryDataTag,\n\tV extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\ttag: T,\n\tvalues: V,\n): {\n\t[P in keyof V]:\n\t\t| (V[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<V[P]>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<V[P], undefined>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t\t})\n\t\t| (V[P] extends undefined ? undefined : never);\n} =>\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\tObject.entries(values)\n\t\t.filter((e) => e[1] !== undefined)\n\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t.reduce((pv, cv) => {\n\t\t\tconst [key, value] = cv;\n\t\t\t// The ternary form is less legible in this case.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tpv[key] = () => {\n\t\t\t\t\treturn { tag, value: value() };\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tpv[key] = { tag, value };\n\t\t\t}\n\t\t\treturn pv;\n\t\t}, {}) as ReturnType<typeof tagData>;\n\n/**\n * Tags all provided `values` as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagCodeArtifacts(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @see {@link tagData}\n *\n * @internal\n */\nexport const tagCodeArtifacts = <\n\tT extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\tvalues: T,\n): {\n\t[P in keyof T]:\n\t\t| (T[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<T[P]>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<T[P], undefined>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t\t})\n\t\t| (T[P] extends undefined ? undefined : never);\n} => tagData<TelemetryDataTag.CodeArtifact, T>(TelemetryDataTag.CodeArtifact, values);\n"]}

@@ -28,3 +28,3 @@ "use strict";

this._events = [];
this.minLogLevel = minLogLevel ?? core_interfaces_1.LogLevel.default;
this.minLogLevel = minLogLevel ?? core_interfaces_1.LogLevel.info;
}

@@ -44,3 +44,3 @@ /**

send(event, logLevel) {
if ((logLevel ?? core_interfaces_1.LogLevel.default) >= this.minLogLevel) {
if ((logLevel ?? core_interfaces_1.LogLevel.essential) >= this.minLogLevel) {
this._events.push(event);

@@ -47,0 +47,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAIyC;AACzC,kEAA6D;A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AAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAuB,CAAC;KACtD,CAAC,CAAC;AACJ,CAAC;AAPD,kDAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ITelemetryBaseEvent,\n\ttype ITelemetryBaseLogger,\n\tLogLevel,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger } from \"./logger.js\";\nimport type {\n\tITelemetryEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n} from \"./telemetryTypes.js\";\n\n/**\n * Mock {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} implementation.\n *\n * Records events sent to it, and then can walk back over those events, searching for a set of expected events to\n * match against the logged events.\n *\n * @internal\n */\nexport class MockLogger implements ITelemetryBaseLogger {\n\t/**\n\t * Gets an immutable copy of the events logged thus far.\n\t */\n\tpublic get events(): readonly ITelemetryBaseEvent[] {\n\t\treturn [...this._events];\n\t}\n\n\tprivate _events: ITelemetryBaseEvent[] = [];\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.minLogLevel}\n\t */\n\tpublic readonly minLogLevel: LogLevel;\n\n\tpublic constructor(minLogLevel?: LogLevel) {\n\t\tthis.minLogLevel = minLogLevel ?? LogLevel.default;\n\t}\n\n\t/**\n\t * Clears the events logged thus far.\n\t */\n\tpublic clear(): void {\n\t\tthis._events = [];\n\t}\n\n\tpublic toTelemetryLogger(): ReturnType<typeof createChildLogger> {\n\t\treturn createChildLogger({ logger: this });\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tif ((logLevel ?? LogLevel.default) >= this.minLogLevel) {\n\t\t\tthis._events.push(event);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to appear in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t */\n\tpublic matchEvents(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t\tclearEventsAfterCheck,\n\t\t);\n\t\t// How many expected events were left over? Hopefully none.\n\t\tconst unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n\t\treturn unmatchedExpectedEventCount === 0;\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchEvents} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatch(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchEvents(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for any of the given\n\t * expected events.\n\t * @param expectedEvents - events that are expected to appear in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @returns if any of the expected events is found.\n\t */\n\tpublic matchAnyEvent(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t\tclearEventsAfterCheck,\n\t\t);\n\t\treturn matchedExpectedEventCount > 0;\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchAnyEvent} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchAny(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchAnyEvent(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking only for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to be the only events in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t */\n\tpublic matchEventStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tif (expectedEvents.length !== this._events.length) {\n\t\t\tif (clearEventsAfterCheck) {\n\t\t\t\tthis.clear();\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t// `events` will be cleared by the below check if requested.\n\t\treturn this.matchEvents(expectedEvents, inlineDetailsProp, clearEventsAfterCheck);\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchEvents} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchEventStrict(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchAnyEvent} is `false` for the given events.\n\t * @param disallowedEvents - The events expected to not appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchNone(\n\t\tdisallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (this.matchAnyEvent(disallowedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\tprivate getMatchedEventsCount(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean,\n\t\tclearEventsAfterCheck: boolean,\n\t): number {\n\t\tlet iExpectedEvent = 0;\n\t\tfor (const event of this._events) {\n\t\t\tconst expectedEvent = expectedEvents[iExpectedEvent];\n\t\t\tif (\n\t\t\t\tiExpectedEvent < expectedEvents.length &&\n\t\t\t\texpectedEvent !== undefined &&\n\t\t\t\tMockLogger.eventsMatch(event, expectedEvent, inlineDetailsProp)\n\t\t\t) {\n\t\t\t\t// We found the next expected event; increment\n\t\t\t\t++iExpectedEvent;\n\t\t\t}\n\t\t}\n\n\t\t// Remove the events so far; next call will just compare subsequent events from here\n\t\tif (clearEventsAfterCheck) {\n\t\t\tthis.clear();\n\t\t}\n\n\t\t// Return the count of matched events.\n\t\treturn iExpectedEvent;\n\t}\n\n\t/**\n\t * Ensure the expected event is a strict subset of the actual event\n\t */\n\tprivate static eventsMatch(\n\t\tactual: ITelemetryBaseEvent,\n\t\texpected: Omit<ITelemetryBaseEvent, \"category\">,\n\t\tinlineDetailsProp: boolean,\n\t): boolean {\n\t\tconst { details, ...actualForMatching } = actual;\n\t\t// \"details\" is used in a lot of telemetry logs to group a bunch of properties together and stringify them.\n\t\t// Some of the properties in the expected event may be inside \"details\". So, if inlineDetailsProp is true,\n\t\t// extract the properties from \"details\" in the actual event and inline them in the actual event.\n\t\tif (inlineDetailsProp && details !== undefined) {\n\t\t\tassert(\n\t\t\t\ttypeof details === \"string\",\n\t\t\t\t0x6c9 /* Details should a JSON stringified string if inlineDetailsProp is true */,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst detailsExpanded = JSON.parse(details);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn matchObjects({ ...actualForMatching, ...detailsExpanded }, expected);\n\t\t}\n\t\treturn matchObjects(actual, expected);\n\t}\n\n\t/**\n\t * Throws if any errors were logged\n\t */\n\tpublic assertNoErrors(message?: string, clearEventsAfterCheck: boolean = true): void {\n\t\tconst actualEvents = this.events;\n\t\tconst errors = actualEvents.filter((event) => event.category === \"error\");\n\t\tif (clearEventsAfterCheck) {\n\t\t\tthis.clear();\n\t\t}\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`${message ?? \"Errors found in logs\"}\n\nerror logs:\n${JSON.stringify(errors)}`);\n\t\t}\n\t}\n}\n\nfunction matchObjects(\n\tactual: ITelemetryPropertiesExt,\n\texpected: ITelemetryPropertiesExt,\n): boolean {\n\tfor (const [expectedKey, expectedValue] of Object.entries(expected)) {\n\t\tconst actualValue = actual[expectedKey];\n\t\tif (\n\t\t\t!Array.isArray(expectedValue) &&\n\t\t\texpectedValue !== null &&\n\t\t\ttypeof expectedValue === \"object\"\n\t\t) {\n\t\t\tif (\n\t\t\t\tArray.isArray(actualValue) ||\n\t\t\t\tactualValue === null ||\n\t\t\t\ttypeof actualValue !== \"object\" ||\n\t\t\t\t!matchObjects(\n\t\t\t\t\tactualValue as ITelemetryPropertiesExt,\n\t\t\t\t\texpectedValue as ITelemetryPropertiesExt,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Mock {@link TelemetryLoggerExt} implementation.\n *\n * @remarks Can be created via {@link createMockLoggerExt}.\n *\n * @internal\n */\nexport interface IMockLoggerExt extends TelemetryLoggerExt {\n\t/**\n\t * Gets the events that have been logged so far.\n\t */\n\tevents(): readonly ITelemetryEventExt[];\n}\n\n/**\n * Creates an {@link IMockLoggerExt}.\n *\n * @internal\n */\nexport function createMockLoggerExt(minLogLevel?: LogLevel): IMockLoggerExt {\n\tconst mockLogger = new MockLogger(minLogLevel);\n\tconst childLogger = createChildLogger({ logger: mockLogger });\n\treturn Object.assign(childLogger, {\n\t\tevents: (): readonly ITelemetryEventExt[] =>\n\t\t\tmockLogger.events.map((e) => e as ITelemetryEventExt),\n\t});\n}\n"]}
{"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAIyC;AACzC,kEAA6D;AAE7D,2CAAgD;AAOhD;;;;;;;GAOG;AACH,MAAa,UAAU;IACtB;;OA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CAAC,CAAC;AACJ,CAAC;AAPD,kDAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ITelemetryBaseEvent,\n\ttype ITelemetryBaseLogger,\n\tLogLevel,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger } from \"./logger.js\";\nimport type {\n\tITelemetryEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n} from \"./telemetryTypes.js\";\n\n/**\n * Mock {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} implementation.\n *\n * Records events sent to it, and then can walk back over those events, searching for a set of expected events to\n * match against the logged events.\n *\n * @internal\n */\nexport class MockLogger implements ITelemetryBaseLogger {\n\t/**\n\t * Gets an immutable copy of the events logged thus far.\n\t */\n\tpublic get events(): readonly ITelemetryBaseEvent[] {\n\t\treturn [...this._events];\n\t}\n\n\tprivate _events: ITelemetryBaseEvent[] = [];\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.minLogLevel}\n\t */\n\tpublic readonly minLogLevel: LogLevel;\n\n\tpublic constructor(minLogLevel?: LogLevel) {\n\t\tthis.minLogLevel = minLogLevel ?? LogLevel.info;\n\t}\n\n\t/**\n\t * Clears the events logged thus far.\n\t */\n\tpublic clear(): void {\n\t\tthis._events = [];\n\t}\n\n\tpublic toTelemetryLogger(): ReturnType<typeof createChildLogger> {\n\t\treturn createChildLogger({ logger: this });\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tif ((logLevel ?? LogLevel.essential) >= this.minLogLevel) {\n\t\t\tthis._events.push(event);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to appear in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t */\n\tpublic matchEvents(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t\tclearEventsAfterCheck,\n\t\t);\n\t\t// How many expected events were left over? Hopefully none.\n\t\tconst unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n\t\treturn unmatchedExpectedEventCount === 0;\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchEvents} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatch(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchEvents(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for any of the given\n\t * expected events.\n\t * @param expectedEvents - events that are expected to appear in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @returns if any of the expected events is found.\n\t */\n\tpublic matchAnyEvent(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t\tclearEventsAfterCheck,\n\t\t);\n\t\treturn matchedExpectedEventCount > 0;\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchAnyEvent} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchAny(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchAnyEvent(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking only for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to be the only events in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t */\n\tpublic matchEventStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tif (expectedEvents.length !== this._events.length) {\n\t\t\tif (clearEventsAfterCheck) {\n\t\t\t\tthis.clear();\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t// `events` will be cleared by the below check if requested.\n\t\treturn this.matchEvents(expectedEvents, inlineDetailsProp, clearEventsAfterCheck);\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchEvents} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchEventStrict(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchAnyEvent} is `false` for the given events.\n\t * @param disallowedEvents - The events expected to not appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchNone(\n\t\tdisallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (this.matchAnyEvent(disallowedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\tprivate getMatchedEventsCount(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean,\n\t\tclearEventsAfterCheck: boolean,\n\t): number {\n\t\tlet iExpectedEvent = 0;\n\t\tfor (const event of this._events) {\n\t\t\tconst expectedEvent = expectedEvents[iExpectedEvent];\n\t\t\tif (\n\t\t\t\tiExpectedEvent < expectedEvents.length &&\n\t\t\t\texpectedEvent !== undefined &&\n\t\t\t\tMockLogger.eventsMatch(event, expectedEvent, inlineDetailsProp)\n\t\t\t) {\n\t\t\t\t// We found the next expected event; increment\n\t\t\t\t++iExpectedEvent;\n\t\t\t}\n\t\t}\n\n\t\t// Remove the events so far; next call will just compare subsequent events from here\n\t\tif (clearEventsAfterCheck) {\n\t\t\tthis.clear();\n\t\t}\n\n\t\t// Return the count of matched events.\n\t\treturn iExpectedEvent;\n\t}\n\n\t/**\n\t * Ensure the expected event is a strict subset of the actual event\n\t */\n\tprivate static eventsMatch(\n\t\tactual: ITelemetryBaseEvent,\n\t\texpected: Omit<ITelemetryBaseEvent, \"category\">,\n\t\tinlineDetailsProp: boolean,\n\t): boolean {\n\t\tconst { details, ...actualForMatching } = actual;\n\t\t// \"details\" is used in a lot of telemetry logs to group a bunch of properties together and stringify them.\n\t\t// Some of the properties in the expected event may be inside \"details\". So, if inlineDetailsProp is true,\n\t\t// extract the properties from \"details\" in the actual event and inline them in the actual event.\n\t\tif (inlineDetailsProp && details !== undefined) {\n\t\t\tassert(\n\t\t\t\ttypeof details === \"string\",\n\t\t\t\t0x6c9 /* Details should a JSON stringified string if inlineDetailsProp is true */,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst detailsExpanded = JSON.parse(details);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn matchObjects({ ...actualForMatching, ...detailsExpanded }, expected);\n\t\t}\n\t\treturn matchObjects(actual, expected);\n\t}\n\n\t/**\n\t * Throws if any errors were logged\n\t */\n\tpublic assertNoErrors(message?: string, clearEventsAfterCheck: boolean = true): void {\n\t\tconst actualEvents = this.events;\n\t\tconst errors = actualEvents.filter((event) => event.category === \"error\");\n\t\tif (clearEventsAfterCheck) {\n\t\t\tthis.clear();\n\t\t}\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`${message ?? \"Errors found in logs\"}\n\nerror logs:\n${JSON.stringify(errors)}`);\n\t\t}\n\t}\n}\n\nfunction matchObjects(\n\tactual: ITelemetryPropertiesExt,\n\texpected: ITelemetryPropertiesExt,\n): boolean {\n\tfor (const [expectedKey, expectedValue] of Object.entries(expected)) {\n\t\tconst actualValue = actual[expectedKey];\n\t\tif (\n\t\t\t!Array.isArray(expectedValue) &&\n\t\t\texpectedValue !== null &&\n\t\t\ttypeof expectedValue === \"object\"\n\t\t) {\n\t\t\tif (\n\t\t\t\tArray.isArray(actualValue) ||\n\t\t\t\tactualValue === null ||\n\t\t\t\ttypeof actualValue !== \"object\" ||\n\t\t\t\t!matchObjects(\n\t\t\t\t\tactualValue as ITelemetryPropertiesExt,\n\t\t\t\t\texpectedValue as ITelemetryPropertiesExt,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Mock {@link TelemetryLoggerExt} implementation.\n *\n * @remarks Can be created via {@link createMockLoggerExt}.\n *\n * @internal\n */\nexport interface IMockLoggerExt extends TelemetryLoggerExt {\n\t/**\n\t * Gets the events that have been logged so far.\n\t */\n\tevents(): readonly ITelemetryEventExt[];\n}\n\n/**\n * Creates an {@link IMockLoggerExt}.\n *\n * @internal\n */\nexport function createMockLoggerExt(minLogLevel?: LogLevel): IMockLoggerExt {\n\tconst mockLogger = new MockLogger(minLogLevel);\n\tconst childLogger = createChildLogger({ logger: mockLogger });\n\treturn Object.assign(childLogger, {\n\t\tevents: (): readonly ITelemetryEventExt[] =>\n\t\t\tmockLogger.events.map((e) => e as ITelemetryEventExt),\n\t});\n}\n"]}

@@ -54,2 +54,5 @@ /*!

*
* Telemetry events emitted by this class (both at the sample threshold and on dispose) are sent with
* {@link @fluidframework/core-interfaces#LogLevelConst.info | LogLevel.info}.
*
* @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring

@@ -56,0 +59,0 @@ * any custom metric data that might be required by this class. E.g., the code might just return a boolean.

@@ -1,1 +0,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AAO,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,GACrC;IAAE,WAAW,EAAE,cAAc,CAAA;CAAE,CAAC,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,sBAAsB,CAClC,cAAc,GAAG,IAAI,EACrB,cAAc,SAAS,aAAa,CAAC,cAAc,CAAC,GAAG,IAAI,CAC1D,YAAW,WAAW;IA4BtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IA9BrC,OAAO,CAAC,SAAS,CAAkB;IAEnC;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiC;IAEjE;;;;;;;;;;;;;OAaG;gBAEe,SAAS,EAAE,yBAAyB,EACpC,MAAM,EAAE,kBAAkB,EAC1B,eAAe,EAAE,MAAM,EACvB,uBAAuB,GAAE,OAAe,EACxC,mBAAmB,wCAA8C;IAGnF;;;;;;;;;;;;;;OAcG;IACI,OAAO,CACb,aAAa,EAAE,MAAM,iBAAiB,CAAC,cAAc,EAAE,cAAc,CAAC,EACtE,MAAM,GAAE,MAAW,GACjB,iBAAiB,CAAC,cAAc,EAAE,cAAc,CAAC;IAwCpD,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,WAAW;IA6BZ,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI;CAM/C"}

@@ -9,2 +9,3 @@ "use strict";

const client_utils_1 = require("@fluid-internal/client-utils");
const core_interfaces_1 = require("@fluidframework/core-interfaces");
const internal_1 = require("@fluidframework/core-utils/internal");

@@ -22,2 +23,5 @@ const mathTools_js_1 = require("./mathTools.js");

*
* Telemetry events emitted by this class (both at the sample threshold and on dispose) are sent with
* {@link @fluidframework/core-interfaces#LogLevelConst.info | LogLevel.info}.
*
* @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring

@@ -152,3 +156,4 @@ * any custom metric data that might be required by this class. E.g., the code might just return a boolean.

};
this.logger.sendPerformanceEvent(telemetryEvent);
this.logger.sendPerformanceEvent(telemetryEvent, undefined, // error
core_interfaces_1.LogLevel.info);
this.measurementsMap.delete(bucket);

@@ -155,0 +160,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"sampledTelemetryHelper.js","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,kEAA6D;AAE7D,iDAAsD;AA2GtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,sBAAsB;IAOlC;;OAEG;IACH,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAID;;;;;;;;;;;;;OAaG;IACH,YACkB,SAAoC,EACpC,MAA0B,EAC1B,eAAuB,EACvB,0BAAmC,KAAK,EACxC,sBAAsB,IAAI,GAAG,EAAoC;QAJjE,cAAS,GAAT,SAAS,CAA2B;QACpC,WAAM,GAAN,MAAM,CAAoB;QAC1B,oBAAe,GAAf,eAAe,CAAQ;QACvB,4BAAuB,GAAvB,uBAAuB,CAAiB;QACxC,wBAAmB,GAAnB,mBAAmB,CAA8C;QA9B3E,cAAS,GAAY,KAAK,CAAC;QASlB,oBAAe,GAAG,IAAI,GAAG,EAAsB,CAAC;IAsB9D,CAAC;IAEJ;;;;;;;;;;;;;;OAcG;IACI,OAAO,CACb,aAAsE,EACtE,SAAiB,EAAE;QAEnB,MAAM,KAAK,GAAG,IAAA,6BAAc,GAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;QACpC,MAAM,QAAQ,GA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,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;CACD;AA7KD,wDA6KC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport type { IDisposable, ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { roundToDecimalPlaces } from \"./mathTools.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * @privateRemarks\n *\n * The names of the properties in this interface are the ones that will get stamped in the\n * telemetry event, changes should be considered carefully. The optional properties should\n * only be populated if 'includeAggregateMetrics' is true.\n */\ninterface Measurements {\n\t/**\n\t * The duration of the latest execution.\n\t */\n\tduration: number;\n\n\t/**\n\t * The number of executions since the last time an event was generated.\n\t */\n\tcount: number;\n\n\t/**\n\t * Total duration across all the executions since the last event was generated.\n\t */\n\ttotalDuration?: number;\n\n\t/**\n\t * Min duration across all the executions since the last event was generated.\n\t */\n\tminDuration?: number;\n\n\t/**\n\t * Max duration across all the executions since the last event was generated.\n\t */\n\tmaxDuration?: number;\n\n\t/**\n\t * Average duration across all the executions since the last event was generated.\n\t */\n\taverageDuration?: number;\n}\n\n/**\n * The data that will be logged in the telemetry event.\n */\ninterface LoggerData {\n\tmeasurements: Measurements;\n\n\t/**\n\t * The sum of the custom data passed into the logger for each key.\n\t * Absence of a given key should be interpreted as 0.\n\t */\n\tdataSums: Record<string, number>;\n\n\t/**\n\t * The max of the custom data passed into the logger for each key.\n\t */\n\tdataMaxes: Record<string, number>;\n}\n\n/**\n * Helper type for an object whose properties are all numbers\n *\n * @internal\n */\nexport type CustomMetrics<TKey> = {\n\t[K in keyof TKey]: K extends string ? number : never;\n};\n\n/**\n * Potentially part of the structure of the return value of the function provided to {@link SampledTelemetryHelper.measure}.\n *\n * @see {@link MeasureReturnType} for more details on how this type is used.\n *\n * @internal\n */\nexport interface ICustomData<T> {\n\tcustomData: CustomMetrics<T>;\n}\n\n/**\n * Encapsulates the type-level logic for {@link SampledTelemetryHelper.measure}, to determine the expected return type\n * for the function that method receives (and by extension, its own return type). In words: {@link SampledTelemetryHelper}\n * is optionally provided with two generic types: one for custom metrics, and one for the actual return value of the\n * code that will be measured.\n *\n * - If no generic type is provided for custom metrics, then this type is simply the generic type provided for the actual\n * return value of the measured code (which could be void!).\n * - If a generic type is provided for custom metrics, then this type has a `customData` property whose type matches that\n * generic. Then if the generic type for the actual return value is not void, this type also has a property `returnValue`\n * whose type matches the generic type for the actual return value; if the generic type for the actual return value is\n * void, then this type _forbids_ a `returnValue` property (technically, it can exist but must be undefined in that case),\n * to try to ensure that the caller doesn't accidentally provide a function that actually returns a value.\n *\n * @internal\n */\nexport type MeasureReturnType<TMeasureReturn, TCustomMetrics> = TCustomMetrics extends void\n\t? TMeasureReturn\n\t: ICustomData<TCustomMetrics> &\n\t\t\t(TMeasureReturn extends void\n\t\t\t\t? Partial<Record<\"returnValue\", never>>\n\t\t\t\t: { returnValue: TMeasureReturn });\n\n/**\n * Helper class that executes a specified code block and writes an\n * {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified\n * number of executions is reached (or when the class is disposed).\n *\n * @remarks\n * The `duration` field in the telemetry event this class generates is the duration of the latest execution (sample)\n * of the specified code block.\n * See the documentation of the `includeAggregateMetrics` parameter for additional details that can be included.\n *\n * @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring\n * any custom metric data that might be required by this class. E.g., the code might just return a boolean.\n * @typeParam TCustomMetrics - A type that contains the custom properties that will be used by an instance of this class\n * for custom metrics. Each property in this type should be a number.\n *\n * @internal\n */\nexport class SampledTelemetryHelper<\n\tTMeasureReturn = void,\n\tTCustomMetrics extends CustomMetrics<TCustomMetrics> = void,\n> implements IDisposable\n{\n\tprivate _disposed: boolean = false;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IDisposable.disposed}\n\t */\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tprivate readonly measurementsMap = new Map<string, LoggerData>();\n\n\t/**\n\t * @param eventBase - Custom properties to include in the telemetry performance event when it is written.\n\t * @param logger - The logger to use to write the telemetry performance event.\n\t * @param sampleThreshold - Telemetry performance events will be generated every time we hit this many executions\n\t * of the code block.\n\t * @param includeAggregateMetrics - If set to `true`, the telemetry performance event will include aggregated\n\t * metrics (total duration, min duration, max duration) for all the executions in between generated events.\n\t * @param perBucketProperties - Map of strings that represent different buckets (which can be specified when calling\n\t * the 'measure' method), to properties which should be added to the telemetry event for that bucket.\n\t * If a bucket being measured does not have an entry in this map, no additional properties will be added to its\n\t * telemetry events. The following keys are reserved for use by this class: \"duration\", \"count\", \"totalDuration\",\n\t * \"minDuration\", \"maxDuration\". If any of them is specified as a key in one of the ITelemetryBaseProperties objects\n\t * in this map, that key-value pair will be ignored.\n\t */\n\tpublic constructor(\n\t\tprivate readonly eventBase: ITelemetryGenericEventExt,\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\t\tprivate readonly sampleThreshold: number,\n\t\tprivate readonly includeAggregateMetrics: boolean = false,\n\t\tprivate readonly perBucketProperties = new Map<string, ITelemetryBaseProperties>(),\n\t) {}\n\n\t/**\n\t * Executes the specified code and keeps track of execution time statistics.\n\t * When it's been called enough times (the sampleThreshold for the class) then it generates a log message with the\n\t * necessary information.\n\t *\n\t * @remarks It's the responsibility of the caller to ensure that the same same set of custom metric properties is\n\t * provided each time this method is called on a given instance of {@link SampledTelemetryHelper}.\n\t * Otherwise the final measurements in the telemetry event may not be accurate.\n\t *\n\t * @param codeToMeasure - The code to be executed and measured.\n\t * @param bucket - A key to track executions of the code block separately.\n\t * Each different value of this parameter has a separate set of executions and metrics tracked by the class.\n\t * If no such distinction needs to be made, do not provide a value.\n\t * @returns Whatever the passed-in code block returns.\n\t */\n\tpublic measure(\n\t\tcodeToMeasure: () => MeasureReturnType<TMeasureReturn, TCustomMetrics>,\n\t\tbucket: string = \"\",\n\t): MeasureReturnType<TMeasureReturn, TCustomMetrics> {\n\t\tconst start = performanceNow();\n\t\tconst returnValue = codeToMeasure();\n\t\tconst duration = performanceNow() - start;\n\n\t\tlet loggerData = this.measurementsMap.get(bucket);\n\t\tif (loggerData === undefined) {\n\t\t\tloggerData = {\n\t\t\t\tmeasurements: { count: 0, duration: -1 },\n\t\t\t\tdataSums: {},\n\t\t\t\tdataMaxes: {},\n\t\t\t};\n\t\t\tthis.measurementsMap.set(bucket, loggerData);\n\t\t}\n\n\t\tconst m = loggerData.measurements;\n\t\tm.count++;\n\t\tm.duration = duration;\n\n\t\tif (this.includeAggregateMetrics) {\n\t\t\tm.totalDuration = (m.totalDuration ?? 0) + duration;\n\t\t\tm.minDuration = Math.min(m.minDuration ?? duration, duration);\n\t\t\tm.maxDuration = Math.max(m.maxDuration ?? 0, duration);\n\t\t}\n\n\t\tif (this.isCustomData(returnValue)) {\n\t\t\tloggerData = this.accumulateCustomData(returnValue.customData, loggerData);\n\t\t}\n\n\t\tif (m.count >= this.sampleThreshold) {\n\t\t\t// Computed separately to avoid multiple division operations.\n\t\t\tif (this.includeAggregateMetrics) {\n\t\t\t\tm.averageDuration = (m.totalDuration ?? 0) / m.count;\n\t\t\t}\n\t\t\tthis.flushBucket(bucket);\n\t\t}\n\n\t\treturn returnValue;\n\t}\n\n\tprivate isCustomData(data: unknown): data is ICustomData<TCustomMetrics> {\n\t\treturn (\n\t\t\ttypeof data === \"object\" &&\n\t\t\tdata !== null &&\n\t\t\t\"customData\" in data &&\n\t\t\ttypeof data.customData === \"object\"\n\t\t);\n\t}\n\n\tprivate accumulateCustomData(\n\t\tcustomData: CustomMetrics<TCustomMetrics>,\n\t\tloggerData: LoggerData,\n\t): LoggerData {\n\t\tfor (const [key, val] of Object.entries(customData)) {\n\t\t\tassert(typeof key === \"string\", 0x9df /* Key should be a string */);\n\t\t\tassert(typeof val === \"number\", 0x9e0 /* Value should be a number */);\n\n\t\t\tloggerData.dataSums[key] = (loggerData.dataSums[key] ?? 0) + val;\n\t\t\tloggerData.dataMaxes[key] = Math.max(\n\t\t\t\tloggerData.dataMaxes[key] ?? Number.NEGATIVE_INFINITY,\n\t\t\t\tval,\n\t\t\t);\n\t\t}\n\n\t\treturn loggerData;\n\t}\n\n\tprivate processCustomData(loggerData: LoggerData, count: number): Record<string, number> {\n\t\tconst processedCustomData: Record<string, number> = {};\n\n\t\tif (loggerData.dataSums === undefined || loggerData.dataMaxes === undefined) {\n\t\t\treturn processedCustomData;\n\t\t}\n\n\t\tconst dataSums = loggerData.dataSums;\n\t\tconst dataMaxes = loggerData.dataMaxes;\n\n\t\tfor (const [key, val] of Object.entries(dataSums)) {\n\t\t\t// implementation of class guarantees the keys between dataMaxes and dataSums align.\n\t\t\tprocessedCustomData[`avg_${key}`] = roundToDecimalPlaces(val / count, 6);\n\t\t\tprocessedCustomData[`max_${key}`] = dataMaxes[key] ?? 0;\n\t\t}\n\n\t\treturn processedCustomData;\n\t}\n\n\tprivate flushBucket(bucket: string): void {\n\t\tconst loggerData = this.measurementsMap.get(bucket);\n\t\tif (loggerData === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst measurements = loggerData.measurements;\n\n\t\tconst processedCustomData = this.processCustomData(loggerData, measurements.count);\n\n\t\tif (measurements.count !== 0) {\n\t\t\tconst bucketProperties = this.perBucketProperties.get(bucket);\n\n\t\t\tconst telemetryEvent: ITelemetryPerformanceEventExt = {\n\t\t\t\t...this.eventBase,\n\t\t\t\t...bucketProperties, // If the bucket doesn't exist and this is undefined, things work as expected\n\t\t\t\t...measurements,\n\t\t\t\t...processedCustomData,\n\t\t\t};\n\n\t\t\tthis.logger.sendPerformanceEvent(telemetryEvent);\n\t\t\tthis.measurementsMap.delete(bucket);\n\t\t}\n\t}\n\n\tpublic dispose(error?: Error | undefined): void {\n\t\tfor (const [k] of this.measurementsMap.entries()) {\n\t\t\tthis.flushBucket(k);\n\t\t}\n\t\tthis._disposed = true;\n\t}\n}\n"]}
{"version":3,"file":"sampledTelemetryHelper.js","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,qEAA2D;AAC3D,kEAA6D;AAE7D,iDAAsD;AA2GtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,sBAAsB;IAOlC;;OAEG;IACH,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAID;;;;;;;;;;;;;OAaG;IACH,YACkB,SAAoC,EACpC,MAA0B,EAC1B,eAAuB,EACvB,0BAAmC,KAAK,EACxC,sBAAsB,IAAI,GAAG,EAAoC;QAJjE,cAAS,GAAT,SAAS,CAA2B;QACpC,WAAM,GAAN,MAAM,CAAoB;QAC1B,oBAAe,GAAf,eAAe,CAAQ;QACvB,4BAAuB,GAAvB,uBAAuB,CAAiB;QACxC,wBAAmB,GAAnB,mBAAmB,CAA8C;QA9B3E,cAAS,GAAY,KAAK,CAAC;QASlB,oBAAe,GAAG,IAAI,GAAG,EAAsB,CAAC;IAsB9D,CAAC;IAEJ;;;;;;;;;;;;;;OAcG;IACI,OAAO,CACb,aAAsE,EACtE,SAAiB,EAAE;QAEnB,MAAM,KAAK,GAAG,IAAA,6BAAc,GAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAA,6BAAc,GAAE,GAAG,KAAK,CAAC;QAE1C,IAAI,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,UAAU,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D,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;CACD;AAjLD,wDAiLC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport type { IDisposable, ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { roundToDecimalPlaces } from \"./mathTools.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * @privateRemarks\n *\n * The names of the properties in this interface are the ones that will get stamped in the\n * telemetry event, changes should be considered carefully. The optional properties should\n * only be populated if 'includeAggregateMetrics' is true.\n */\ninterface Measurements {\n\t/**\n\t * The duration of the latest execution.\n\t */\n\tduration: number;\n\n\t/**\n\t * The number of executions since the last time an event was generated.\n\t */\n\tcount: number;\n\n\t/**\n\t * Total duration across all the executions since the last event was generated.\n\t */\n\ttotalDuration?: number;\n\n\t/**\n\t * Min duration across all the executions since the last event was generated.\n\t */\n\tminDuration?: number;\n\n\t/**\n\t * Max duration across all the executions since the last event was generated.\n\t */\n\tmaxDuration?: number;\n\n\t/**\n\t * Average duration across all the executions since the last event was generated.\n\t */\n\taverageDuration?: number;\n}\n\n/**\n * The data that will be logged in the telemetry event.\n */\ninterface LoggerData {\n\tmeasurements: Measurements;\n\n\t/**\n\t * The sum of the custom data passed into the logger for each key.\n\t * Absence of a given key should be interpreted as 0.\n\t */\n\tdataSums: Record<string, number>;\n\n\t/**\n\t * The max of the custom data passed into the logger for each key.\n\t */\n\tdataMaxes: Record<string, number>;\n}\n\n/**\n * Helper type for an object whose properties are all numbers\n *\n * @internal\n */\nexport type CustomMetrics<TKey> = {\n\t[K in keyof TKey]: K extends string ? number : never;\n};\n\n/**\n * Potentially part of the structure of the return value of the function provided to {@link SampledTelemetryHelper.measure}.\n *\n * @see {@link MeasureReturnType} for more details on how this type is used.\n *\n * @internal\n */\nexport interface ICustomData<T> {\n\tcustomData: CustomMetrics<T>;\n}\n\n/**\n * Encapsulates the type-level logic for {@link SampledTelemetryHelper.measure}, to determine the expected return type\n * for the function that method receives (and by extension, its own return type). In words: {@link SampledTelemetryHelper}\n * is optionally provided with two generic types: one for custom metrics, and one for the actual return value of the\n * code that will be measured.\n *\n * - If no generic type is provided for custom metrics, then this type is simply the generic type provided for the actual\n * return value of the measured code (which could be void!).\n * - If a generic type is provided for custom metrics, then this type has a `customData` property whose type matches that\n * generic. Then if the generic type for the actual return value is not void, this type also has a property `returnValue`\n * whose type matches the generic type for the actual return value; if the generic type for the actual return value is\n * void, then this type _forbids_ a `returnValue` property (technically, it can exist but must be undefined in that case),\n * to try to ensure that the caller doesn't accidentally provide a function that actually returns a value.\n *\n * @internal\n */\nexport type MeasureReturnType<TMeasureReturn, TCustomMetrics> = TCustomMetrics extends void\n\t? TMeasureReturn\n\t: ICustomData<TCustomMetrics> &\n\t\t\t(TMeasureReturn extends void\n\t\t\t\t? Partial<Record<\"returnValue\", never>>\n\t\t\t\t: { returnValue: TMeasureReturn });\n\n/**\n * Helper class that executes a specified code block and writes an\n * {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified\n * number of executions is reached (or when the class is disposed).\n *\n * @remarks\n * The `duration` field in the telemetry event this class generates is the duration of the latest execution (sample)\n * of the specified code block.\n * See the documentation of the `includeAggregateMetrics` parameter for additional details that can be included.\n *\n * Telemetry events emitted by this class (both at the sample threshold and on dispose) are sent with\n * {@link @fluidframework/core-interfaces#LogLevelConst.info | LogLevel.info}.\n *\n * @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring\n * any custom metric data that might be required by this class. E.g., the code might just return a boolean.\n * @typeParam TCustomMetrics - A type that contains the custom properties that will be used by an instance of this class\n * for custom metrics. Each property in this type should be a number.\n *\n * @internal\n */\nexport class SampledTelemetryHelper<\n\tTMeasureReturn = void,\n\tTCustomMetrics extends CustomMetrics<TCustomMetrics> = void,\n> implements IDisposable\n{\n\tprivate _disposed: boolean = false;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IDisposable.disposed}\n\t */\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tprivate readonly measurementsMap = new Map<string, LoggerData>();\n\n\t/**\n\t * @param eventBase - Custom properties to include in the telemetry performance event when it is written.\n\t * @param logger - The logger to use to write the telemetry performance event.\n\t * @param sampleThreshold - Telemetry performance events will be generated every time we hit this many executions\n\t * of the code block.\n\t * @param includeAggregateMetrics - If set to `true`, the telemetry performance event will include aggregated\n\t * metrics (total duration, min duration, max duration) for all the executions in between generated events.\n\t * @param perBucketProperties - Map of strings that represent different buckets (which can be specified when calling\n\t * the 'measure' method), to properties which should be added to the telemetry event for that bucket.\n\t * If a bucket being measured does not have an entry in this map, no additional properties will be added to its\n\t * telemetry events. The following keys are reserved for use by this class: \"duration\", \"count\", \"totalDuration\",\n\t * \"minDuration\", \"maxDuration\". If any of them is specified as a key in one of the ITelemetryBaseProperties objects\n\t * in this map, that key-value pair will be ignored.\n\t */\n\tpublic constructor(\n\t\tprivate readonly eventBase: ITelemetryGenericEventExt,\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\t\tprivate readonly sampleThreshold: number,\n\t\tprivate readonly includeAggregateMetrics: boolean = false,\n\t\tprivate readonly perBucketProperties = new Map<string, ITelemetryBaseProperties>(),\n\t) {}\n\n\t/**\n\t * Executes the specified code and keeps track of execution time statistics.\n\t * When it's been called enough times (the sampleThreshold for the class) then it generates a log message with the\n\t * necessary information.\n\t *\n\t * @remarks It's the responsibility of the caller to ensure that the same same set of custom metric properties is\n\t * provided each time this method is called on a given instance of {@link SampledTelemetryHelper}.\n\t * Otherwise the final measurements in the telemetry event may not be accurate.\n\t *\n\t * @param codeToMeasure - The code to be executed and measured.\n\t * @param bucket - A key to track executions of the code block separately.\n\t * Each different value of this parameter has a separate set of executions and metrics tracked by the class.\n\t * If no such distinction needs to be made, do not provide a value.\n\t * @returns Whatever the passed-in code block returns.\n\t */\n\tpublic measure(\n\t\tcodeToMeasure: () => MeasureReturnType<TMeasureReturn, TCustomMetrics>,\n\t\tbucket: string = \"\",\n\t): MeasureReturnType<TMeasureReturn, TCustomMetrics> {\n\t\tconst start = performanceNow();\n\t\tconst returnValue = codeToMeasure();\n\t\tconst duration = performanceNow() - start;\n\n\t\tlet loggerData = this.measurementsMap.get(bucket);\n\t\tif (loggerData === undefined) {\n\t\t\tloggerData = {\n\t\t\t\tmeasurements: { count: 0, duration: -1 },\n\t\t\t\tdataSums: {},\n\t\t\t\tdataMaxes: {},\n\t\t\t};\n\t\t\tthis.measurementsMap.set(bucket, loggerData);\n\t\t}\n\n\t\tconst m = loggerData.measurements;\n\t\tm.count++;\n\t\tm.duration = duration;\n\n\t\tif (this.includeAggregateMetrics) {\n\t\t\tm.totalDuration = (m.totalDuration ?? 0) + duration;\n\t\t\tm.minDuration = Math.min(m.minDuration ?? duration, duration);\n\t\t\tm.maxDuration = Math.max(m.maxDuration ?? 0, duration);\n\t\t}\n\n\t\tif (this.isCustomData(returnValue)) {\n\t\t\tloggerData = this.accumulateCustomData(returnValue.customData, loggerData);\n\t\t}\n\n\t\tif (m.count >= this.sampleThreshold) {\n\t\t\t// Computed separately to avoid multiple division operations.\n\t\t\tif (this.includeAggregateMetrics) {\n\t\t\t\tm.averageDuration = (m.totalDuration ?? 0) / m.count;\n\t\t\t}\n\t\t\tthis.flushBucket(bucket);\n\t\t}\n\n\t\treturn returnValue;\n\t}\n\n\tprivate isCustomData(data: unknown): data is ICustomData<TCustomMetrics> {\n\t\treturn (\n\t\t\ttypeof data === \"object\" &&\n\t\t\tdata !== null &&\n\t\t\t\"customData\" in data &&\n\t\t\ttypeof data.customData === \"object\"\n\t\t);\n\t}\n\n\tprivate accumulateCustomData(\n\t\tcustomData: CustomMetrics<TCustomMetrics>,\n\t\tloggerData: LoggerData,\n\t): LoggerData {\n\t\tfor (const [key, val] of Object.entries(customData)) {\n\t\t\tassert(typeof key === \"string\", 0x9df /* Key should be a string */);\n\t\t\tassert(typeof val === \"number\", 0x9e0 /* Value should be a number */);\n\n\t\t\tloggerData.dataSums[key] = (loggerData.dataSums[key] ?? 0) + val;\n\t\t\tloggerData.dataMaxes[key] = Math.max(\n\t\t\t\tloggerData.dataMaxes[key] ?? Number.NEGATIVE_INFINITY,\n\t\t\t\tval,\n\t\t\t);\n\t\t}\n\n\t\treturn loggerData;\n\t}\n\n\tprivate processCustomData(loggerData: LoggerData, count: number): Record<string, number> {\n\t\tconst processedCustomData: Record<string, number> = {};\n\n\t\tif (loggerData.dataSums === undefined || loggerData.dataMaxes === undefined) {\n\t\t\treturn processedCustomData;\n\t\t}\n\n\t\tconst dataSums = loggerData.dataSums;\n\t\tconst dataMaxes = loggerData.dataMaxes;\n\n\t\tfor (const [key, val] of Object.entries(dataSums)) {\n\t\t\t// implementation of class guarantees the keys between dataMaxes and dataSums align.\n\t\t\tprocessedCustomData[`avg_${key}`] = roundToDecimalPlaces(val / count, 6);\n\t\t\tprocessedCustomData[`max_${key}`] = dataMaxes[key] ?? 0;\n\t\t}\n\n\t\treturn processedCustomData;\n\t}\n\n\tprivate flushBucket(bucket: string): void {\n\t\tconst loggerData = this.measurementsMap.get(bucket);\n\t\tif (loggerData === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst measurements = loggerData.measurements;\n\n\t\tconst processedCustomData = this.processCustomData(loggerData, measurements.count);\n\n\t\tif (measurements.count !== 0) {\n\t\t\tconst bucketProperties = this.perBucketProperties.get(bucket);\n\n\t\t\tconst telemetryEvent: ITelemetryPerformanceEventExt = {\n\t\t\t\t...this.eventBase,\n\t\t\t\t...bucketProperties, // If the bucket doesn't exist and this is undefined, things work as expected\n\t\t\t\t...measurements,\n\t\t\t\t...processedCustomData,\n\t\t\t};\n\n\t\t\tthis.logger.sendPerformanceEvent(\n\t\t\t\ttelemetryEvent,\n\t\t\t\tundefined, // error\n\t\t\t\tLogLevel.info,\n\t\t\t);\n\t\t\tthis.measurementsMap.delete(bucket);\n\t\t}\n\t}\n\n\tpublic dispose(error?: Error | undefined): void {\n\t\tfor (const [k] of this.measurementsMap.entries()) {\n\t\t\tthis.flushBucket(k);\n\t\t}\n\t\tthis._disposed = true;\n\t}\n}\n"]}

@@ -119,7 +119,8 @@ /*!

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @deprecated This method is being removed without a replacement.
* @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
*/
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
/**

@@ -137,7 +138,8 @@ * Send an error telemetry event.

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @deprecated This method is being removed without a replacement.
* @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
*/
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
}

@@ -157,5 +159,6 @@ /**

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.
* @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
/**

@@ -171,6 +174,7 @@ * Send an error telemetry event.

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevelConst.default | LogLevel.default}.
* @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
}
//# sourceMappingURL=telemetryTypes.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,C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E,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,IAAI,GACvD,IAAI,CAAC;CACR;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC/D;;;;;;OAMG;IACH,kBAAkB,CACjB,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,IAAI,GACvD,IAAI,CAAC;IAER;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtE;;;;;;OAMG;IACH,oBAAoB,CACnB,KAAK,EAAE,6BAA6B,EACpC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,IAAI,GACvD,IAAI,CAAC;CACR"}

@@ -1,1 +0,1 @@

{"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @legacy @beta\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @legacy @beta\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>\n>;\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * This is the externally facing type for a FluidFramework internal telemetry logger wrapper.\n *\n * @remarks\n * The methods if this interface are not to be used directly by consumers and are all\n * deprecated to removed without replacement. This type is not deprecated and will\n * transition to an erased type to handle cases where \"internal\" `ITelemetryLoggerExt`\n * previously leaked out.\n *\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for deprecation and breaking change details.\n *\n * @privateRemarks\n * External APIs taking in an `ITelemetryLoggerExt` ideally should be updated to\n * accept `ITelemetryBaseLogger` instead.\n *\n * @sealed\n * @legacy\n * @beta\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\n * This interface is meant to be used internally within the Fluid Framework,\n * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.\n * @internal\n */\nexport interface TelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevelConst.default | LogLevel.default}.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n}\n"]}
{"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @legacy @beta\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @legacy @beta\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>\n>;\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * This is the externally facing type for a FluidFramework internal telemetry logger wrapper.\n *\n * @remarks\n * The methods if this interface are not to be used directly by consumers and are all\n * deprecated to removed without replacement. This type is not deprecated and will\n * transition to an erased type to handle cases where \"internal\" `ITelemetryLoggerExt`\n * previously leaked out.\n *\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for deprecation and breaking change details.\n *\n * @privateRemarks\n * External APIs taking in an `ITelemetryLoggerExt` ideally should be updated to\n * accept `ITelemetryBaseLogger` instead.\n *\n * @sealed\n * @legacy\n * @beta\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\n * This interface is meant to be used internally within the Fluid Framework,\n * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.\n * @internal\n */\nexport interface TelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAEX,kBAAkB,EAClB,MAAM,iCAAiC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IAClE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,CAAC,EAAE,aAAa,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CA8CzB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAKlF"}
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAEX,kBAAkB,EAClB,MAAM,iCAAiC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IAClE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,CAAC,EAAE,aAAa,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CAsDzB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAKlF"}

@@ -29,3 +29,3 @@ "use strict";

const sampledLogger = {
send: (event) => {
send: (event, logLevel) => {
// The sampler uses the following logic for sending events:

@@ -39,6 +39,6 @@ // 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.

}
logger.send(event);
logger.send(event, logLevel);
}
},
sendTelemetryEvent: (event) => {
sendTelemetryEvent: (event, error, logLevel) => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -48,6 +48,6 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendTelemetryEvent(event);
logger.sendTelemetryEvent(event, error, logLevel);
}
},
sendErrorEvent: (event) => {
sendErrorEvent: (event, error) => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -57,6 +57,6 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendErrorEvent(event);
logger.sendErrorEvent(event, error);
}
},
sendPerformanceEvent: (event) => {
sendPerformanceEvent: (event, error, logLevel) => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -66,3 +66,3 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendPerformanceEvent(event);
logger.sendPerformanceEvent(event, error, logLevel);
}

@@ -69,0 +69,0 @@ },

@@ -1,1 +0,1 @@

{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2CAAwD;AAmCxD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,mBAAmB,CAClC,MAA0B,EAC1B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,IAAA,qCAAyB,EAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GACvB,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC,IAAI,KAAK,CAAC;IAEjF,MAAM,aAAa,GAAG;QACrB,IAAI,EAAE,CAAC,KAA0B,EAAQ,EAAE;YAC1C,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,0EAA0E;YAC1E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACF,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC9D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC1D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AAlDD,kDAkDC;AAED;;;;;;;GAOG;AACH,SAAgB,OAAO,CAAI,aAAsB;IAChD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;AALD,0BAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends TelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: TelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n\tskipLoggingWhenSamplingIsDisabled?: boolean,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.send(event);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendPerformanceEvent(event);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n\n/**\n * Runs the specified function and returns an object with the time it took to run as well as any output from it.\n * @remarks Useful in conjunction with {@link TelemetryEventBatcher}.\n *\n * @param codeToMeasure - The code to be executed and measured.\n * @returns The total duration of the code execution and whatever the passed-in code block returns.\n * @internal\n */\nexport function measure<T>(codeToMeasure: () => T): { duration: number; output: T } {\n\tconst start = performance.now();\n\tconst output = codeToMeasure();\n\tconst duration = performance.now() - start;\n\treturn { duration, output };\n}\n"]}
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2CAAwD;AAmCxD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,mBAAmB,CAClC,MAA0B,EAC1B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,IAAA,qCAAyB,EAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GACvB,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC,IAAI,KAAK,CAAC;IAEjF,MAAM,aAAa,GAAG;QACrB,IAAI,EAAE,CAAC,KAA0B,EAAE,QAAmB,EAAQ,EAAE;YAC/D,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,0EAA0E;YAC1E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,kBAAkB,EAAE,CACnB,KAAgC,EAChC,KAAe,EACf,QAAyD,EAClD,EAAE;YACT,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI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ors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent, LogLevel } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends TelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: TelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n\tskipLoggingWhenSamplingIsDisabled?: boolean,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent, logLevel?: LogLevel): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.send(event, logLevel);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (\n\t\t\tevent: ITelemetryGenericEventExt,\n\t\t\terror?: unknown,\n\t\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t\t): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendTelemetryEvent(event, error, logLevel);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt, error?: unknown): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendErrorEvent(event, error);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (\n\t\t\tevent: ITelemetryGenericEventExt,\n\t\t\terror?: unknown,\n\t\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t\t): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendPerformanceEvent(event, error, logLevel);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n\n/**\n * Runs the specified function and returns an object with the time it took to run as well as any output from it.\n * @remarks Useful in conjunction with {@link TelemetryEventBatcher}.\n *\n * @param codeToMeasure - The code to be executed and measured.\n * @returns The total duration of the code execution and whatever the passed-in code block returns.\n * @internal\n */\nexport function measure<T>(codeToMeasure: () => T): { duration: number; output: T } {\n\tconst start = performance.now();\n\tconst output = codeToMeasure();\n\tconst duration = performance.now() - start;\n\treturn { duration, output };\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEnF;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC3D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAC9C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;IACrD,cAAc,CAAC,IAAI,EAA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AAsB,CAAC,CAAC,SAAS,oBAAoB,GAAG,kBAAkB,EACzF,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,GAC7C,iBAAiB,CAAC,CAAC,CAAC,CAkBtB;AAOD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAC5C,iBAAiB,CAEnB;AAED;;KAEK;AACL,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,IAAI;KAClD,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAC9B,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,MAAM,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAC3E,SAAS;CACZ,CAAC;AAEF;;;;;;;;;;KAUK;AACL,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,MAAM,EAC7D,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,EACrC,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACzB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CA6BtB"}

@@ -5,2 +5,3 @@ /*!

*/
import { LogLevel } from "@fluidframework/core-interfaces";
import { Lazy } from "@fluidframework/core-utils/internal";

@@ -201,3 +202,3 @@ import { createChildLogger, tagCodeArtifacts } from "./logger.js";

}),
});
}, LogLevel.info);
return parsed;

@@ -204,0 +205,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,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AAE,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,yDAAyD;QACzD,sDAAsD;QACtD,oDAAoD;QACpD,0BAA0B;QAC1B,OAAO,EAAE,GAAwB,EAAE;YAClC,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAC7D,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tConfigTypes,\n\tIConfigProviderBase,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger, tagCodeArtifacts } from \"./logger.js\";\nimport type { ITelemetryLoggerExt, TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Creates a wrapper on top of an existing config provider which allows for\n * specifying feature gates if not present in the original provider.\n *\n * @param original - the original config provider\n * @param defaults - default feature gate configs to be used if not specified by the original provider\n * @returns A config provider that looks for any requested feature gates in the original provider and falls\n * back to the values specified in the `defaults` feature gates if they're not present in the original.\n *\n * @internal\n */\nexport const wrapConfigProviderWithDefaults = (\n\toriginal: IConfigProviderBase | undefined,\n\tdefaults: Record<string, ConfigTypes>,\n): IConfigProviderBase => ({\n\tgetRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],\n});\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tpublic constructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic getBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tpublic getNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tpublic getString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tpublic getBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tpublic getNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tpublic getStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tpublic getRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send({\n\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\t// Since this is an internal context, assume that any external logger type\n\t// (`ITelemetryLoggerExt`) is just the internal `TelemetryLoggerExt` type.\n\t// `extractTelemetryLoggerExt` can be used to extract the internal type, but\n\t// we'll just \"cast\" it here.\n\tlogger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\t// Cast is similar to `extractTelemetryLoggerExt` but preserves other\n\t// logger types rather than just returning `TelemetryLoggerExt`.\n\tmc.logger = logger as L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n\n/**\n * @internal\n * */\nexport type OptionConfigReaders<T extends object> = {\n\t[K in keyof T]?: K extends string\n\t\t? (config: IConfigProvider, name: `Fluid.${string}.${K}`) => T[K] | undefined\n\t\t: undefined;\n};\n\n/**\n * Creates a proxy object that allows for reading configuration values from a IConfigProviderBase,\n * and default to the provided options if the configuration value is not present.\n *\n * @param config - the configuration provider to read values from.\n * @param namespace - the namespace to use when reading configuration values.\n * @param configReaders - a mapping of option keys to configuration value readers.\n * @param defaultOptions - the default options to use if the configuration value is not present.\n *\n * @internal\n * */\nexport function createConfigBasedOptionsProxy<T extends object>(\n\tconfig: IConfigProviderBase,\n\tnamespace: `Fluid.${string}`,\n\tconfigReaders: OptionConfigReaders<T>,\n\tdefaultOptions?: Partial<T>,\n): Readonly<Partial<T>> {\n\tconst realConfig =\n\t\tconfig instanceof CachedConfigProvider\n\t\t\t? config\n\t\t\t: new CachedConfigProvider(undefined, config);\n\n\tconst keys = new Set<string>([\n\t\t...Object.keys(defaultOptions ?? {}),\n\t\t...Object.keys(configReaders),\n\t]);\n\n\treturn new Proxy<Partial<T>>(Object.freeze({}), {\n\t\tget: (_, prop: string & keyof T): unknown => {\n\t\t\tconst reader = configReaders[prop];\n\t\t\tconst value = reader?.(realConfig, `${namespace}.${prop}`);\n\t\t\tif (value !== undefined) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\treturn defaultOptions?.[prop];\n\t\t},\n\t\thas: (_, prop: string): boolean => keys.has(prop),\n\t\t// we don't want the keys of this object to be enumerable\n\t\t// as accessing them will trigger a config read, which\n\t\t// should only happen when the value is accessed via\n\t\t// a previously known key.\n\t\townKeys: (): (string | symbol)[] => {\n\t\t\tthrow new TypeError(\"OptionsProxy keys are not enumerable\");\n\t\t},\n\t});\n}\n"]}
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAgBlE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,IAAI,CAAsB,GAAG,EAAE,CAC9E,sBAAsB,CAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE;YAC1C,YAAY,EAAE,CAAC,IAAY,EAA2B,EAAE;gBACvD,IAAI,CAAC;oBACJ,OAAO,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,GAAG,CAAC;gBACpE,CAAC;gBAAC,MAAM,CAAC;oBACR,OAAO,SAAS,CAAC;gBAClB,CAAC;YACF,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC3B,CAAC,CAAC;AAaF,SAAS,eAAe,CAAC,IAAY;IACpC,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,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MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAC/C,GAAG,EAAE,CAAC,CAAC,EAAE,IAAsB,EAAW,EAAE;YAC3C,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,yDAAyD;QACzD,sDAAsD;QACtD,oDAAoD;QACpD,0BAA0B;QAC1B,OAAO,EAAE,GAAwB,EAAE;YAClC,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAC7D,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tConfigTypes,\n\tIConfigProviderBase,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger, tagCodeArtifacts } from \"./logger.js\";\nimport type { ITelemetryLoggerExt, TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Creates a wrapper on top of an existing config provider which allows for\n * specifying feature gates if not present in the original provider.\n *\n * @param original - the original config provider\n * @param defaults - default feature gate configs to be used if not specified by the original provider\n * @returns A config provider that looks for any requested feature gates in the original provider and falls\n * back to the values specified in the `defaults` feature gates if they're not present in the original.\n *\n * @internal\n */\nexport const wrapConfigProviderWithDefaults = (\n\toriginal: IConfigProviderBase | undefined,\n\tdefaults: Record<string, ConfigTypes>,\n): IConfigProviderBase => ({\n\tgetRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],\n});\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tpublic constructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic getBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tpublic getNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tpublic getString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tpublic getBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tpublic getNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tpublic getStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tpublic getRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tLogLevel.info,\n\t\t\t\t\t);\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\t// Since this is an internal context, assume that any external logger type\n\t// (`ITelemetryLoggerExt`) is just the internal `TelemetryLoggerExt` type.\n\t// `extractTelemetryLoggerExt` can be used to extract the internal type, but\n\t// we'll just \"cast\" it here.\n\tlogger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\t// Cast is similar to `extractTelemetryLoggerExt` but preserves other\n\t// logger types rather than just returning `TelemetryLoggerExt`.\n\tmc.logger = logger as L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n\n/**\n * @internal\n * */\nexport type OptionConfigReaders<T extends object> = {\n\t[K in keyof T]?: K extends string\n\t\t? (config: IConfigProvider, name: `Fluid.${string}.${K}`) => T[K] | undefined\n\t\t: undefined;\n};\n\n/**\n * Creates a proxy object that allows for reading configuration values from a IConfigProviderBase,\n * and default to the provided options if the configuration value is not present.\n *\n * @param config - the configuration provider to read values from.\n * @param namespace - the namespace to use when reading configuration values.\n * @param configReaders - a mapping of option keys to configuration value readers.\n * @param defaultOptions - the default options to use if the configuration value is not present.\n *\n * @internal\n * */\nexport function createConfigBasedOptionsProxy<T extends object>(\n\tconfig: IConfigProviderBase,\n\tnamespace: `Fluid.${string}`,\n\tconfigReaders: OptionConfigReaders<T>,\n\tdefaultOptions?: Partial<T>,\n): Readonly<Partial<T>> {\n\tconst realConfig =\n\t\tconfig instanceof CachedConfigProvider\n\t\t\t? config\n\t\t\t: new CachedConfigProvider(undefined, config);\n\n\tconst keys = new Set<string>([\n\t\t...Object.keys(defaultOptions ?? {}),\n\t\t...Object.keys(configReaders),\n\t]);\n\n\treturn new Proxy<Partial<T>>(Object.freeze({}), {\n\t\tget: (_, prop: string & keyof T): unknown => {\n\t\t\tconst reader = configReaders[prop];\n\t\t\tconst value = reader?.(realConfig, `${namespace}.${prop}`);\n\t\t\tif (value !== undefined) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\treturn defaultOptions?.[prop];\n\t\t},\n\t\thas: (_, prop: string): boolean => keys.has(prop),\n\t\t// we don't want the keys of this object to be enumerable\n\t\t// as accessing them will trigger a config read, which\n\t\t// should only happen when the value is accessed via\n\t\t// a previously known key.\n\t\townKeys: (): (string | symbol)[] => {\n\t\t\tthrow new TypeError(\"OptionsProxy keys are not enumerable\");\n\t\t},\n\t});\n}\n"]}

@@ -7,3 +7,3 @@ /*!

import type { ITelemetryLoggerExt, ITelemetryPropertiesExt, TelemetryLoggerExt, TelemetryEventPropertyTypeExt } from "./telemetryTypes.js";
import type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryPerformanceEventExt, TelemetryEventCategory } from "./telemetryTypesUndeprecated.js";
import type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryPerformanceEventExt } from "./telemetryTypesUndeprecated.js";
/**

@@ -123,6 +123,6 @@ * Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
/**

@@ -133,7 +133,5 @@ * Send a telemetry event with the logger

* @param error - optional error object to log
* @param logLevel - optional level of the log.
* @param logLevel - level of the log.
*/
protected sendTelemetryEventCore(event: ITelemetryGenericEventExt & {
category: TelemetryEventCategory;
}, error?: unknown, logLevel?: LogLevel): void;
private sendTelemetryEventCore;
/**

@@ -151,6 +149,6 @@ * Send an error telemetry event with the logger

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
protected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent;

@@ -279,3 +277,3 @@ private extendProperties;

*/
send(event: ITelemetryBaseEvent): void;
send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;
}

@@ -307,2 +305,3 @@ /**

private readonly emitLogs;
private readonly logLevel;
/**

@@ -316,5 +315,7 @@ * Creates an instance of {@link PerformanceEvent} and starts measurements

* but measurements will still be performed and any specified markers will be generated.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns An instance of {@link PerformanceEvent}
*/
static start(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean): PerformanceEvent;
static start(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): PerformanceEvent;
/**

@@ -328,2 +329,4 @@ * Measure a synchronous task

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -336,3 +339,3 @@ *

*/
static timedExec<T>(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number): T;
static timedExec<T>(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): T;
/**

@@ -347,2 +350,4 @@ * Measure an asynchronous task

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -355,3 +360,3 @@ *

*/
static timedExecAsync<T>(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, sampleThreshold?: number): Promise<T>;
static timedExecAsync<T>(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): Promise<T>;
get duration(): number;

@@ -361,3 +366,3 @@ private event?;

private startMark?;
protected constructor(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean);
private constructor();
reportProgress(props?: ITelemetryPropertiesExt, eventNameSuffix?: string): void;

@@ -364,0 +369,0 @@ private autoEnd;

@@ -1,1 +0,1 @@

{"version":3,"file":"logger.d.ts","s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D,CAAC,2CAGc,8BAA8B;;SAG3C,iBAAiB,YAAY;;;SAI7B,iBAAiB,YAAY;oDAG6C,CAAC"}

@@ -130,7 +130,7 @@ /*!

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendTelemetryEvent(event, error, logLevel = LogLevel.default) {
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? LogLevel.error : logLevel);
sendTelemetryEvent(event, error, logLevel) {
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential));
}

@@ -142,3 +142,3 @@ /**

* @param error - optional error object to log
* @param logLevel - optional level of the log.
* @param logLevel - level of the log.
*/

@@ -169,3 +169,3 @@ sendTelemetryEventCore(event, error, logLevel) {

category: "error",
}, error, LogLevel.error);
}, error, LogLevel.essential);
}

@@ -177,6 +177,6 @@ /**

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendPerformanceEvent(event, error, logLevel = LogLevel.default) {
sendPerformanceEvent(event, error, logLevel) {
const perfEvent = {

@@ -186,3 +186,3 @@ ...event,

};
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? LogLevel.error : logLevel);
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential));
}

@@ -366,4 +366,4 @@ prepareEvent(event) {

shouldFilterOutEvent(event, logLevel) {
const eventLogLevel = logLevel ?? LogLevel.default;
const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.default;
const eventLogLevel = logLevel ?? LogLevel.essential;
const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.info;
// Filter out in case event log level is below what is wanted in config.

@@ -381,3 +381,3 @@ return eventLogLevel < configLogLevel;

}
this.baseLogger.send(this.prepareEvent(event), logLevel);
this.baseLogger.send(this.prepareEvent(event), logLevel ?? LogLevel.essential);
}

@@ -423,3 +423,3 @@ }

this.loggers = loggers;
this._minLogLevelOfAllLoggers = LogLevel.default;
this._minLogLevelOfAllLoggers = LogLevel.info;
this.calculateMinLogLevel();

@@ -434,3 +434,3 @@ }

for (const logger of this.loggers) {
logLevels.push(logger.minLogLevel ?? LogLevel.default);
logLevels.push(logger.minLogLevel ?? LogLevel.info);
}

@@ -456,6 +456,6 @@ this._minLogLevelOfAllLoggers = Math.min(...logLevels);

*/
send(event) {
send(event, logLevel) {
const newEvent = this.prepareEvent(event);
for (const logger of this.loggers) {
logger.send(newEvent);
logger.send(newEvent, logLevel ?? LogLevel.essential);
}

@@ -478,6 +478,8 @@ }

* but measurements will still be performed and any specified markers will be generated.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns An instance of {@link PerformanceEvent}
*/
static start(logger, event, markers, emitLogs = true) {
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs);
static start(logger, event, markers, emitLogs = true, logLevel) {
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs, logLevel);
}

@@ -492,2 +494,4 @@ /**

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -500,4 +504,4 @@ *

*/
static timedExec(logger, event, callback, markers, sampleThreshold = 1) {
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
static timedExec(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
try {

@@ -522,2 +526,4 @@ const ret = callback(perfEvent);

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -530,4 +536,4 @@ *

*/
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1) {
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
try {

@@ -546,6 +552,7 @@ const ret = await callback(perfEvent);

}
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true) {
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true, logLevel) {
this.logger = logger;
this.markers = markers;
this.emitLogs = emitLogs;
this.logLevel = logLevel;
this.startTime = performanceNow();

@@ -613,3 +620,3 @@ this.event = { ...event };

}
this.logger.sendPerformanceEvent(event, error);
this.logger.sendPerformanceEvent(event, error, this.logLevel);
}

@@ -616,0 +623,0 @@ static shouldReport(event, sampleThreshold) {

@@ -1,1 +0,1 @@

{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAGN,QAAQ,GAGR,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,6BAA6B,EAC7B,aAAa,EACb,eAAe,EACf,8BAA8B,GAC9B,MAAM,mBAAmB,C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ACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IAClC,mDAAmD;KAClD,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IAClB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IACxB,iDAAiD;IACjD,kDAAkD;IAClD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QACjC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE;YACd,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAChC,CAAC,CAAC;IACH,CAAC;SAAM,CAAC;QACP,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC,EAAE,EAAE,CAA+B,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAM/B,MAAS,EAaR,EAAE,CAAC,OAAO,CAAmC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport {\n\ttype ITelemetryBaseEvent,\n\ttype ITelemetryBaseLogger,\n\tLogLevel,\n\ttype Tagged,\n\ttype TelemetryBaseEventPropertyType,\n} from \"@fluidframework/core-interfaces\";\n\nimport {\n\tCachedConfigProvider,\n\tloggerIsMonitoringContext,\n\tmixinMonitoringContext,\n} from \"./config.js\";\nimport {\n\textractLogSafeErrorProperties,\n\tgenerateStack,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n} from \"./errorLogging.js\";\nimport type {\n\tITelemetryEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n\tTelemetryLoggerExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes.js\";\nimport type {\n\tITelemetryErrorEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.\n * @internal\n */\nexport function toITelemetryLoggerExt(logger: TelemetryLoggerExt): ITelemetryLoggerExt {\n\treturn logger as unknown as ITelemetryLoggerExt;\n}\n\n/**\n * Un-type-erase the {@link ITelemetryLoggerExt}.\n * @remarks\n * This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.\n *\n * @typeParam options - options for the extraction, currently only supports making\n * the output possibly undefined (when `PossiblyUndefined: true`), which is useful\n * for cases where we want to allow passing `undefined` through.\n *\n * @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will\n * be when the breaking change is made. At that time, use of this helper will be\n * required.\n *\n * @internal\n */\nexport function extractTelemetryLoggerExt<\n\toptions extends {\n\t\tPossiblyUndefined?: true;\n\t} = // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty object without PossiblyUndefined is the correct type\n\t{},\n>(\n\tinput:\n\t\t| ITelemetryLoggerExt\n\t\t| TelemetryLoggerExt\n\t\t| (options[\"PossiblyUndefined\"] extends true ? undefined : never),\n): TelemetryLoggerExt | (options[\"PossiblyUndefined\"] extends true ? undefined : never) {\n\treturn input as unknown as TelemetryLoggerExt;\n}\n\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n *\n * @privateRemarks Please do not modify existing entries, to maintain backwards compatibility.\n *\n * @internal\n */\nexport enum TelemetryDataTag {\n\t/**\n\t * Data containing terms or IDs from code packages that may have been dynamically loaded\n\t */\n\tCodeArtifact = \"CodeArtifact\",\n\t/**\n\t * Personal data of a variety of classifications that pertains to the user\n\t */\n\tUserData = \"UserData\",\n}\n\n/**\n * @legacy\n * @beta\n */\nexport type TelemetryEventPropertyTypes = ITelemetryPropertiesExt[string];\n\n/**\n * @legacy\n * @beta\n */\nexport type ITelemetryLoggerPropertyBag = Record<\n\tstring,\n\tTelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes)\n>;\n\n/**\n * @legacy\n * @beta\n *\n * @privateRemarks\n * This is exposed to support {@link createChildLogger} properties parameter.\n */\nexport interface ITelemetryLoggerPropertyBags {\n\tall?: ITelemetryLoggerPropertyBag;\n\terror?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * Attempts to parse number from string.\n * If it fails, it will return the original string.\n *\n * @remarks\n * Used to make telemetry data typed (and support math operations, like comparison),\n * in places where we do expect numbers (like contentsize/duration property in http header).\n *\n * @internal\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function numberFromString(str: string | null | undefined): string | number | undefined {\n\tif (str === undefined || str === null) {\n\t\treturn undefined;\n\t}\n\tconst num = Number(str);\n\treturn Number.isNaN(num) ? str : num;\n}\n\n// TODO: add docs\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function formatTick(tick: number): number {\n\treturn Math.floor(tick);\n}\n\n/**\n * String used to concatenate the namespace of parent loggers and their child loggers.\n * @internal\n */\nexport const eventNamespaceSeparator = \":\";\n\n/**\n * TelemetryLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport abstract class TelemetryLogger implements TelemetryLoggerExt {\n\t/**\n\t * {@inheritDoc eventNamespaceSeparator}\n\t */\n\tpublic static readonly eventNamespaceSeparator = eventNamespaceSeparator;\n\n\tpublic static sanitizePkgName(name: string): string {\n\t\treturn name.replace(\"@\", \"\").replace(\"/\", \"-\");\n\t}\n\n\t/**\n\t * Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied\n\t * over from the error object, along with other telemetry properties if it's an ILoggingError.\n\t * @param event - Event being logged\n\t * @param error - Error to extract info from\n\t * @param fetchStack - Whether to fetch the current callstack if error.stack is undefined\n\t */\n\tpublic static prepareErrorObject(\n\t\tevent: ITelemetryBaseEvent,\n\t\terror: unknown,\n\t\tfetchStack: boolean,\n\t): void {\n\t\tconst { message, errorType, stack } = extractLogSafeErrorProperties(\n\t\t\terror,\n\t\t\ttrue /* sanitizeStack */,\n\t\t);\n\t\t// First, copy over error message, stack, and errorType directly (overwrite if present on event)\n\t\tevent.stack = stack;\n\t\tevent.error = message; // Note that the error message goes on the 'error' field\n\t\tevent.errorType = errorType;\n\n\t\tif (isILoggingError(error)) {\n\t\t\t// Add any other telemetry properties from the LoggingError\n\t\t\tconst telemetryProp = error.getTelemetryProperties();\n\t\t\tfor (const key of Object.keys(telemetryProp)) {\n\t\t\t\tif (event[key] !== undefined) {\n\t\t\t\t\t// Don't overwrite existing properties on the event\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tevent[key] = telemetryProp[key];\n\t\t\t}\n\t\t}\n\n\t\t// Collect stack if we were not able to extract it from error\n\t\tif (event.stack === undefined && fetchStack) {\n\t\t\tevent.stack = generateStack();\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprotected readonly namespace?: string,\n\t\tprotected readonly properties?: ITelemetryLoggerPropertyBags,\n\t) {}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic abstract send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log. It category of event is set as error,\n\t * then the logLevel will be upgraded to be an error.\n\t */\n\tpublic sendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default,\n\t): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{ ...event, category: event.category ?? \"generic\" },\n\t\t\terror,\n\t\t\tevent.category === \"error\" ? LogLevel.error : logLevel,\n\t\t);\n\t}\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log.\n\t */\n\tprotected sendTelemetryEventCore(\n\t\tevent: ITelemetryGenericEventExt & { category: TelemetryEventCategory },\n\t\terror?: unknown,\n\t\tlogLevel?: LogLevel,\n\t): void {\n\t\tconst newEvent = convertToBaseEvent(event);\n\t\tif (error !== undefined) {\n\t\t\tTelemetryLogger.prepareErrorObject(newEvent, error, false);\n\t\t}\n\n\t\t// Will include Nan & Infinity, but probably we do not care\n\t\tif (typeof newEvent.duration === \"number\") {\n\t\t\tnewEvent.duration = formatTick(newEvent.duration);\n\t\t}\n\n\t\tthis.send(newEvent, logLevel);\n\t}\n\n\t/**\n\t * Send an error telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{\n\t\t\t\t// ensure the error field has some value,\n\t\t\t\t// this can and will be overridden by event, or error\n\t\t\t\terror: event.eventName,\n\t\t\t\t...event,\n\t\t\t\tcategory: \"error\",\n\t\t\t},\n\t\t\terror,\n\t\t\tLogLevel.error,\n\t\t);\n\t}\n\n\t/**\n\t * Send a performance telemetry event with the logger\n\t *\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log. It category of event is set as error,\n\t * then the logLevel will be upgraded to be an error.\n\t */\n\tpublic sendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default,\n\t): void {\n\t\tconst perfEvent = {\n\t\t\t...event,\n\t\t\tcategory: event.category ?? \"performance\",\n\t\t};\n\n\t\tthis.sendTelemetryEventCore(\n\t\t\tperfEvent,\n\t\t\terror,\n\t\t\tperfEvent.category === \"error\" ? LogLevel.error : logLevel,\n\t\t);\n\t}\n\n\tprotected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent {\n\t\tconst includeErrorProps = event.category === \"error\" || event.error !== undefined;\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\t...event,\n\t\t};\n\t\tif (this.namespace !== undefined) {\n\t\t\tnewEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;\n\t\t}\n\t\treturn this.extendProperties(newEvent, includeErrorProps);\n\t}\n\n\tprivate extendProperties<\n\t\tT extends ITelemetryLoggerPropertyBag = ITelemetryLoggerPropertyBag,\n\t>(toExtend: T, includeErrorProps: boolean): T {\n\t\tconst eventLike: ITelemetryLoggerPropertyBag = toExtend;\n\t\tif (this.properties) {\n\t\t\tconst properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];\n\t\t\tproperties.push(this.properties.all);\n\t\t\tif (includeErrorProps) {\n\t\t\t\tproperties.push(this.properties.error);\n\t\t\t}\n\t\t\tfor (const props of properties) {\n\t\t\t\tif (props !== undefined) {\n\t\t\t\t\tfor (const [key, getterOrValue] of Object.entries(props)) {\n\t\t\t\t\t\tif (eventLike[key] !== undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If this throws, hopefully it is handled elsewhere\n\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\ttypeof getterOrValue === \"function\" ? getterOrValue() : getterOrValue;\n\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\teventLike[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn toExtend;\n\t}\n}\n\n/**\n * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from\n * container-runtime. Issue: #8191\n * TaggedLoggerAdapter class can add tag handling to your logger.\n *\n * @internal\n */\nexport class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n\tpublic constructor(private readonly logger: ITelemetryBaseLogger) {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(eventWithTagsMaybe: ITelemetryBaseEvent): void {\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\tcategory: eventWithTagsMaybe.category,\n\t\t\teventName: eventWithTagsMaybe.eventName,\n\t\t};\n\t\tfor (const [key, taggableProp] of Object.entries(eventWithTagsMaybe)) {\n\t\t\tconst { value, tag } =\n\t\t\t\ttypeof taggableProp === \"object\"\n\t\t\t\t\t? taggableProp\n\t\t\t\t\t: { value: taggableProp, tag: undefined };\n\t\t\tswitch (tag) {\n\t\t\t\tcase undefined: {\n\t\t\t\t\t// No tag means we can log plainly\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"PackageData\": // For back-compat\n\t\t\t\tcase TelemetryDataTag.CodeArtifact: {\n\t\t\t\t\t// For Microsoft applications, CodeArtifact is safe for now\n\t\t\t\t\t// (we don't load 3P code in 1P apps)\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TelemetryDataTag.UserData: {\n\t\t\t\t\t// Strip out anything tagged explicitly as UserData.\n\t\t\t\t\t// Alternate strategy would be to hash these props\n\t\t\t\t\tnewEvent[key] = \"REDACTED (UserData)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\t// If we encounter a tag we don't recognize\n\t\t\t\t\t// then we must assume we should scrub.\n\t\t\t\t\tnewEvent[key] = \"REDACTED (unknown tag)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.logger.send(newEvent);\n\t}\n}\n\nfunction toEitherTelemetryLoggerExt(\n\tlogger: TelemetryLoggerExt,\n): TelemetryLoggerExt & ITelemetryLoggerExt {\n\treturn logger as TelemetryLoggerExt & ITelemetryLoggerExt;\n}\n\n/**\n * Create a child logger based on the provided props object.\n *\n * @remarks\n * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.\n *\n * @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.\n *\n * @internal\n *\n * @privateRemarks\n * Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for\n * easier internal usage without needing to type erase or un-type-erase the\n * logger.\n *\n * If always creating a child logger for direct external exposure, consider\n * using {@link createChildLogger} from /legacy API instead, which returns\n * exactly an {@link ITelemetryLoggerExt}.\n */\nexport function createChildLogger(props?: {\n\tlogger?: ITelemetryBaseLogger;\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n}): TelemetryLoggerExt & ITelemetryLoggerExt {\n\treturn toEitherTelemetryLoggerExt(\n\t\tChildLogger.create(props?.logger, props?.namespace, props?.properties),\n\t);\n}\n\n/**\n * ChildLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events.\n */\nexport class ChildLogger extends TelemetryLogger {\n\t/**\n\t * Create child logger\n\t * @param baseLogger - Base logger to use to output events. If undefined, proper child logger\n\t * is created, but it does not send telemetry events anywhere.\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t */\n\tpublic static create(\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// if we are creating a child of a child, rather than nest, which will increase\n\t\t// the callstack overhead, just generate a new logger that includes everything from the previous\n\t\tif (baseLogger instanceof ChildLogger) {\n\t\t\tconst combinedProperties: ITelemetryLoggerPropertyBags = {};\n\t\t\tfor (const extendedProps of [baseLogger.properties, properties]) {\n\t\t\t\tif (extendedProps !== undefined) {\n\t\t\t\t\tif (extendedProps.all !== undefined) {\n\t\t\t\t\t\tcombinedProperties.all = {\n\t\t\t\t\t\t\t...combinedProperties.all,\n\t\t\t\t\t\t\t...extendedProps.all,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (extendedProps.error !== undefined) {\n\t\t\t\t\t\tcombinedProperties.error = {\n\t\t\t\t\t\t\t...combinedProperties.error,\n\t\t\t\t\t\t\t...extendedProps.error,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst combinedNamespace =\n\t\t\t\tbaseLogger.namespace === undefined\n\t\t\t\t\t? namespace\n\t\t\t\t\t: namespace === undefined\n\t\t\t\t\t\t? baseLogger.namespace\n\t\t\t\t\t\t: `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;\n\n\t\t\tconst child = new ChildLogger(\n\t\t\t\tbaseLogger.baseLogger,\n\t\t\t\tcombinedNamespace,\n\t\t\t\tcombinedProperties,\n\t\t\t);\n\n\t\t\tif (!loggerIsMonitoringContext(child) && loggerIsMonitoringContext(baseLogger)) {\n\t\t\t\tmixinMonitoringContext(child, baseLogger.config);\n\t\t\t}\n\t\t\treturn child;\n\t\t}\n\n\t\treturn new ChildLogger(baseLogger ?? { send(): void {} }, namespace, properties);\n\t}\n\n\tprivate constructor(\n\t\tprotected readonly baseLogger: ITelemetryBaseLogger,\n\t\tnamespace: string | undefined,\n\t\tproperties: ITelemetryLoggerPropertyBags | undefined,\n\t) {\n\t\tsuper(namespace, properties);\n\n\t\t// propagate the monitoring context\n\t\tif (loggerIsMonitoringContext(baseLogger)) {\n\t\t\tmixinMonitoringContext(this, new CachedConfigProvider(this, baseLogger.config));\n\t\t}\n\t}\n\n\tpublic get minLogLevel(): LogLevel | undefined {\n\t\treturn this.baseLogger.minLogLevel;\n\t}\n\n\tprivate shouldFilterOutEvent(event: ITelemetryBaseEvent, logLevel?: LogLevel): boolean {\n\t\tconst eventLogLevel = logLevel ?? LogLevel.default;\n\t\tconst configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.default;\n\t\t// Filter out in case event log level is below what is wanted in config.\n\t\treturn eventLogLevel < configLogLevel;\n\t}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tif (this.shouldFilterOutEvent(event, logLevel)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.baseLogger.send(this.prepareEvent(event), logLevel);\n\t}\n}\n\n/**\n * Input properties for {@link createMultiSinkLogger}.\n *\n * @internal\n */\nexport interface MultiSinkLoggerProperties {\n\t/**\n\t * Will be prefixed to all event names.\n\t */\n\tnamespace?: string;\n\n\t/**\n\t * Default properties that will be applied to all events flowing through this logger.\n\t */\n\tproperties?: ITelemetryLoggerPropertyBags;\n\n\t/**\n\t * The base loggers that this logger will forward the logs to, after it processes them.\n\t */\n\tloggers?: (ITelemetryBaseLogger | undefined)[];\n\n\t/**\n\t * If true, the logger will attempt to copy the custom properties (if they are of a known type, i.e. one from this package) of all the base loggers passed to it, to apply them itself to logs that flow through.\n\t */\n\ttryInheritProperties?: true;\n}\n\n/**\n * Create a logger which logs to multiple other loggers based on the provided props object.\n *\n * @internal\n */\nexport function createMultiSinkLogger(props: MultiSinkLoggerProperties): TelemetryLoggerExt {\n\treturn new MultiSinkLogger(\n\t\tprops.namespace,\n\t\tprops.properties,\n\t\tprops.loggers?.filter((l): l is ITelemetryBaseLogger => l !== undefined),\n\t\tprops.tryInheritProperties,\n\t);\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n\tprotected loggers: ITelemetryBaseLogger[];\n\t// This is minimum of minLlogLevel of all loggers.\n\tprivate _minLogLevelOfAllLoggers: LogLevel;\n\n\t/**\n\t * Create multiple sink logger (i.e. logger that sends events to multiple sinks)\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param loggers - The list of loggers to use as sinks\n\t * @param tryInheritProperties - Will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n\t */\n\tpublic constructor(\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t\tloggers: ITelemetryBaseLogger[] = [],\n\t\ttryInheritProperties?: true,\n\t) {\n\t\tlet realProperties = properties === undefined ? undefined : { ...properties };\n\t\tif (tryInheritProperties === true) {\n\t\t\tconst merge = (realProperties ??= {});\n\t\t\tloggers\n\t\t\t\t.filter((l): l is this => l instanceof TelemetryLogger)\n\t\t\t\t.map((l) => l.properties ?? {})\n\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t.forEach((cv) => {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t\tObject.keys(cv).forEach((k) => {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\tmerge[k] = { ...cv[k], ...merge?.[k] };\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\n\t\tsuper(namespace, realProperties);\n\t\tthis.loggers = loggers;\n\t\tthis._minLogLevelOfAllLoggers = LogLevel.default;\n\t\tthis.calculateMinLogLevel();\n\t}\n\n\tpublic get minLogLevel(): LogLevel {\n\t\treturn this._minLogLevelOfAllLoggers;\n\t}\n\n\tprivate calculateMinLogLevel(): void {\n\t\tif (this.loggers.length > 0) {\n\t\t\tconst logLevels: LogLevel[] = [];\n\t\t\tfor (const logger of this.loggers) {\n\t\t\t\tlogLevels.push(logger.minLogLevel ?? LogLevel.default);\n\t\t\t}\n\t\t\tthis._minLogLevelOfAllLoggers = Math.min(...logLevels) as LogLevel;\n\t\t}\n\t}\n\n\t/**\n\t * Add logger to send all events to\n\t * @param logger - Logger to add\n\t */\n\tpublic addLogger(logger?: ITelemetryBaseLogger): void {\n\t\tif (logger !== undefined && logger !== null) {\n\t\t\tthis.loggers.push(logger);\n\t\t\t// Update in case the logLevel of added logger is less than the current.\n\t\t\tthis.calculateMinLogLevel();\n\t\t}\n\t}\n\n\t/**\n\t * Send an event to the loggers\n\t *\n\t * @param event - the event to send to all the registered logger\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tconst newEvent = this.prepareEvent(event);\n\t\tfor (const logger of this.loggers) {\n\t\t\tlogger.send(newEvent);\n\t\t}\n\t}\n}\n\n/**\n * Describes what events {@link PerformanceEvent} should log.\n *\n * @remarks\n * By default, all events are logged, but the client can override this behavior.\n *\n * For example, there is rarely a need to record a start event, as we're really after\n * success / failure tracking, including duration (on success).\n *\n * @internal\n */\nexport interface IPerformanceEventMarkers {\n\tstart?: true;\n\tend?: true;\n\tcancel?: \"generic\" | \"error\"; // tells wether to issue \"generic\" or \"error\" category cancel event\n}\n\n/**\n * Helper class to log performance events.\n *\n * @internal\n */\nexport class PerformanceEvent {\n\t/**\n\t * Creates an instance of {@link PerformanceEvent} and starts measurements\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,\n\t * but measurements will still be performed and any specified markers will be generated.\n\t * @returns An instance of {@link PerformanceEvent}\n\t */\n\tpublic static start(\n\t\tlogger: TelemetryLoggerExt | ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\temitLogs: boolean = true,\n\t): PerformanceEvent {\n\t\treturn new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs);\n\t}\n\n\t/**\n\t * Measure a synchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static timedExec<T>(\n\t\tlogger: TelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tcallback: (event: PerformanceEvent) => T,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t): T {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t);\n\t\ttry {\n\t\t\tconst ret = callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Measure an asynchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static async timedExecAsync<T>(\n\t\tlogger: TelemetryLoggerExt | ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tcallback: (event: PerformanceEvent) => Promise<T>,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t): Promise<T> {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t);\n\t\ttry {\n\t\t\tconst ret = await callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic get duration(): number {\n\t\treturn performanceNow() - this.startTime;\n\t}\n\n\tprivate event?: ITelemetryGenericEventExt;\n\tprivate readonly startTime = performanceNow();\n\tprivate startMark?: string;\n\n\tprotected constructor(\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tprivate readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n\t\tprivate readonly emitLogs: boolean = true,\n\t) {\n\t\tthis.event = { ...event };\n\t\tif (this.markers.start) {\n\t\t\tthis.reportEvent(\"start\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof window === \"object\" &&\n\t\t\twindow?.performance?.mark !== undefined &&\n\t\t\twindow?.performance?.mark !== null\n\t\t) {\n\t\t\tthis.startMark = `${event.eventName}-start`;\n\t\t\twindow.performance.mark(this.startMark);\n\t\t}\n\t}\n\n\tpublic reportProgress(\n\t\tprops?: ITelemetryPropertiesExt,\n\t\teventNameSuffix: string = \"update\",\n\t): void {\n\t\tthis.reportEvent(eventNameSuffix, props);\n\t}\n\n\tprivate autoEnd(): void {\n\t\t// Event might have been cancelled or ended in the callback\n\t\tif (this.event && this.markers.end) {\n\t\t\tthis.reportEvent(\"end\");\n\t\t}\n\t\tthis.performanceEndMark();\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\tpublic end(props?: ITelemetryPropertiesExt): void {\n\t\tthis.reportEvent(\"end\", props);\n\t\tthis.performanceEndMark();\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\tprivate performanceEndMark(): void {\n\t\tif (this.startMark !== undefined && this.event) {\n\t\t\tconst endMark = `${this.event.eventName}-end`;\n\t\t\twindow.performance.mark(endMark);\n\t\t\twindow.performance.measure(`${this.event.eventName}`, this.startMark, endMark);\n\t\t\tthis.startMark = undefined;\n\t\t}\n\t}\n\n\tpublic cancel(props?: ITelemetryPropertiesExt, error?: unknown): void {\n\t\tif (this.markers.cancel !== undefined) {\n\t\t\tthis.reportEvent(\"cancel\", { category: this.markers.cancel, ...props }, error);\n\t\t}\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\t/**\n\t * Report the event, if it hasn't already been reported.\n\t */\n\tpublic reportEvent(\n\t\teventNameSuffix: string,\n\t\tprops?: ITelemetryPropertiesExt,\n\t\terror?: unknown,\n\t): void {\n\t\t// If the caller invokes cancel or end directly inside the callback for timedExec[Async],\n\t\t// then it's possible to come back through reportEvent twice. Only the first time counts.\n\t\tif (!this.event) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.emitLogs) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst event: ITelemetryPerformanceEventExt = { ...this.event, ...props };\n\t\tevent.eventName = `${event.eventName}_${eventNameSuffix}`;\n\t\tif (eventNameSuffix !== \"start\") {\n\t\t\tevent.duration = this.duration;\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(event, error);\n\t}\n\n\tprivate static readonly eventHits = new Map<string, number>();\n\tprivate static shouldReport(\n\t\tevent: ITelemetryGenericEventExt,\n\t\tsampleThreshold: number,\n\t): boolean {\n\t\tconst eventKey = `.${event.category}.${event.eventName}`;\n\t\tconst hitCount = PerformanceEvent.eventHits.get(eventKey) ?? 0;\n\t\tPerformanceEvent.eventHits.set(eventKey, hitCount >= sampleThreshold ? 1 : hitCount + 1);\n\t\treturn hitCount % sampleThreshold === 0;\n\t}\n}\n\n/**\n * Takes in an event object, and converts all of its values to a basePropertyType.\n * In the case of an invalid property type, the value will be converted to an error string.\n * @param event - Event with fields you want to stringify.\n */\nfunction convertToBaseEvent({\n\tcategory,\n\teventName,\n\t...props\n}: ITelemetryEventExt): ITelemetryBaseEvent {\n\tconst newEvent: ITelemetryBaseEvent = { category, eventName };\n\tfor (const key of Object.keys(props)) {\n\t\tnewEvent[key] = convertToBasePropertyType(props[key]);\n\t}\n\treturn newEvent;\n}\n\n/**\n * Takes in value, and does one of 4 things.\n * if value is of primitive type - returns the original value.\n * If the value is a flat array or object - returns a stringified version of the array/object.\n * If the value is an object of type Tagged<TelemetryBaseEventPropertyType> - returns the object\n * with its values recursively converted to base property Type.\n * If none of these cases are reached - returns an error string\n * @param x - value passed in to convert to a base property type\n */\nexport function convertToBasePropertyType(\n\tx: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>,\n): TelemetryBaseEventPropertyType | Tagged<TelemetryBaseEventPropertyType> {\n\treturn isTaggedTelemetryPropertyValue(x)\n\t\t? {\n\t\t\t\tvalue: convertToBasePropertyTypeUntagged(x.value),\n\t\t\t\ttag: x.tag,\n\t\t\t}\n\t\t: convertToBasePropertyTypeUntagged(x);\n}\n\nfunction convertToBasePropertyTypeUntagged(\n\tx: TelemetryEventPropertyTypeExt,\n): TelemetryBaseEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\": {\n\t\t\treturn x;\n\t\t}\n\t\tcase \"object\": {\n\t\t\t// We assume this is an array or flat object based on the input types\n\t\t\treturn JSON.stringify(x);\n\t\t}\n\t\tdefault: {\n\t\t\t// should never reach this case based on the input types\n\t\t\tconsole.error(\n\t\t\t\t`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`,\n\t\t\t);\n\t\t\treturn `INVALID PROPERTY (typed as ${typeof x})`;\n\t\t}\n\t}\n}\n\n/**\n * Tags all given `values` with the same `tag`.\n *\n * @param tag - The tag with which all `values` will be annotated.\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagData(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged.\n *\n * @internal\n */\nexport const tagData = <\n\tT extends TelemetryDataTag,\n\tV extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\ttag: T,\n\tvalues: V,\n): {\n\t[P in keyof V]:\n\t\t| (V[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<V[P]>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<V[P], undefined>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t\t})\n\t\t| (V[P] extends undefined ? undefined : never);\n} =>\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\tObject.entries(values)\n\t\t.filter((e) => e[1] !== undefined)\n\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t.reduce((pv, cv) => {\n\t\t\tconst [key, value] = cv;\n\t\t\t// The ternary form is less legible in this case.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tpv[key] = () => {\n\t\t\t\t\treturn { tag, value: value() };\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tpv[key] = { tag, value };\n\t\t\t}\n\t\t\treturn pv;\n\t\t}, {}) as ReturnType<typeof tagData>;\n\n/**\n * Tags all provided `values` as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagCodeArtifacts(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @see {@link tagData}\n *\n * @internal\n */\nexport const tagCodeArtifacts = <\n\tT extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\tvalues: T,\n): {\n\t[P in keyof T]:\n\t\t| (T[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<T[P]>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<T[P], undefined>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t\t})\n\t\t| (T[P] extends undefined ? undefined : never);\n} => tagData<TelemetryDataTag.CodeArtifact, T>(TelemetryDataTag.CodeArtifact, values);\n"]}
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAGN,QAAQ,GAGR,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,6BAA6B,EAC7B,aAAa,EACb,eAAe,EACf,8BAA8B,GAC9B,MAAM,mBAAmB,CAAC;AAe3B;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA0B;IAC/D,OAAO,MAAwC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,yBAAyB,CAMxC,KAGkE;IAElE,OAAO,KAAsC,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAA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AC/D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;KACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IAClC,mDAAmD;KAClD,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IAClB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IACxB,iDAAiD;IACjD,kDAAkD;IAClD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QACjC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE;YACd,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAChC,CAAC,CAAC;IACH,CAAC;SAAM,CAAC;QACP,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC,EAAE,EAAE,CAA+B,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAM/B,MAAS,EAaR,EAAE,CAAC,OAAO,CAAmC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport {\n\ttype ITelemetryBaseEvent,\n\ttype ITelemetryBaseLogger,\n\tLogLevel,\n\ttype Tagged,\n\ttype TelemetryBaseEventPropertyType,\n} from \"@fluidframework/core-interfaces\";\n\nimport {\n\tCachedConfigProvider,\n\tloggerIsMonitoringContext,\n\tmixinMonitoringContext,\n} from \"./config.js\";\nimport {\n\textractLogSafeErrorProperties,\n\tgenerateStack,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n} from \"./errorLogging.js\";\nimport type {\n\tITelemetryEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n\tTelemetryLoggerExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes.js\";\nimport type {\n\tITelemetryErrorEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.\n * @internal\n */\nexport function toITelemetryLoggerExt(logger: TelemetryLoggerExt): ITelemetryLoggerExt {\n\treturn logger as unknown as ITelemetryLoggerExt;\n}\n\n/**\n * Un-type-erase the {@link ITelemetryLoggerExt}.\n * @remarks\n * This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.\n *\n * @typeParam options - options for the extraction, currently only supports making\n * the output possibly undefined (when `PossiblyUndefined: true`), which is useful\n * for cases where we want to allow passing `undefined` through.\n *\n * @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will\n * be when the breaking change is made. At that time, use of this helper will be\n * required.\n *\n * @internal\n */\nexport function extractTelemetryLoggerExt<\n\toptions extends {\n\t\tPossiblyUndefined?: true;\n\t} = // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty object without PossiblyUndefined is the correct type\n\t{},\n>(\n\tinput:\n\t\t| ITelemetryLoggerExt\n\t\t| TelemetryLoggerExt\n\t\t| (options[\"PossiblyUndefined\"] extends true ? undefined : never),\n): TelemetryLoggerExt | (options[\"PossiblyUndefined\"] extends true ? undefined : never) {\n\treturn input as unknown as TelemetryLoggerExt;\n}\n\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n *\n * @privateRemarks Please do not modify existing entries, to maintain backwards compatibility.\n *\n * @internal\n */\nexport enum TelemetryDataTag {\n\t/**\n\t * Data containing terms or IDs from code packages that may have been dynamically loaded\n\t */\n\tCodeArtifact = \"CodeArtifact\",\n\t/**\n\t * Personal data of a variety of classifications that pertains to the user\n\t */\n\tUserData = \"UserData\",\n}\n\n/**\n * @legacy\n * @beta\n */\nexport type TelemetryEventPropertyTypes = ITelemetryPropertiesExt[string];\n\n/**\n * @legacy\n * @beta\n */\nexport type ITelemetryLoggerPropertyBag = Record<\n\tstring,\n\tTelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes)\n>;\n\n/**\n * @legacy\n * @beta\n *\n * @privateRemarks\n * This is exposed to support {@link createChildLogger} properties parameter.\n */\nexport interface ITelemetryLoggerPropertyBags {\n\tall?: ITelemetryLoggerPropertyBag;\n\terror?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * Attempts to parse number from string.\n * If it fails, it will return the original string.\n *\n * @remarks\n * Used to make telemetry data typed (and support math operations, like comparison),\n * in places where we do expect numbers (like contentsize/duration property in http header).\n *\n * @internal\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function numberFromString(str: string | null | undefined): string | number | undefined {\n\tif (str === undefined || str === null) {\n\t\treturn undefined;\n\t}\n\tconst num = Number(str);\n\treturn Number.isNaN(num) ? str : num;\n}\n\n// TODO: add docs\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function formatTick(tick: number): number {\n\treturn Math.floor(tick);\n}\n\n/**\n * String used to concatenate the namespace of parent loggers and their child loggers.\n * @internal\n */\nexport const eventNamespaceSeparator = \":\";\n\n/**\n * TelemetryLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport abstract class TelemetryLogger implements TelemetryLoggerExt {\n\t/**\n\t * {@inheritDoc eventNamespaceSeparator}\n\t */\n\tpublic static readonly eventNamespaceSeparator = eventNamespaceSeparator;\n\n\tpublic static sanitizePkgName(name: string): string {\n\t\treturn name.replace(\"@\", \"\").replace(\"/\", \"-\");\n\t}\n\n\t/**\n\t * Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied\n\t * over from the error object, along with other telemetry properties if it's an ILoggingError.\n\t * @param event - Event being logged\n\t * @param error - Error to extract info from\n\t * @param fetchStack - Whether to fetch the current callstack if error.stack is undefined\n\t */\n\tpublic static prepareErrorObject(\n\t\tevent: ITelemetryBaseEvent,\n\t\terror: unknown,\n\t\tfetchStack: boolean,\n\t): void {\n\t\tconst { message, errorType, stack } = extractLogSafeErrorProperties(\n\t\t\terror,\n\t\t\ttrue /* sanitizeStack */,\n\t\t);\n\t\t// First, copy over error message, stack, and errorType directly (overwrite if present on event)\n\t\tevent.stack = stack;\n\t\tevent.error = message; // Note that the error message goes on the 'error' field\n\t\tevent.errorType = errorType;\n\n\t\tif (isILoggingError(error)) {\n\t\t\t// Add any other telemetry properties from the LoggingError\n\t\t\tconst telemetryProp = error.getTelemetryProperties();\n\t\t\tfor (const key of Object.keys(telemetryProp)) {\n\t\t\t\tif (event[key] !== undefined) {\n\t\t\t\t\t// Don't overwrite existing properties on the event\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tevent[key] = telemetryProp[key];\n\t\t\t}\n\t\t}\n\n\t\t// Collect stack if we were not able to extract it from error\n\t\tif (event.stack === undefined && fetchStack) {\n\t\t\tevent.stack = generateStack();\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprotected readonly namespace?: string,\n\t\tprotected readonly properties?: ITelemetryLoggerPropertyBags,\n\t) {}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic abstract send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log. If the event's category is `error`,\n\t * the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tpublic sendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{ ...event, category: event.category ?? \"generic\" },\n\t\t\terror,\n\t\t\tevent.category === \"error\" ? LogLevel.essential : (logLevel ?? LogLevel.essential),\n\t\t);\n\t}\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - level of the log.\n\t */\n\tprivate sendTelemetryEventCore(\n\t\tevent: ITelemetryGenericEventExt & { category: TelemetryEventCategory },\n\t\terror: unknown,\n\t\tlogLevel: LogLevel,\n\t): void {\n\t\tconst newEvent = convertToBaseEvent(event);\n\t\tif (error !== undefined) {\n\t\t\tTelemetryLogger.prepareErrorObject(newEvent, error, false);\n\t\t}\n\n\t\t// Will include Nan & Infinity, but probably we do not care\n\t\tif (typeof newEvent.duration === \"number\") {\n\t\t\tnewEvent.duration = formatTick(newEvent.duration);\n\t\t}\n\n\t\tthis.send(newEvent, logLevel);\n\t}\n\n\t/**\n\t * Send an error telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{\n\t\t\t\t// ensure the error field has some value,\n\t\t\t\t// this can and will be overridden by event, or error\n\t\t\t\terror: event.eventName,\n\t\t\t\t...event,\n\t\t\t\tcategory: \"error\",\n\t\t\t},\n\t\t\terror,\n\t\t\tLogLevel.essential,\n\t\t);\n\t}\n\n\t/**\n\t * Send a performance telemetry event with the logger\n\t *\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log. If the event's category is `error`,\n\t * the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tpublic sendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void {\n\t\tconst perfEvent = {\n\t\t\t...event,\n\t\t\tcategory: event.category ?? \"performance\",\n\t\t};\n\n\t\tthis.sendTelemetryEventCore(\n\t\t\tperfEvent,\n\t\t\terror,\n\t\t\tperfEvent.category === \"error\" ? LogLevel.essential : (logLevel ?? LogLevel.essential),\n\t\t);\n\t}\n\n\tprotected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent {\n\t\tconst includeErrorProps = event.category === \"error\" || event.error !== undefined;\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\t...event,\n\t\t};\n\t\tif (this.namespace !== undefined) {\n\t\t\tnewEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;\n\t\t}\n\t\treturn this.extendProperties(newEvent, includeErrorProps);\n\t}\n\n\tprivate extendProperties<\n\t\tT extends ITelemetryLoggerPropertyBag = ITelemetryLoggerPropertyBag,\n\t>(toExtend: T, includeErrorProps: boolean): T {\n\t\tconst eventLike: ITelemetryLoggerPropertyBag = toExtend;\n\t\tif (this.properties) {\n\t\t\tconst properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];\n\t\t\tproperties.push(this.properties.all);\n\t\t\tif (includeErrorProps) {\n\t\t\t\tproperties.push(this.properties.error);\n\t\t\t}\n\t\t\tfor (const props of properties) {\n\t\t\t\tif (props !== undefined) {\n\t\t\t\t\tfor (const [key, getterOrValue] of Object.entries(props)) {\n\t\t\t\t\t\tif (eventLike[key] !== undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If this throws, hopefully it is handled elsewhere\n\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\ttypeof getterOrValue === \"function\" ? getterOrValue() : getterOrValue;\n\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\teventLike[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn toExtend;\n\t}\n}\n\n/**\n * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from\n * container-runtime. Issue: #8191\n * TaggedLoggerAdapter class can add tag handling to your logger.\n *\n * @internal\n */\nexport class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n\tpublic constructor(private readonly logger: ITelemetryBaseLogger) {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(eventWithTagsMaybe: ITelemetryBaseEvent): void {\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\tcategory: eventWithTagsMaybe.category,\n\t\t\teventName: eventWithTagsMaybe.eventName,\n\t\t};\n\t\tfor (const [key, taggableProp] of Object.entries(eventWithTagsMaybe)) {\n\t\t\tconst { value, tag } =\n\t\t\t\ttypeof taggableProp === \"object\"\n\t\t\t\t\t? taggableProp\n\t\t\t\t\t: { value: taggableProp, tag: undefined };\n\t\t\tswitch (tag) {\n\t\t\t\tcase undefined: {\n\t\t\t\t\t// No tag means we can log plainly\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"PackageData\": // For back-compat\n\t\t\t\tcase TelemetryDataTag.CodeArtifact: {\n\t\t\t\t\t// For Microsoft applications, CodeArtifact is safe for now\n\t\t\t\t\t// (we don't load 3P code in 1P apps)\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TelemetryDataTag.UserData: {\n\t\t\t\t\t// Strip out anything tagged explicitly as UserData.\n\t\t\t\t\t// Alternate strategy would be to hash these props\n\t\t\t\t\tnewEvent[key] = \"REDACTED (UserData)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\t// If we encounter a tag we don't recognize\n\t\t\t\t\t// then we must assume we should scrub.\n\t\t\t\t\tnewEvent[key] = \"REDACTED (unknown tag)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.logger.send(newEvent);\n\t}\n}\n\nfunction toEitherTelemetryLoggerExt(\n\tlogger: TelemetryLoggerExt,\n): TelemetryLoggerExt & ITelemetryLoggerExt {\n\treturn logger as TelemetryLoggerExt & ITelemetryLoggerExt;\n}\n\n/**\n * Create a child logger based on the provided props object.\n *\n * @remarks\n * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.\n *\n * @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.\n *\n * @internal\n *\n * @privateRemarks\n * Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for\n * easier internal usage without needing to type erase or un-type-erase the\n * logger.\n *\n * If always creating a child logger for direct external exposure, consider\n * using {@link createChildLogger} from /legacy API instead, which returns\n * exactly an {@link ITelemetryLoggerExt}.\n */\nexport function createChildLogger(props?: {\n\tlogger?: ITelemetryBaseLogger;\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n}): TelemetryLoggerExt & ITelemetryLoggerExt {\n\treturn toEitherTelemetryLoggerExt(\n\t\tChildLogger.create(props?.logger, props?.namespace, props?.properties),\n\t);\n}\n\n/**\n * ChildLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events.\n */\nexport class ChildLogger extends TelemetryLogger {\n\t/**\n\t * Create child logger\n\t * @param baseLogger - Base logger to use to output events. If undefined, proper child logger\n\t * is created, but it does not send telemetry events anywhere.\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t */\n\tpublic static create(\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// if we are creating a child of a child, rather than nest, which will increase\n\t\t// the callstack overhead, just generate a new logger that includes everything from the previous\n\t\tif (baseLogger instanceof ChildLogger) {\n\t\t\tconst combinedProperties: ITelemetryLoggerPropertyBags = {};\n\t\t\tfor (const extendedProps of [baseLogger.properties, properties]) {\n\t\t\t\tif (extendedProps !== undefined) {\n\t\t\t\t\tif (extendedProps.all !== undefined) {\n\t\t\t\t\t\tcombinedProperties.all = {\n\t\t\t\t\t\t\t...combinedProperties.all,\n\t\t\t\t\t\t\t...extendedProps.all,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (extendedProps.error !== undefined) {\n\t\t\t\t\t\tcombinedProperties.error = {\n\t\t\t\t\t\t\t...combinedProperties.error,\n\t\t\t\t\t\t\t...extendedProps.error,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst combinedNamespace =\n\t\t\t\tbaseLogger.namespace === undefined\n\t\t\t\t\t? namespace\n\t\t\t\t\t: namespace === undefined\n\t\t\t\t\t\t? baseLogger.namespace\n\t\t\t\t\t\t: `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;\n\n\t\t\tconst child = new ChildLogger(\n\t\t\t\tbaseLogger.baseLogger,\n\t\t\t\tcombinedNamespace,\n\t\t\t\tcombinedProperties,\n\t\t\t);\n\n\t\t\tif (!loggerIsMonitoringContext(child) && loggerIsMonitoringContext(baseLogger)) {\n\t\t\t\tmixinMonitoringContext(child, baseLogger.config);\n\t\t\t}\n\t\t\treturn child;\n\t\t}\n\n\t\treturn new ChildLogger(baseLogger ?? { send(): void {} }, namespace, properties);\n\t}\n\n\tprivate constructor(\n\t\tprotected readonly baseLogger: ITelemetryBaseLogger,\n\t\tnamespace: string | undefined,\n\t\tproperties: ITelemetryLoggerPropertyBags | undefined,\n\t) {\n\t\tsuper(namespace, properties);\n\n\t\t// propagate the monitoring context\n\t\tif (loggerIsMonitoringContext(baseLogger)) {\n\t\t\tmixinMonitoringContext(this, new CachedConfigProvider(this, baseLogger.config));\n\t\t}\n\t}\n\n\tpublic get minLogLevel(): LogLevel | undefined {\n\t\treturn this.baseLogger.minLogLevel;\n\t}\n\n\tprivate shouldFilterOutEvent(event: ITelemetryBaseEvent, logLevel?: LogLevel): boolean {\n\t\tconst eventLogLevel = logLevel ?? LogLevel.essential;\n\t\tconst configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.info;\n\t\t// Filter out in case event log level is below what is wanted in config.\n\t\treturn eventLogLevel < configLogLevel;\n\t}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tif (this.shouldFilterOutEvent(event, logLevel)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.baseLogger.send(this.prepareEvent(event), logLevel ?? LogLevel.essential);\n\t}\n}\n\n/**\n * Input properties for {@link createMultiSinkLogger}.\n *\n * @internal\n */\nexport interface MultiSinkLoggerProperties {\n\t/**\n\t * Will be prefixed to all event names.\n\t */\n\tnamespace?: string;\n\n\t/**\n\t * Default properties that will be applied to all events flowing through this logger.\n\t */\n\tproperties?: ITelemetryLoggerPropertyBags;\n\n\t/**\n\t * The base loggers that this logger will forward the logs to, after it processes them.\n\t */\n\tloggers?: (ITelemetryBaseLogger | undefined)[];\n\n\t/**\n\t * If true, the logger will attempt to copy the custom properties (if they are of a known type, i.e. one from this package) of all the base loggers passed to it, to apply them itself to logs that flow through.\n\t */\n\ttryInheritProperties?: true;\n}\n\n/**\n * Create a logger which logs to multiple other loggers based on the provided props object.\n *\n * @internal\n */\nexport function createMultiSinkLogger(props: MultiSinkLoggerProperties): TelemetryLoggerExt {\n\treturn new MultiSinkLogger(\n\t\tprops.namespace,\n\t\tprops.properties,\n\t\tprops.loggers?.filter((l): l is ITelemetryBaseLogger => l !== undefined),\n\t\tprops.tryInheritProperties,\n\t);\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n\tprotected loggers: ITelemetryBaseLogger[];\n\t// This is minimum of minLlogLevel of all loggers.\n\tprivate _minLogLevelOfAllLoggers: LogLevel;\n\n\t/**\n\t * Create multiple sink logger (i.e. logger that sends events to multiple sinks)\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param loggers - The list of loggers to use as sinks\n\t * @param tryInheritProperties - Will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n\t */\n\tpublic constructor(\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t\tloggers: ITelemetryBaseLogger[] = [],\n\t\ttryInheritProperties?: true,\n\t) {\n\t\tlet realProperties = properties === undefined ? undefined : { ...properties };\n\t\tif (tryInheritProperties === true) {\n\t\t\tconst merge = (realProperties ??= {});\n\t\t\tloggers\n\t\t\t\t.filter((l): l is this => l instanceof TelemetryLogger)\n\t\t\t\t.map((l) => l.properties ?? {})\n\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t.forEach((cv) => {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t\tObject.keys(cv).forEach((k) => {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\tmerge[k] = { ...cv[k], ...merge?.[k] };\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\n\t\tsuper(namespace, realProperties);\n\t\tthis.loggers = loggers;\n\t\tthis._minLogLevelOfAllLoggers = LogLevel.info;\n\t\tthis.calculateMinLogLevel();\n\t}\n\n\tpublic get minLogLevel(): LogLevel {\n\t\treturn this._minLogLevelOfAllLoggers;\n\t}\n\n\tprivate calculateMinLogLevel(): void {\n\t\tif (this.loggers.length > 0) {\n\t\t\tconst logLevels: LogLevel[] = [];\n\t\t\tfor (const logger of this.loggers) {\n\t\t\t\tlogLevels.push(logger.minLogLevel ?? LogLevel.info);\n\t\t\t}\n\t\t\tthis._minLogLevelOfAllLoggers = Math.min(...logLevels) as LogLevel;\n\t\t}\n\t}\n\n\t/**\n\t * Add logger to send all events to\n\t * @param logger - Logger to add\n\t */\n\tpublic addLogger(logger?: ITelemetryBaseLogger): void {\n\t\tif (logger !== undefined && logger !== null) {\n\t\t\tthis.loggers.push(logger);\n\t\t\t// Update in case the logLevel of added logger is less than the current.\n\t\t\tthis.calculateMinLogLevel();\n\t\t}\n\t}\n\n\t/**\n\t * Send an event to the loggers\n\t *\n\t * @param event - the event to send to all the registered logger\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tconst newEvent = this.prepareEvent(event);\n\t\tfor (const logger of this.loggers) {\n\t\t\tlogger.send(newEvent, logLevel ?? LogLevel.essential);\n\t\t}\n\t}\n}\n\n/**\n * Describes what events {@link PerformanceEvent} should log.\n *\n * @remarks\n * By default, all events are logged, but the client can override this behavior.\n *\n * For example, there is rarely a need to record a start event, as we're really after\n * success / failure tracking, including duration (on success).\n *\n * @internal\n */\nexport interface IPerformanceEventMarkers {\n\tstart?: true;\n\tend?: true;\n\tcancel?: \"generic\" | \"error\"; // tells wether to issue \"generic\" or \"error\" category cancel event\n}\n\n/**\n * Helper class to log performance events.\n *\n * @internal\n */\nexport class PerformanceEvent {\n\t/**\n\t * Creates an instance of {@link PerformanceEvent} and starts measurements\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,\n\t * but measurements will still be performed and any specified markers will be generated.\n\t * @param logLevel - optional {@link LogLevel} for events emitted by this performance event.\n\t * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.\n\t * @returns An instance of {@link PerformanceEvent}\n\t */\n\tpublic static start(\n\t\tlogger: TelemetryLoggerExt | ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\temitLogs: boolean = true,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): PerformanceEvent {\n\t\treturn new PerformanceEvent(\n\t\t\textractTelemetryLoggerExt(logger),\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\temitLogs,\n\t\t\tlogLevel,\n\t\t);\n\t}\n\n\t/**\n\t * Measure a synchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @param logLevel - optional {@link LogLevel} for events emitted by this performance event.\n\t * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static timedExec<T>(\n\t\tlogger: TelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tcallback: (event: PerformanceEvent) => T,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): T {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t\tlogLevel,\n\t\t);\n\t\ttry {\n\t\t\tconst ret = callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Measure an asynchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @param logLevel - optional {@link LogLevel} for events emitted by this performance event.\n\t * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static async timedExecAsync<T>(\n\t\tlogger: TelemetryLoggerExt | ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tcallback: (event: PerformanceEvent) => Promise<T>,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): Promise<T> {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t\tlogLevel,\n\t\t);\n\t\ttry {\n\t\t\tconst ret = await callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic get duration(): number {\n\t\treturn performanceNow() - this.startTime;\n\t}\n\n\tprivate event?: ITelemetryGenericEventExt;\n\tprivate readonly startTime = performanceNow();\n\tprivate startMark?: string;\n\n\tprivate constructor(\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEventExt,\n\t\tprivate readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n\t\tprivate readonly emitLogs: boolean = true,\n\t\tprivate readonly logLevel: typeof LogLevel.verbose | typeof LogLevel.info | undefined,\n\t) {\n\t\tthis.event = { ...event };\n\t\tif (this.markers.start) {\n\t\t\tthis.reportEvent(\"start\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof window === \"object\" &&\n\t\t\twindow?.performance?.mark !== undefined &&\n\t\t\twindow?.performance?.mark !== null\n\t\t) {\n\t\t\tthis.startMark = `${event.eventName}-start`;\n\t\t\twindow.performance.mark(this.startMark);\n\t\t}\n\t}\n\n\tpublic reportProgress(\n\t\tprops?: ITelemetryPropertiesExt,\n\t\teventNameSuffix: string = \"update\",\n\t): void {\n\t\tthis.reportEvent(eventNameSuffix, props);\n\t}\n\n\tprivate autoEnd(): void {\n\t\t// Event might have been cancelled or ended in the callback\n\t\tif (this.event && this.markers.end) {\n\t\t\tthis.reportEvent(\"end\");\n\t\t}\n\t\tthis.performanceEndMark();\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\tpublic end(props?: ITelemetryPropertiesExt): void {\n\t\tthis.reportEvent(\"end\", props);\n\t\tthis.performanceEndMark();\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\tprivate performanceEndMark(): void {\n\t\tif (this.startMark !== undefined && this.event) {\n\t\t\tconst endMark = `${this.event.eventName}-end`;\n\t\t\twindow.performance.mark(endMark);\n\t\t\twindow.performance.measure(`${this.event.eventName}`, this.startMark, endMark);\n\t\t\tthis.startMark = undefined;\n\t\t}\n\t}\n\n\tpublic cancel(props?: ITelemetryPropertiesExt, error?: unknown): void {\n\t\tif (this.markers.cancel !== undefined) {\n\t\t\tthis.reportEvent(\"cancel\", { category: this.markers.cancel, ...props }, error);\n\t\t}\n\n\t\t// To prevent the event from being reported again later\n\t\tthis.event = undefined;\n\t}\n\n\t/**\n\t * Report the event, if it hasn't already been reported.\n\t */\n\tpublic reportEvent(\n\t\teventNameSuffix: string,\n\t\tprops?: ITelemetryPropertiesExt,\n\t\terror?: unknown,\n\t): void {\n\t\t// If the caller invokes cancel or end directly inside the callback for timedExec[Async],\n\t\t// then it's possible to come back through reportEvent twice. Only the first time counts.\n\t\tif (!this.event) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.emitLogs) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst event: ITelemetryPerformanceEventExt = { ...this.event, ...props };\n\t\tevent.eventName = `${event.eventName}_${eventNameSuffix}`;\n\t\tif (eventNameSuffix !== \"start\") {\n\t\t\tevent.duration = this.duration;\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(event, error, this.logLevel);\n\t}\n\n\tprivate static readonly eventHits = new Map<string, number>();\n\tprivate static shouldReport(\n\t\tevent: ITelemetryGenericEventExt,\n\t\tsampleThreshold: number,\n\t): boolean {\n\t\tconst eventKey = `.${event.category}.${event.eventName}`;\n\t\tconst hitCount = PerformanceEvent.eventHits.get(eventKey) ?? 0;\n\t\tPerformanceEvent.eventHits.set(eventKey, hitCount >= sampleThreshold ? 1 : hitCount + 1);\n\t\treturn hitCount % sampleThreshold === 0;\n\t}\n}\n\n/**\n * Takes in an event object, and converts all of its values to a basePropertyType.\n * In the case of an invalid property type, the value will be converted to an error string.\n * @param event - Event with fields you want to stringify.\n */\nfunction convertToBaseEvent({\n\tcategory,\n\teventName,\n\t...props\n}: ITelemetryEventExt): ITelemetryBaseEvent {\n\tconst newEvent: ITelemetryBaseEvent = { category, eventName };\n\tfor (const key of Object.keys(props)) {\n\t\tnewEvent[key] = convertToBasePropertyType(props[key]);\n\t}\n\treturn newEvent;\n}\n\n/**\n * Takes in value, and does one of 4 things.\n * if value is of primitive type - returns the original value.\n * If the value is a flat array or object - returns a stringified version of the array/object.\n * If the value is an object of type Tagged<TelemetryBaseEventPropertyType> - returns the object\n * with its values recursively converted to base property Type.\n * If none of these cases are reached - returns an error string\n * @param x - value passed in to convert to a base property type\n */\nexport function convertToBasePropertyType(\n\tx: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>,\n): TelemetryBaseEventPropertyType | Tagged<TelemetryBaseEventPropertyType> {\n\treturn isTaggedTelemetryPropertyValue(x)\n\t\t? {\n\t\t\t\tvalue: convertToBasePropertyTypeUntagged(x.value),\n\t\t\t\ttag: x.tag,\n\t\t\t}\n\t\t: convertToBasePropertyTypeUntagged(x);\n}\n\nfunction convertToBasePropertyTypeUntagged(\n\tx: TelemetryEventPropertyTypeExt,\n): TelemetryBaseEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\": {\n\t\t\treturn x;\n\t\t}\n\t\tcase \"object\": {\n\t\t\t// We assume this is an array or flat object based on the input types\n\t\t\treturn JSON.stringify(x);\n\t\t}\n\t\tdefault: {\n\t\t\t// should never reach this case based on the input types\n\t\t\tconsole.error(\n\t\t\t\t`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`,\n\t\t\t);\n\t\t\treturn `INVALID PROPERTY (typed as ${typeof x})`;\n\t\t}\n\t}\n}\n\n/**\n * Tags all given `values` with the same `tag`.\n *\n * @param tag - The tag with which all `values` will be annotated.\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagData(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged.\n *\n * @internal\n */\nexport const tagData = <\n\tT extends TelemetryDataTag,\n\tV extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\ttag: T,\n\tvalues: V,\n): {\n\t[P in keyof V]:\n\t\t| (V[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<V[P]>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<V[P], undefined>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t\t})\n\t\t| (V[P] extends undefined ? undefined : never);\n} =>\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\tObject.entries(values)\n\t\t.filter((e) => e[1] !== undefined)\n\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t.reduce((pv, cv) => {\n\t\t\tconst [key, value] = cv;\n\t\t\t// The ternary form is less legible in this case.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tpv[key] = () => {\n\t\t\t\t\treturn { tag, value: value() };\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tpv[key] = { tag, value };\n\t\t\t}\n\t\t\treturn pv;\n\t\t}, {}) as ReturnType<typeof tagData>;\n\n/**\n * Tags all provided `values` as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagCodeArtifacts(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @see {@link tagData}\n *\n * @internal\n */\nexport const tagCodeArtifacts = <\n\tT extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\tvalues: T,\n): {\n\t[P in keyof T]:\n\t\t| (T[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<T[P]>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<T[P], undefined>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t\t})\n\t\t| (T[P] extends undefined ? undefined : never);\n} => tagData<TelemetryDataTag.CodeArtifact, T>(TelemetryDataTag.CodeArtifact, values);\n"]}

@@ -25,3 +25,3 @@ /*!

this._events = [];
this.minLogLevel = minLogLevel ?? LogLevel.default;
this.minLogLevel = minLogLevel ?? LogLevel.info;
}

@@ -41,3 +41,3 @@ /**

send(event, logLevel) {
if ((logLevel ?? LogLevel.default) >= this.minLogLevel) {
if ((logLevel ?? LogLevel.essential) >= this.minLogLevel) {
this._events.push(event);

@@ -44,0 +44,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGN,QAAQ,GACR,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOhD;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACH,IAAW,MAAM;QAChB,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IASD,YAAmB,WAAsB;QAPjC,YAAO,GAA0B,EAAE,CAAC;QAQ3C,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACnB,CAAC;IAEM,iBAAiB;QACvB,OAAO,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,KAA0B,EAAE,QAAmB;QAC1D,IAAI,CAAC,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C,WAAW,CAAC;gBAC1B,WAAW,KAAK,IAAI;gBACpB,OAAO,WAAW,KAAK,QAAQ;gBAC/B,CAAC,YAAY,CACZ,WAAsC,EACtC,aAAwC,CACxC,EACA,CAAC;gBACF,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;aAAM,IAAI,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;YAC1E,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAgBD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAsB;IACzD,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;QACjC,MAAM,EAAE,GAAkC,EAAE,CAC3C,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAuB,CAAC;KACtD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ITelemetryBaseEvent,\n\ttype ITelemetryBaseLogger,\n\tLogLevel,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger } from \"./logger.js\";\nimport type {\n\tITelemetryEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n} from \"./telemetryTypes.js\";\n\n/**\n * Mock {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} implementation.\n *\n * Records events sent to it, and then can walk back over those events, searching for a set of expected events to\n * match against the logged events.\n *\n * @internal\n */\nexport class MockLogger implements ITelemetryBaseLogger {\n\t/**\n\t * Gets an immutable copy of the events logged thus far.\n\t */\n\tpublic get events(): readonly ITelemetryBaseEvent[] {\n\t\treturn [...this._events];\n\t}\n\n\tprivate _events: ITelemetryBaseEvent[] = [];\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.minLogLevel}\n\t */\n\tpublic readonly minLogLevel: LogLevel;\n\n\tpublic constructor(minLogLevel?: LogLevel) {\n\t\tthis.minLogLevel = minLogLevel ?? LogLevel.default;\n\t}\n\n\t/**\n\t * Clears the events logged thus far.\n\t */\n\tpublic clear(): void {\n\t\tthis._events = [];\n\t}\n\n\tpublic toTelemetryLogger(): ReturnType<typeof createChildLogger> {\n\t\treturn createChildLogger({ logger: this });\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tif ((logLevel ?? LogLevel.default) >= this.minLogLevel) {\n\t\t\tthis._events.push(event);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to appear in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t */\n\tpublic matchEvents(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t\tclearEventsAfterCheck,\n\t\t);\n\t\t// How many expected events were left over? Hopefully none.\n\t\tconst unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n\t\treturn unmatchedExpectedEventCount === 0;\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchEvents} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatch(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchEvents(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for any of the given\n\t * expected events.\n\t * @param expectedEvents - events that are expected to appear in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @returns if any of the expected events is found.\n\t */\n\tpublic matchAnyEvent(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t\tclearEventsAfterCheck,\n\t\t);\n\t\treturn matchedExpectedEventCount > 0;\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchAnyEvent} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchAny(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchAnyEvent(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking only for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to be the only events in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t */\n\tpublic matchEventStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tif (expectedEvents.length !== this._events.length) {\n\t\t\tif (clearEventsAfterCheck) {\n\t\t\t\tthis.clear();\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t// `events` will be cleared by the below check if requested.\n\t\treturn this.matchEvents(expectedEvents, inlineDetailsProp, clearEventsAfterCheck);\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchEvents} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchEventStrict(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchAnyEvent} is `false` for the given events.\n\t * @param disallowedEvents - The events expected to not appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchNone(\n\t\tdisallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (this.matchAnyEvent(disallowedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\tprivate getMatchedEventsCount(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean,\n\t\tclearEventsAfterCheck: boolean,\n\t): number {\n\t\tlet iExpectedEvent = 0;\n\t\tfor (const event of this._events) {\n\t\t\tconst expectedEvent = expectedEvents[iExpectedEvent];\n\t\t\tif (\n\t\t\t\tiExpectedEvent < expectedEvents.length &&\n\t\t\t\texpectedEvent !== undefined &&\n\t\t\t\tMockLogger.eventsMatch(event, expectedEvent, inlineDetailsProp)\n\t\t\t) {\n\t\t\t\t// We found the next expected event; increment\n\t\t\t\t++iExpectedEvent;\n\t\t\t}\n\t\t}\n\n\t\t// Remove the events so far; next call will just compare subsequent events from here\n\t\tif (clearEventsAfterCheck) {\n\t\t\tthis.clear();\n\t\t}\n\n\t\t// Return the count of matched events.\n\t\treturn iExpectedEvent;\n\t}\n\n\t/**\n\t * Ensure the expected event is a strict subset of the actual event\n\t */\n\tprivate static eventsMatch(\n\t\tactual: ITelemetryBaseEvent,\n\t\texpected: Omit<ITelemetryBaseEvent, \"category\">,\n\t\tinlineDetailsProp: boolean,\n\t): boolean {\n\t\tconst { details, ...actualForMatching } = actual;\n\t\t// \"details\" is used in a lot of telemetry logs to group a bunch of properties together and stringify them.\n\t\t// Some of the properties in the expected event may be inside \"details\". So, if inlineDetailsProp is true,\n\t\t// extract the properties from \"details\" in the actual event and inline them in the actual event.\n\t\tif (inlineDetailsProp && details !== undefined) {\n\t\t\tassert(\n\t\t\t\ttypeof details === \"string\",\n\t\t\t\t0x6c9 /* Details should a JSON stringified string if inlineDetailsProp is true */,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst detailsExpanded = JSON.parse(details);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn matchObjects({ ...actualForMatching, ...detailsExpanded }, expected);\n\t\t}\n\t\treturn matchObjects(actual, expected);\n\t}\n\n\t/**\n\t * Throws if any errors were logged\n\t */\n\tpublic assertNoErrors(message?: string, clearEventsAfterCheck: boolean = true): void {\n\t\tconst actualEvents = this.events;\n\t\tconst errors = actualEvents.filter((event) => event.category === \"error\");\n\t\tif (clearEventsAfterCheck) {\n\t\t\tthis.clear();\n\t\t}\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`${message ?? \"Errors found in logs\"}\n\nerror logs:\n${JSON.stringify(errors)}`);\n\t\t}\n\t}\n}\n\nfunction matchObjects(\n\tactual: ITelemetryPropertiesExt,\n\texpected: ITelemetryPropertiesExt,\n): boolean {\n\tfor (const [expectedKey, expectedValue] of Object.entries(expected)) {\n\t\tconst actualValue = actual[expectedKey];\n\t\tif (\n\t\t\t!Array.isArray(expectedValue) &&\n\t\t\texpectedValue !== null &&\n\t\t\ttypeof expectedValue === \"object\"\n\t\t) {\n\t\t\tif (\n\t\t\t\tArray.isArray(actualValue) ||\n\t\t\t\tactualValue === null ||\n\t\t\t\ttypeof actualValue !== \"object\" ||\n\t\t\t\t!matchObjects(\n\t\t\t\t\tactualValue as ITelemetryPropertiesExt,\n\t\t\t\t\texpectedValue as ITelemetryPropertiesExt,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Mock {@link TelemetryLoggerExt} implementation.\n *\n * @remarks Can be created via {@link createMockLoggerExt}.\n *\n * @internal\n */\nexport interface IMockLoggerExt extends TelemetryLoggerExt {\n\t/**\n\t * Gets the events that have been logged so far.\n\t */\n\tevents(): readonly ITelemetryEventExt[];\n}\n\n/**\n * Creates an {@link IMockLoggerExt}.\n *\n * @internal\n */\nexport function createMockLoggerExt(minLogLevel?: LogLevel): IMockLoggerExt {\n\tconst mockLogger = new MockLogger(minLogLevel);\n\tconst childLogger = createChildLogger({ logger: mockLogger });\n\treturn Object.assign(childLogger, {\n\t\tevents: (): readonly ITelemetryEventExt[] =>\n\t\t\tmockLogger.events.map((e) => e as ITelemetryEventExt),\n\t});\n}\n"]}
{"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGN,QAAQ,GACR,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOhD;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACH,IAAW,MAAM;QAChB,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IASD,YAAmB,WAAsB;QAPjC,YAAO,GAA0B,EAAE,CAAC;QAQ3C,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,QAAQ,CAAC,IAAI,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACnB,CAAC;IAEM,iBAAiB;QACvB,OAAO,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,KAA0B,EAAE,QAAmB;QAC1D,IAAI,C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O,CAAC,WAAW,CAAC;gBAC1B,WAAW,KAAK,IAAI;gBACpB,OAAO,WAAW,KAAK,QAAQ;gBAC/B,CAAC,YAAY,CACZ,WAAsC,EACtC,aAAwC,CACxC,EACA,CAAC;gBACF,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;aAAM,IAAI,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;YAC1E,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAgBD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAsB;IACzD,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;QACjC,MAAM,EAAE,GAAkC,EAAE,CAC3C,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAuB,CAAC;KACtD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ITelemetryBaseEvent,\n\ttype ITelemetryBaseLogger,\n\tLogLevel,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger } from \"./logger.js\";\nimport type {\n\tITelemetryEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n} from \"./telemetryTypes.js\";\n\n/**\n * Mock {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} implementation.\n *\n * Records events sent to it, and then can walk back over those events, searching for a set of expected events to\n * match against the logged events.\n *\n * @internal\n */\nexport class MockLogger implements ITelemetryBaseLogger {\n\t/**\n\t * Gets an immutable copy of the events logged thus far.\n\t */\n\tpublic get events(): readonly ITelemetryBaseEvent[] {\n\t\treturn [...this._events];\n\t}\n\n\tprivate _events: ITelemetryBaseEvent[] = [];\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.minLogLevel}\n\t */\n\tpublic readonly minLogLevel: LogLevel;\n\n\tpublic constructor(minLogLevel?: LogLevel) {\n\t\tthis.minLogLevel = minLogLevel ?? LogLevel.info;\n\t}\n\n\t/**\n\t * Clears the events logged thus far.\n\t */\n\tpublic clear(): void {\n\t\tthis._events = [];\n\t}\n\n\tpublic toTelemetryLogger(): ReturnType<typeof createChildLogger> {\n\t\treturn createChildLogger({ logger: this });\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {\n\t\tif ((logLevel ?? LogLevel.essential) >= this.minLogLevel) {\n\t\t\tthis._events.push(event);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to appear in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t */\n\tpublic matchEvents(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t\tclearEventsAfterCheck,\n\t\t);\n\t\t// How many expected events were left over? Hopefully none.\n\t\tconst unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n\t\treturn unmatchedExpectedEventCount === 0;\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchEvents} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatch(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchEvents(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for any of the given\n\t * expected events.\n\t * @param expectedEvents - events that are expected to appear in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @returns if any of the expected events is found.\n\t */\n\tpublic matchAnyEvent(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t\tclearEventsAfterCheck,\n\t\t);\n\t\treturn matchedExpectedEventCount > 0;\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchAnyEvent} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchAny(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchAnyEvent(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking only for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to be the only events in the recorded log.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t */\n\tpublic matchEventStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): boolean {\n\t\tif (expectedEvents.length !== this._events.length) {\n\t\t\tif (clearEventsAfterCheck) {\n\t\t\t\tthis.clear();\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t// `events` will be cleared by the below check if requested.\n\t\treturn this.matchEvents(expectedEvents, inlineDetailsProp, clearEventsAfterCheck);\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchEvents} is `true` for the given events.\n\t * @param expectedEvents - The events expected to appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (!this.matchEventStrict(expectedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Asserts {@link MockLogger.matchAnyEvent} is `false` for the given events.\n\t * @param disallowedEvents - The events expected to not appear.\n\t * @param message - Optional error message to include in the thrown error, if the condition is not satisfied.\n\t * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check.\n\t * Default: true.\n\t * @throws An error containing the actual/expected event data if the condition is not satisfied.\n\t */\n\tpublic assertMatchNone(\n\t\tdisallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t\tclearEventsAfterCheck: boolean = true,\n\t): void {\n\t\t// Use copy to ensure events aren't cleared out from under us before we (potentially) throw\n\t\tconst actualEvents = this.events;\n\n\t\tif (this.matchAnyEvent(disallowedEvents, inlineDetailsProp, clearEventsAfterCheck)) {\n\t\t\tthrow new Error(`${message ?? \"Logs don't match\"}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\tprivate getMatchedEventsCount(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean,\n\t\tclearEventsAfterCheck: boolean,\n\t): number {\n\t\tlet iExpectedEvent = 0;\n\t\tfor (const event of this._events) {\n\t\t\tconst expectedEvent = expectedEvents[iExpectedEvent];\n\t\t\tif (\n\t\t\t\tiExpectedEvent < expectedEvents.length &&\n\t\t\t\texpectedEvent !== undefined &&\n\t\t\t\tMockLogger.eventsMatch(event, expectedEvent, inlineDetailsProp)\n\t\t\t) {\n\t\t\t\t// We found the next expected event; increment\n\t\t\t\t++iExpectedEvent;\n\t\t\t}\n\t\t}\n\n\t\t// Remove the events so far; next call will just compare subsequent events from here\n\t\tif (clearEventsAfterCheck) {\n\t\t\tthis.clear();\n\t\t}\n\n\t\t// Return the count of matched events.\n\t\treturn iExpectedEvent;\n\t}\n\n\t/**\n\t * Ensure the expected event is a strict subset of the actual event\n\t */\n\tprivate static eventsMatch(\n\t\tactual: ITelemetryBaseEvent,\n\t\texpected: Omit<ITelemetryBaseEvent, \"category\">,\n\t\tinlineDetailsProp: boolean,\n\t): boolean {\n\t\tconst { details, ...actualForMatching } = actual;\n\t\t// \"details\" is used in a lot of telemetry logs to group a bunch of properties together and stringify them.\n\t\t// Some of the properties in the expected event may be inside \"details\". So, if inlineDetailsProp is true,\n\t\t// extract the properties from \"details\" in the actual event and inline them in the actual event.\n\t\tif (inlineDetailsProp && details !== undefined) {\n\t\t\tassert(\n\t\t\t\ttypeof details === \"string\",\n\t\t\t\t0x6c9 /* Details should a JSON stringified string if inlineDetailsProp is true */,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst detailsExpanded = JSON.parse(details);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn matchObjects({ ...actualForMatching, ...detailsExpanded }, expected);\n\t\t}\n\t\treturn matchObjects(actual, expected);\n\t}\n\n\t/**\n\t * Throws if any errors were logged\n\t */\n\tpublic assertNoErrors(message?: string, clearEventsAfterCheck: boolean = true): void {\n\t\tconst actualEvents = this.events;\n\t\tconst errors = actualEvents.filter((event) => event.category === \"error\");\n\t\tif (clearEventsAfterCheck) {\n\t\t\tthis.clear();\n\t\t}\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(`${message ?? \"Errors found in logs\"}\n\nerror logs:\n${JSON.stringify(errors)}`);\n\t\t}\n\t}\n}\n\nfunction matchObjects(\n\tactual: ITelemetryPropertiesExt,\n\texpected: ITelemetryPropertiesExt,\n): boolean {\n\tfor (const [expectedKey, expectedValue] of Object.entries(expected)) {\n\t\tconst actualValue = actual[expectedKey];\n\t\tif (\n\t\t\t!Array.isArray(expectedValue) &&\n\t\t\texpectedValue !== null &&\n\t\t\ttypeof expectedValue === \"object\"\n\t\t) {\n\t\t\tif (\n\t\t\t\tArray.isArray(actualValue) ||\n\t\t\t\tactualValue === null ||\n\t\t\t\ttypeof actualValue !== \"object\" ||\n\t\t\t\t!matchObjects(\n\t\t\t\t\tactualValue as ITelemetryPropertiesExt,\n\t\t\t\t\texpectedValue as ITelemetryPropertiesExt,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Mock {@link TelemetryLoggerExt} implementation.\n *\n * @remarks Can be created via {@link createMockLoggerExt}.\n *\n * @internal\n */\nexport interface IMockLoggerExt extends TelemetryLoggerExt {\n\t/**\n\t * Gets the events that have been logged so far.\n\t */\n\tevents(): readonly ITelemetryEventExt[];\n}\n\n/**\n * Creates an {@link IMockLoggerExt}.\n *\n * @internal\n */\nexport function createMockLoggerExt(minLogLevel?: LogLevel): IMockLoggerExt {\n\tconst mockLogger = new MockLogger(minLogLevel);\n\tconst childLogger = createChildLogger({ logger: mockLogger });\n\treturn Object.assign(childLogger, {\n\t\tevents: (): readonly ITelemetryEventExt[] =>\n\t\t\tmockLogger.events.map((e) => e as ITelemetryEventExt),\n\t});\n}\n"]}

@@ -54,2 +54,5 @@ /*!

*
* Telemetry events emitted by this class (both at the sample threshold and on dispose) are sent with
* {@link @fluidframework/core-interfaces#LogLevelConst.info | LogLevel.info}.
*
* @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring

@@ -56,0 +59,0 @@ * any custom metric data that might be required by this class. E.g., the code might just return a boolean.

@@ -1,1 +0,1 @@

{"version":3,"file":"sampledTelemetryHelper.d.ts","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAI7F,OAAO,KAAK,EACX,yBAAyB,EACzB,kBAAkB,EAElB,MAAM,iCAAiC,CAAC;AA2DzC;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,IAAI,IAAI;KAChC,CAAC,IAAI,MAAM,IAAI,GAAG,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,KAAK;CACpD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;CA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;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiC;IAEjE;;;;;;;;;;;;;OAaG;gBAEe,SAAS,EAAE,yBAAyB,EACpC,MAAM,EAAE,kBAAkB,EAC1B,eAAe,EAAE,MAAM,EACvB,uBAAuB,GAAE,OAAe,EACxC,mBAAmB,wCAA8C;IAGnF;;;;;;;;;;;;;;OAcG;IACI,OAAO,CACb,aAAa,EAAE,MAAM,iBAAiB,CAAC,cAAc,EAAE,cAAc,CAAC,EACtE,MAAM,GAAE,MAAW,GACjB,iBAAiB,CAAC,cAAc,EAAE,cAAc,CAAC;IAwCpD,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,WAAW;IA6BZ,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI;CAM/C"}

@@ -6,2 +6,3 @@ /*!

import { performanceNow } from "@fluid-internal/client-utils";
import { LogLevel } from "@fluidframework/core-interfaces";
import { assert } from "@fluidframework/core-utils/internal";

@@ -19,2 +20,5 @@ import { roundToDecimalPlaces } from "./mathTools.js";

*
* Telemetry events emitted by this class (both at the sample threshold and on dispose) are sent with
* {@link @fluidframework/core-interfaces#LogLevelConst.info | LogLevel.info}.
*
* @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring

@@ -149,3 +153,4 @@ * any custom metric data that might be required by this class. E.g., the code might just return a boolean.

};
this.logger.sendPerformanceEvent(telemetryEvent);
this.logger.sendPerformanceEvent(telemetryEvent, undefined, // error
LogLevel.info);
this.measurementsMap.delete(bucket);

@@ -152,0 +157,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"sampledTelemetryHelper.js","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,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CAAC;IAC5B,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO;QACR,CAAC;QAED,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAE7C,MAAM,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAEnF,IAAI,YAAY,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAE9D,MAAM,cAAc,GAAkC;gBACrD,GAAG,IAAI,CAAC,SAAS;gBACjB,GAAG,gBAAgB,EAAE,6EAA6E;gBAClG,GAAG,YAAY;gBACf,GAAG,mBAAmB;aACtB,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;YACjD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;IACF,CAAC;IAEM,OAAO,CAAC,KAAyB;QACvC,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport type { IDisposable, ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { roundToDecimalPlaces } from \"./mathTools.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * @privateRemarks\n *\n * The names of the properties in this interface are the ones that will get stamped in the\n * telemetry event, changes should be considered carefully. The optional properties should\n * only be populated if 'includeAggregateMetrics' is true.\n */\ninterface Measurements {\n\t/**\n\t * The duration of the latest execution.\n\t */\n\tduration: number;\n\n\t/**\n\t * The number of executions since the last time an event was generated.\n\t */\n\tcount: number;\n\n\t/**\n\t * Total duration across all the executions since the last event was generated.\n\t */\n\ttotalDuration?: number;\n\n\t/**\n\t * Min duration across all the executions since the last event was generated.\n\t */\n\tminDuration?: number;\n\n\t/**\n\t * Max duration across all the executions since the last event was generated.\n\t */\n\tmaxDuration?: number;\n\n\t/**\n\t * Average duration across all the executions since the last event was generated.\n\t */\n\taverageDuration?: number;\n}\n\n/**\n * The data that will be logged in the telemetry event.\n */\ninterface LoggerData {\n\tmeasurements: Measurements;\n\n\t/**\n\t * The sum of the custom data passed into the logger for each key.\n\t * Absence of a given key should be interpreted as 0.\n\t */\n\tdataSums: Record<string, number>;\n\n\t/**\n\t * The max of the custom data passed into the logger for each key.\n\t */\n\tdataMaxes: Record<string, number>;\n}\n\n/**\n * Helper type for an object whose properties are all numbers\n *\n * @internal\n */\nexport type CustomMetrics<TKey> = {\n\t[K in keyof TKey]: K extends string ? number : never;\n};\n\n/**\n * Potentially part of the structure of the return value of the function provided to {@link SampledTelemetryHelper.measure}.\n *\n * @see {@link MeasureReturnType} for more details on how this type is used.\n *\n * @internal\n */\nexport interface ICustomData<T> {\n\tcustomData: CustomMetrics<T>;\n}\n\n/**\n * Encapsulates the type-level logic for {@link SampledTelemetryHelper.measure}, to determine the expected return type\n * for the function that method receives (and by extension, its own return type). In words: {@link SampledTelemetryHelper}\n * is optionally provided with two generic types: one for custom metrics, and one for the actual return value of the\n * code that will be measured.\n *\n * - If no generic type is provided for custom metrics, then this type is simply the generic type provided for the actual\n * return value of the measured code (which could be void!).\n * - If a generic type is provided for custom metrics, then this type has a `customData` property whose type matches that\n * generic. Then if the generic type for the actual return value is not void, this type also has a property `returnValue`\n * whose type matches the generic type for the actual return value; if the generic type for the actual return value is\n * void, then this type _forbids_ a `returnValue` property (technically, it can exist but must be undefined in that case),\n * to try to ensure that the caller doesn't accidentally provide a function that actually returns a value.\n *\n * @internal\n */\nexport type MeasureReturnType<TMeasureReturn, TCustomMetrics> = TCustomMetrics extends void\n\t? TMeasureReturn\n\t: ICustomData<TCustomMetrics> &\n\t\t\t(TMeasureReturn extends void\n\t\t\t\t? Partial<Record<\"returnValue\", never>>\n\t\t\t\t: { returnValue: TMeasureReturn });\n\n/**\n * Helper class that executes a specified code block and writes an\n * {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified\n * number of executions is reached (or when the class is disposed).\n *\n * @remarks\n * The `duration` field in the telemetry event this class generates is the duration of the latest execution (sample)\n * of the specified code block.\n * See the documentation of the `includeAggregateMetrics` parameter for additional details that can be included.\n *\n * @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring\n * any custom metric data that might be required by this class. E.g., the code might just return a boolean.\n * @typeParam TCustomMetrics - A type that contains the custom properties that will be used by an instance of this class\n * for custom metrics. Each property in this type should be a number.\n *\n * @internal\n */\nexport class SampledTelemetryHelper<\n\tTMeasureReturn = void,\n\tTCustomMetrics extends CustomMetrics<TCustomMetrics> = void,\n> implements IDisposable\n{\n\tprivate _disposed: boolean = false;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IDisposable.disposed}\n\t */\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tprivate readonly measurementsMap = new Map<string, LoggerData>();\n\n\t/**\n\t * @param eventBase - Custom properties to include in the telemetry performance event when it is written.\n\t * @param logger - The logger to use to write the telemetry performance event.\n\t * @param sampleThreshold - Telemetry performance events will be generated every time we hit this many executions\n\t * of the code block.\n\t * @param includeAggregateMetrics - If set to `true`, the telemetry performance event will include aggregated\n\t * metrics (total duration, min duration, max duration) for all the executions in between generated events.\n\t * @param perBucketProperties - Map of strings that represent different buckets (which can be specified when calling\n\t * the 'measure' method), to properties which should be added to the telemetry event for that bucket.\n\t * If a bucket being measured does not have an entry in this map, no additional properties will be added to its\n\t * telemetry events. The following keys are reserved for use by this class: \"duration\", \"count\", \"totalDuration\",\n\t * \"minDuration\", \"maxDuration\". If any of them is specified as a key in one of the ITelemetryBaseProperties objects\n\t * in this map, that key-value pair will be ignored.\n\t */\n\tpublic constructor(\n\t\tprivate readonly eventBase: ITelemetryGenericEventExt,\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\t\tprivate readonly sampleThreshold: number,\n\t\tprivate readonly includeAggregateMetrics: boolean = false,\n\t\tprivate readonly perBucketProperties = new Map<string, ITelemetryBaseProperties>(),\n\t) {}\n\n\t/**\n\t * Executes the specified code and keeps track of execution time statistics.\n\t * When it's been called enough times (the sampleThreshold for the class) then it generates a log message with the\n\t * necessary information.\n\t *\n\t * @remarks It's the responsibility of the caller to ensure that the same same set of custom metric properties is\n\t * provided each time this method is called on a given instance of {@link SampledTelemetryHelper}.\n\t * Otherwise the final measurements in the telemetry event may not be accurate.\n\t *\n\t * @param codeToMeasure - The code to be executed and measured.\n\t * @param bucket - A key to track executions of the code block separately.\n\t * Each different value of this parameter has a separate set of executions and metrics tracked by the class.\n\t * If no such distinction needs to be made, do not provide a value.\n\t * @returns Whatever the passed-in code block returns.\n\t */\n\tpublic measure(\n\t\tcodeToMeasure: () => MeasureReturnType<TMeasureReturn, TCustomMetrics>,\n\t\tbucket: string = \"\",\n\t): MeasureReturnType<TMeasureReturn, TCustomMetrics> {\n\t\tconst start = performanceNow();\n\t\tconst returnValue = codeToMeasure();\n\t\tconst duration = performanceNow() - start;\n\n\t\tlet loggerData = this.measurementsMap.get(bucket);\n\t\tif (loggerData === undefined) {\n\t\t\tloggerData = {\n\t\t\t\tmeasurements: { count: 0, duration: -1 },\n\t\t\t\tdataSums: {},\n\t\t\t\tdataMaxes: {},\n\t\t\t};\n\t\t\tthis.measurementsMap.set(bucket, loggerData);\n\t\t}\n\n\t\tconst m = loggerData.measurements;\n\t\tm.count++;\n\t\tm.duration = duration;\n\n\t\tif (this.includeAggregateMetrics) {\n\t\t\tm.totalDuration = (m.totalDuration ?? 0) + duration;\n\t\t\tm.minDuration = Math.min(m.minDuration ?? duration, duration);\n\t\t\tm.maxDuration = Math.max(m.maxDuration ?? 0, duration);\n\t\t}\n\n\t\tif (this.isCustomData(returnValue)) {\n\t\t\tloggerData = this.accumulateCustomData(returnValue.customData, loggerData);\n\t\t}\n\n\t\tif (m.count >= this.sampleThreshold) {\n\t\t\t// Computed separately to avoid multiple division operations.\n\t\t\tif (this.includeAggregateMetrics) {\n\t\t\t\tm.averageDuration = (m.totalDuration ?? 0) / m.count;\n\t\t\t}\n\t\t\tthis.flushBucket(bucket);\n\t\t}\n\n\t\treturn returnValue;\n\t}\n\n\tprivate isCustomData(data: unknown): data is ICustomData<TCustomMetrics> {\n\t\treturn (\n\t\t\ttypeof data === \"object\" &&\n\t\t\tdata !== null &&\n\t\t\t\"customData\" in data &&\n\t\t\ttypeof data.customData === \"object\"\n\t\t);\n\t}\n\n\tprivate accumulateCustomData(\n\t\tcustomData: CustomMetrics<TCustomMetrics>,\n\t\tloggerData: LoggerData,\n\t): LoggerData {\n\t\tfor (const [key, val] of Object.entries(customData)) {\n\t\t\tassert(typeof key === \"string\", 0x9df /* Key should be a string */);\n\t\t\tassert(typeof val === \"number\", 0x9e0 /* Value should be a number */);\n\n\t\t\tloggerData.dataSums[key] = (loggerData.dataSums[key] ?? 0) + val;\n\t\t\tloggerData.dataMaxes[key] = Math.max(\n\t\t\t\tloggerData.dataMaxes[key] ?? Number.NEGATIVE_INFINITY,\n\t\t\t\tval,\n\t\t\t);\n\t\t}\n\n\t\treturn loggerData;\n\t}\n\n\tprivate processCustomData(loggerData: LoggerData, count: number): Record<string, number> {\n\t\tconst processedCustomData: Record<string, number> = {};\n\n\t\tif (loggerData.dataSums === undefined || loggerData.dataMaxes === undefined) {\n\t\t\treturn processedCustomData;\n\t\t}\n\n\t\tconst dataSums = loggerData.dataSums;\n\t\tconst dataMaxes = loggerData.dataMaxes;\n\n\t\tfor (const [key, val] of Object.entries(dataSums)) {\n\t\t\t// implementation of class guarantees the keys between dataMaxes and dataSums align.\n\t\t\tprocessedCustomData[`avg_${key}`] = roundToDecimalPlaces(val / count, 6);\n\t\t\tprocessedCustomData[`max_${key}`] = dataMaxes[key] ?? 0;\n\t\t}\n\n\t\treturn processedCustomData;\n\t}\n\n\tprivate flushBucket(bucket: string): void {\n\t\tconst loggerData = this.measurementsMap.get(bucket);\n\t\tif (loggerData === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst measurements = loggerData.measurements;\n\n\t\tconst processedCustomData = this.processCustomData(loggerData, measurements.count);\n\n\t\tif (measurements.count !== 0) {\n\t\t\tconst bucketProperties = this.perBucketProperties.get(bucket);\n\n\t\t\tconst telemetryEvent: ITelemetryPerformanceEventExt = {\n\t\t\t\t...this.eventBase,\n\t\t\t\t...bucketProperties, // If the bucket doesn't exist and this is undefined, things work as expected\n\t\t\t\t...measurements,\n\t\t\t\t...processedCustomData,\n\t\t\t};\n\n\t\t\tthis.logger.sendPerformanceEvent(telemetryEvent);\n\t\t\tthis.measurementsMap.delete(bucket);\n\t\t}\n\t}\n\n\tpublic dispose(error?: Error | undefined): void {\n\t\tfor (const [k] of this.measurementsMap.entries()) {\n\t\t\tthis.flushBucket(k);\n\t\t}\n\t\tthis._disposed = true;\n\t}\n}\n"]}
{"version":3,"file":"sampledTelemetryHelper.js","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAA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MAAc;QACjC,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO;QACR,CAAC;QAED,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAE7C,MAAM,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAEnF,IAAI,YAAY,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAE9D,MAAM,cAAc,GAAkC;gBACrD,GAAG,IAAI,CAAC,SAAS;gBACjB,GAAG,gBAAgB,EAAE,6EAA6E;gBAClG,GAAG,YAAY;gBACf,GAAG,mBAAmB;aACtB,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAC/B,cAAc,EACd,SAAS,EAAE,QAAQ;YACnB,QAAQ,CAAC,IAAI,CACb,CAAC;YACF,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;IACF,CAAC;IAEM,OAAO,CAAC,KAAyB;QACvC,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport type { IDisposable, ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { roundToDecimalPlaces } from \"./mathTools.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * @privateRemarks\n *\n * The names of the properties in this interface are the ones that will get stamped in the\n * telemetry event, changes should be considered carefully. The optional properties should\n * only be populated if 'includeAggregateMetrics' is true.\n */\ninterface Measurements {\n\t/**\n\t * The duration of the latest execution.\n\t */\n\tduration: number;\n\n\t/**\n\t * The number of executions since the last time an event was generated.\n\t */\n\tcount: number;\n\n\t/**\n\t * Total duration across all the executions since the last event was generated.\n\t */\n\ttotalDuration?: number;\n\n\t/**\n\t * Min duration across all the executions since the last event was generated.\n\t */\n\tminDuration?: number;\n\n\t/**\n\t * Max duration across all the executions since the last event was generated.\n\t */\n\tmaxDuration?: number;\n\n\t/**\n\t * Average duration across all the executions since the last event was generated.\n\t */\n\taverageDuration?: number;\n}\n\n/**\n * The data that will be logged in the telemetry event.\n */\ninterface LoggerData {\n\tmeasurements: Measurements;\n\n\t/**\n\t * The sum of the custom data passed into the logger for each key.\n\t * Absence of a given key should be interpreted as 0.\n\t */\n\tdataSums: Record<string, number>;\n\n\t/**\n\t * The max of the custom data passed into the logger for each key.\n\t */\n\tdataMaxes: Record<string, number>;\n}\n\n/**\n * Helper type for an object whose properties are all numbers\n *\n * @internal\n */\nexport type CustomMetrics<TKey> = {\n\t[K in keyof TKey]: K extends string ? number : never;\n};\n\n/**\n * Potentially part of the structure of the return value of the function provided to {@link SampledTelemetryHelper.measure}.\n *\n * @see {@link MeasureReturnType} for more details on how this type is used.\n *\n * @internal\n */\nexport interface ICustomData<T> {\n\tcustomData: CustomMetrics<T>;\n}\n\n/**\n * Encapsulates the type-level logic for {@link SampledTelemetryHelper.measure}, to determine the expected return type\n * for the function that method receives (and by extension, its own return type). In words: {@link SampledTelemetryHelper}\n * is optionally provided with two generic types: one for custom metrics, and one for the actual return value of the\n * code that will be measured.\n *\n * - If no generic type is provided for custom metrics, then this type is simply the generic type provided for the actual\n * return value of the measured code (which could be void!).\n * - If a generic type is provided for custom metrics, then this type has a `customData` property whose type matches that\n * generic. Then if the generic type for the actual return value is not void, this type also has a property `returnValue`\n * whose type matches the generic type for the actual return value; if the generic type for the actual return value is\n * void, then this type _forbids_ a `returnValue` property (technically, it can exist but must be undefined in that case),\n * to try to ensure that the caller doesn't accidentally provide a function that actually returns a value.\n *\n * @internal\n */\nexport type MeasureReturnType<TMeasureReturn, TCustomMetrics> = TCustomMetrics extends void\n\t? TMeasureReturn\n\t: ICustomData<TCustomMetrics> &\n\t\t\t(TMeasureReturn extends void\n\t\t\t\t? Partial<Record<\"returnValue\", never>>\n\t\t\t\t: { returnValue: TMeasureReturn });\n\n/**\n * Helper class that executes a specified code block and writes an\n * {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified\n * number of executions is reached (or when the class is disposed).\n *\n * @remarks\n * The `duration` field in the telemetry event this class generates is the duration of the latest execution (sample)\n * of the specified code block.\n * See the documentation of the `includeAggregateMetrics` parameter for additional details that can be included.\n *\n * Telemetry events emitted by this class (both at the sample threshold and on dispose) are sent with\n * {@link @fluidframework/core-interfaces#LogLevelConst.info | LogLevel.info}.\n *\n * @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring\n * any custom metric data that might be required by this class. E.g., the code might just return a boolean.\n * @typeParam TCustomMetrics - A type that contains the custom properties that will be used by an instance of this class\n * for custom metrics. Each property in this type should be a number.\n *\n * @internal\n */\nexport class SampledTelemetryHelper<\n\tTMeasureReturn = void,\n\tTCustomMetrics extends CustomMetrics<TCustomMetrics> = void,\n> implements IDisposable\n{\n\tprivate _disposed: boolean = false;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IDisposable.disposed}\n\t */\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tprivate readonly measurementsMap = new Map<string, LoggerData>();\n\n\t/**\n\t * @param eventBase - Custom properties to include in the telemetry performance event when it is written.\n\t * @param logger - The logger to use to write the telemetry performance event.\n\t * @param sampleThreshold - Telemetry performance events will be generated every time we hit this many executions\n\t * of the code block.\n\t * @param includeAggregateMetrics - If set to `true`, the telemetry performance event will include aggregated\n\t * metrics (total duration, min duration, max duration) for all the executions in between generated events.\n\t * @param perBucketProperties - Map of strings that represent different buckets (which can be specified when calling\n\t * the 'measure' method), to properties which should be added to the telemetry event for that bucket.\n\t * If a bucket being measured does not have an entry in this map, no additional properties will be added to its\n\t * telemetry events. The following keys are reserved for use by this class: \"duration\", \"count\", \"totalDuration\",\n\t * \"minDuration\", \"maxDuration\". If any of them is specified as a key in one of the ITelemetryBaseProperties objects\n\t * in this map, that key-value pair will be ignored.\n\t */\n\tpublic constructor(\n\t\tprivate readonly eventBase: ITelemetryGenericEventExt,\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\t\tprivate readonly sampleThreshold: number,\n\t\tprivate readonly includeAggregateMetrics: boolean = false,\n\t\tprivate readonly perBucketProperties = new Map<string, ITelemetryBaseProperties>(),\n\t) {}\n\n\t/**\n\t * Executes the specified code and keeps track of execution time statistics.\n\t * When it's been called enough times (the sampleThreshold for the class) then it generates a log message with the\n\t * necessary information.\n\t *\n\t * @remarks It's the responsibility of the caller to ensure that the same same set of custom metric properties is\n\t * provided each time this method is called on a given instance of {@link SampledTelemetryHelper}.\n\t * Otherwise the final measurements in the telemetry event may not be accurate.\n\t *\n\t * @param codeToMeasure - The code to be executed and measured.\n\t * @param bucket - A key to track executions of the code block separately.\n\t * Each different value of this parameter has a separate set of executions and metrics tracked by the class.\n\t * If no such distinction needs to be made, do not provide a value.\n\t * @returns Whatever the passed-in code block returns.\n\t */\n\tpublic measure(\n\t\tcodeToMeasure: () => MeasureReturnType<TMeasureReturn, TCustomMetrics>,\n\t\tbucket: string = \"\",\n\t): MeasureReturnType<TMeasureReturn, TCustomMetrics> {\n\t\tconst start = performanceNow();\n\t\tconst returnValue = codeToMeasure();\n\t\tconst duration = performanceNow() - start;\n\n\t\tlet loggerData = this.measurementsMap.get(bucket);\n\t\tif (loggerData === undefined) {\n\t\t\tloggerData = {\n\t\t\t\tmeasurements: { count: 0, duration: -1 },\n\t\t\t\tdataSums: {},\n\t\t\t\tdataMaxes: {},\n\t\t\t};\n\t\t\tthis.measurementsMap.set(bucket, loggerData);\n\t\t}\n\n\t\tconst m = loggerData.measurements;\n\t\tm.count++;\n\t\tm.duration = duration;\n\n\t\tif (this.includeAggregateMetrics) {\n\t\t\tm.totalDuration = (m.totalDuration ?? 0) + duration;\n\t\t\tm.minDuration = Math.min(m.minDuration ?? duration, duration);\n\t\t\tm.maxDuration = Math.max(m.maxDuration ?? 0, duration);\n\t\t}\n\n\t\tif (this.isCustomData(returnValue)) {\n\t\t\tloggerData = this.accumulateCustomData(returnValue.customData, loggerData);\n\t\t}\n\n\t\tif (m.count >= this.sampleThreshold) {\n\t\t\t// Computed separately to avoid multiple division operations.\n\t\t\tif (this.includeAggregateMetrics) {\n\t\t\t\tm.averageDuration = (m.totalDuration ?? 0) / m.count;\n\t\t\t}\n\t\t\tthis.flushBucket(bucket);\n\t\t}\n\n\t\treturn returnValue;\n\t}\n\n\tprivate isCustomData(data: unknown): data is ICustomData<TCustomMetrics> {\n\t\treturn (\n\t\t\ttypeof data === \"object\" &&\n\t\t\tdata !== null &&\n\t\t\t\"customData\" in data &&\n\t\t\ttypeof data.customData === \"object\"\n\t\t);\n\t}\n\n\tprivate accumulateCustomData(\n\t\tcustomData: CustomMetrics<TCustomMetrics>,\n\t\tloggerData: LoggerData,\n\t): LoggerData {\n\t\tfor (const [key, val] of Object.entries(customData)) {\n\t\t\tassert(typeof key === \"string\", 0x9df /* Key should be a string */);\n\t\t\tassert(typeof val === \"number\", 0x9e0 /* Value should be a number */);\n\n\t\t\tloggerData.dataSums[key] = (loggerData.dataSums[key] ?? 0) + val;\n\t\t\tloggerData.dataMaxes[key] = Math.max(\n\t\t\t\tloggerData.dataMaxes[key] ?? Number.NEGATIVE_INFINITY,\n\t\t\t\tval,\n\t\t\t);\n\t\t}\n\n\t\treturn loggerData;\n\t}\n\n\tprivate processCustomData(loggerData: LoggerData, count: number): Record<string, number> {\n\t\tconst processedCustomData: Record<string, number> = {};\n\n\t\tif (loggerData.dataSums === undefined || loggerData.dataMaxes === undefined) {\n\t\t\treturn processedCustomData;\n\t\t}\n\n\t\tconst dataSums = loggerData.dataSums;\n\t\tconst dataMaxes = loggerData.dataMaxes;\n\n\t\tfor (const [key, val] of Object.entries(dataSums)) {\n\t\t\t// implementation of class guarantees the keys between dataMaxes and dataSums align.\n\t\t\tprocessedCustomData[`avg_${key}`] = roundToDecimalPlaces(val / count, 6);\n\t\t\tprocessedCustomData[`max_${key}`] = dataMaxes[key] ?? 0;\n\t\t}\n\n\t\treturn processedCustomData;\n\t}\n\n\tprivate flushBucket(bucket: string): void {\n\t\tconst loggerData = this.measurementsMap.get(bucket);\n\t\tif (loggerData === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst measurements = loggerData.measurements;\n\n\t\tconst processedCustomData = this.processCustomData(loggerData, measurements.count);\n\n\t\tif (measurements.count !== 0) {\n\t\t\tconst bucketProperties = this.perBucketProperties.get(bucket);\n\n\t\t\tconst telemetryEvent: ITelemetryPerformanceEventExt = {\n\t\t\t\t...this.eventBase,\n\t\t\t\t...bucketProperties, // If the bucket doesn't exist and this is undefined, things work as expected\n\t\t\t\t...measurements,\n\t\t\t\t...processedCustomData,\n\t\t\t};\n\n\t\t\tthis.logger.sendPerformanceEvent(\n\t\t\t\ttelemetryEvent,\n\t\t\t\tundefined, // error\n\t\t\t\tLogLevel.info,\n\t\t\t);\n\t\t\tthis.measurementsMap.delete(bucket);\n\t\t}\n\t}\n\n\tpublic dispose(error?: Error | undefined): void {\n\t\tfor (const [k] of this.measurementsMap.entries()) {\n\t\t\tthis.flushBucket(k);\n\t\t}\n\t\tthis._disposed = true;\n\t}\n}\n"]}

@@ -119,7 +119,8 @@ /*!

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @deprecated This method is being removed without a replacement.
* @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
*/
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
/**

@@ -137,7 +138,8 @@ * Send an error telemetry event.

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @deprecated This method is being removed without a replacement.
* @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
*/
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
}

@@ -157,5 +159,6 @@ /**

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.
* @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
/**

@@ -171,6 +174,7 @@ * Send an error telemetry event.

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevelConst.default | LogLevel.default}.
* @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
}
//# sourceMappingURL=telemetryTypes.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GACtC,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;AAEzF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC3C,MAAM,EAC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C;IAER;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtE;;;;;;OAMG;IACH,oBAAoB,CACnB,KAAK,EAAE,6BAA6B,EACpC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,IAAI,GACvD,IAAI,CAAC;CACR"}

@@ -1,1 +0,1 @@

{"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @legacy @beta\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @legacy @beta\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>\n>;\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * This is the externally facing type for a FluidFramework internal telemetry logger wrapper.\n *\n * @remarks\n * The methods if this interface are not to be used directly by consumers and are all\n * deprecated to removed without replacement. This type is not deprecated and will\n * transition to an erased type to handle cases where \"internal\" `ITelemetryLoggerExt`\n * previously leaked out.\n *\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for deprecation and breaking change details.\n *\n * @privateRemarks\n * External APIs taking in an `ITelemetryLoggerExt` ideally should be updated to\n * accept `ITelemetryBaseLogger` instead.\n *\n * @sealed\n * @legacy\n * @beta\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\n * This interface is meant to be used internally within the Fluid Framework,\n * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.\n * @internal\n */\nexport interface TelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevelConst.default | LogLevel.default}.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n}\n"]}
{"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @legacy @beta\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @legacy @beta\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>\n>;\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * This is the externally facing type for a FluidFramework internal telemetry logger wrapper.\n *\n * @remarks\n * The methods if this interface are not to be used directly by consumers and are all\n * deprecated to removed without replacement. This type is not deprecated and will\n * transition to an erased type to handle cases where \"internal\" `ITelemetryLoggerExt`\n * previously leaked out.\n *\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for deprecation and breaking change details.\n *\n * @privateRemarks\n * External APIs taking in an `ITelemetryLoggerExt` ideally should be updated to\n * accept `ITelemetryBaseLogger` instead.\n *\n * @sealed\n * @legacy\n * @beta\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\n * This interface is meant to be used internally within the Fluid Framework,\n * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.\n * @internal\n */\nexport interface TelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n}\n"]}

@@ -1,1 +0,1 @@

{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAEX,kBAAkB,EAClB,MAAM,iCAAiC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IAClE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,CAAC,EAAE,aAAa,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CA8CzB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAKlF"}
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAEX,kBAAkB,EAClB,MAAM,iCAAiC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IAClE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,CAAC,EAAE,aAAa,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CAsDzB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAKlF"}

@@ -26,3 +26,3 @@ /*!

const sampledLogger = {
send: (event) => {
send: (event, logLevel) => {
// The sampler uses the following logic for sending events:

@@ -36,6 +36,6 @@ // 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.

}
logger.send(event);
logger.send(event, logLevel);
}
},
sendTelemetryEvent: (event) => {
sendTelemetryEvent: (event, error, logLevel) => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -45,6 +45,6 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendTelemetryEvent(event);
logger.sendTelemetryEvent(event, error, logLevel);
}
},
sendErrorEvent: (event) => {
sendErrorEvent: (event, error) => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -54,6 +54,6 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendErrorEvent(event);
logger.sendErrorEvent(event, error);
}
},
sendPerformanceEvent: (event) => {
sendPerformanceEvent: (event, error, logLevel) => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -63,3 +63,3 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendPerformanceEvent(event);
logger.sendPerformanceEvent(event, error, logLevel);
}

@@ -66,0 +66,0 @@ },

@@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,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAI,aAAsB;IAChD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends TelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: TelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n\tskipLoggingWhenSamplingIsDisabled?: boolean,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.send(event);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendPerformanceEvent(event);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n\n/**\n * Runs the specified function and returns an object with the time it took to run as well as any output from it.\n * @remarks Useful in conjunction with {@link TelemetryEventBatcher}.\n *\n * @param codeToMeasure - The code to be executed and measured.\n * @returns The total duration of the code execution and whatever the passed-in code block returns.\n * @internal\n */\nexport function measure<T>(codeToMeasure: () => T): { duration: number; output: T } {\n\tconst start = performance.now();\n\tconst output = codeToMeasure();\n\tconst duration = performance.now() - start;\n\treturn { duration, output };\n}\n"]}
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,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AAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACrC,CAAC;QACF,CAAC;QACD,oBAAoB,EAAE,CACrB,KAAgC,EAChC,KAAe,EACf,QAAyD,EAClD,EAAE;YACT,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrD,CAAC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAI,aAAsB;IAChD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent, LogLevel } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends TelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: TelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n\tskipLoggingWhenSamplingIsDisabled?: boolean,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent, logLevel?: LogLevel): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.send(event, logLevel);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (\n\t\t\tevent: ITelemetryGenericEventExt,\n\t\t\terror?: unknown,\n\t\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t\t): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendTelemetryEvent(event, error, logLevel);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt, error?: unknown): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendErrorEvent(event, error);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (\n\t\t\tevent: ITelemetryGenericEventExt,\n\t\t\terror?: unknown,\n\t\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t\t): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendPerformanceEvent(event, error, logLevel);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n\n/**\n * Runs the specified function and returns an object with the time it took to run as well as any output from it.\n * @remarks Useful in conjunction with {@link TelemetryEventBatcher}.\n *\n * @param codeToMeasure - The code to be executed and measured.\n * @returns The total duration of the code execution and whatever the passed-in code block returns.\n * @internal\n */\nexport function measure<T>(codeToMeasure: () => T): { duration: number; output: T } {\n\tconst start = performance.now();\n\tconst output = codeToMeasure();\n\tconst duration = performance.now() - start;\n\treturn { duration, output };\n}\n"]}
{
"name": "@fluidframework/telemetry-utils",
"version": "2.100.0",
"version": "2.101.0",
"description": "Collection of telemetry relates utilities for Fluid",

@@ -72,6 +72,6 @@ "homepage": "https://fluidframework.com",

"dependencies": {
"@fluid-internal/client-utils": "~2.100.0",
"@fluidframework/core-interfaces": "~2.100.0",
"@fluidframework/core-utils": "~2.100.0",
"@fluidframework/driver-definitions": "~2.100.0",
"@fluid-internal/client-utils": "~2.101.0",
"@fluidframework/core-interfaces": "~2.101.0",
"@fluidframework/core-utils": "~2.101.0",
"@fluidframework/driver-definitions": "~2.101.0",
"debug": "^4.3.4",

@@ -83,3 +83,3 @@ "uuid": "^11.1.0"

"@biomejs/biome": "~2.4.5",
"@fluid-internal/mocha-test-setup": "~2.100.0",
"@fluid-internal/mocha-test-setup": "~2.101.0",
"@fluid-tools/build-cli": "^0.65.0",

@@ -86,0 +86,0 @@ "@fluidframework/build-common": "^2.0.3",

@@ -11,2 +11,3 @@ /*!

} from "@fluidframework/core-interfaces";
import { LogLevel } from "@fluidframework/core-interfaces";
import { Lazy } from "@fluidframework/core-utils/internal";

@@ -250,10 +251,13 @@

this.configCache.set(name, parsed);
this.logger?.send({
category: "generic",
eventName: "ConfigRead",
...tagCodeArtifacts({
configName: name,
configValue: JSON.stringify(parsed),
}),
});
this.logger?.send(
{
category: "generic",
eventName: "ConfigRead",
...tagCodeArtifacts({
configName: name,
configValue: JSON.stringify(parsed),
}),
},
LogLevel.info,
);
return parsed;

@@ -260,0 +264,0 @@ }

@@ -227,4 +227,4 @@ /*!

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/

@@ -234,3 +234,3 @@ public sendTelemetryEvent(

error?: unknown,
logLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): void {

@@ -240,3 +240,3 @@ this.sendTelemetryEventCore(

error,
event.category === "error" ? LogLevel.error : logLevel,
event.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential),
);

@@ -250,8 +250,8 @@ }

* @param error - optional error object to log
* @param logLevel - optional level of the log.
* @param logLevel - level of the log.
*/
protected sendTelemetryEventCore(
private sendTelemetryEventCore(
event: ITelemetryGenericEventExt & { category: TelemetryEventCategory },
error?: unknown,
logLevel?: LogLevel,
error: unknown,
logLevel: LogLevel,
): void {

@@ -287,3 +287,3 @@ const newEvent = convertToBaseEvent(event);

error,
LogLevel.error,
LogLevel.essential,
);

@@ -297,4 +297,4 @@ }

* @param error - optional error object to log
* @param logLevel - optional level of the log. It category of event is set as error,
* then the logLevel will be upgraded to be an error.
* @param logLevel - optional level of the log. If the event's category is `error`,
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/

@@ -304,3 +304,3 @@ public sendPerformanceEvent(

error?: unknown,
logLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): void {

@@ -315,3 +315,3 @@ const perfEvent = {

error,
perfEvent.category === "error" ? LogLevel.error : logLevel,
perfEvent.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential),
);

@@ -529,4 +529,4 @@ }

private shouldFilterOutEvent(event: ITelemetryBaseEvent, logLevel?: LogLevel): boolean {
const eventLogLevel = logLevel ?? LogLevel.default;
const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.default;
const eventLogLevel = logLevel ?? LogLevel.essential;
const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.info;
// Filter out in case event log level is below what is wanted in config.

@@ -545,3 +545,3 @@ return eventLogLevel < configLogLevel;

}
this.baseLogger.send(this.prepareEvent(event), logLevel);
this.baseLogger.send(this.prepareEvent(event), logLevel ?? LogLevel.essential);
}

@@ -631,3 +631,3 @@ }

this.loggers = loggers;
this._minLogLevelOfAllLoggers = LogLevel.default;
this._minLogLevelOfAllLoggers = LogLevel.info;
this.calculateMinLogLevel();

@@ -644,3 +644,3 @@ }

for (const logger of this.loggers) {
logLevels.push(logger.minLogLevel ?? LogLevel.default);
logLevels.push(logger.minLogLevel ?? LogLevel.info);
}

@@ -668,6 +668,6 @@ this._minLogLevelOfAllLoggers = Math.min(...logLevels) as LogLevel;

*/
public send(event: ITelemetryBaseEvent): void {
public send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {
const newEvent = this.prepareEvent(event);
for (const logger of this.loggers) {
logger.send(newEvent);
logger.send(newEvent, logLevel ?? LogLevel.essential);
}

@@ -708,2 +708,4 @@ }

* but measurements will still be performed and any specified markers will be generated.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns An instance of {@link PerformanceEvent}

@@ -716,4 +718,11 @@ */

emitLogs: boolean = true,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): PerformanceEvent {
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs);
return new PerformanceEvent(
extractTelemetryLoggerExt(logger),
event,
markers,
emitLogs,
logLevel,
);
}

@@ -729,2 +738,4 @@

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -743,2 +754,3 @@ *

sampleThreshold: number = 1,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): T {

@@ -750,2 +762,3 @@ const perfEvent = PerformanceEvent.start(

PerformanceEvent.shouldReport(event, sampleThreshold),
logLevel,
);

@@ -771,2 +784,4 @@ try {

* only when we hit this many executions of the task. If unspecified, all events will be sent.
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
* @returns The results of the executed task

@@ -785,2 +800,3 @@ *

sampleThreshold: number = 1,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): Promise<T> {

@@ -792,2 +808,3 @@ const perfEvent = PerformanceEvent.start(

PerformanceEvent.shouldReport(event, sampleThreshold),
logLevel,
);

@@ -812,3 +829,3 @@ try {

protected constructor(
private constructor(
private readonly logger: TelemetryLoggerExt,

@@ -818,2 +835,3 @@ event: ITelemetryGenericEventExt,

private readonly emitLogs: boolean = true,
private readonly logLevel: typeof LogLevel.verbose | typeof LogLevel.info | undefined,
) {

@@ -903,3 +921,3 @@ this.event = { ...event };

this.logger.sendPerformanceEvent(event, error);
this.logger.sendPerformanceEvent(event, error, this.logLevel);
}

@@ -906,0 +924,0 @@

@@ -44,3 +44,3 @@ /*!

public constructor(minLogLevel?: LogLevel) {
this.minLogLevel = minLogLevel ?? LogLevel.default;
this.minLogLevel = minLogLevel ?? LogLevel.info;
}

@@ -63,3 +63,3 @@

public send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void {
if ((logLevel ?? LogLevel.default) >= this.minLogLevel) {
if ((logLevel ?? LogLevel.essential) >= this.minLogLevel) {
this._events.push(event);

@@ -66,0 +66,0 @@ }

@@ -8,2 +8,3 @@ /*!

import type { IDisposable, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
import { LogLevel } from "@fluidframework/core-interfaces";
import { assert } from "@fluidframework/core-utils/internal";

@@ -128,2 +129,5 @@

*
* Telemetry events emitted by this class (both at the sample threshold and on dispose) are sent with
* {@link @fluidframework/core-interfaces#LogLevelConst.info | LogLevel.info}.
*
* @typeParam TMeasurementReturn - The return type (in a vacuum) of the code block that will be measured, ignoring

@@ -298,3 +302,7 @@ * any custom metric data that might be required by this class. E.g., the code might just return a boolean.

this.logger.sendPerformanceEvent(telemetryEvent);
this.logger.sendPerformanceEvent(
telemetryEvent,
undefined, // error
LogLevel.info,
);
this.measurementsMap.delete(bucket);

@@ -301,0 +309,0 @@ }

@@ -139,3 +139,4 @@ /*!

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @deprecated This method is being removed without a replacement.

@@ -147,3 +148,3 @@ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.

error?: unknown,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.default,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): void;

@@ -164,3 +165,4 @@

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.
* @deprecated This method is being removed without a replacement.

@@ -172,3 +174,3 @@ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.

error?: unknown,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.default,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): void;

@@ -190,3 +192,4 @@ }

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.
* @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/

@@ -196,3 +199,3 @@ sendTelemetryEvent(

error?: unknown,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.default,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): void;

@@ -211,3 +214,4 @@

* @param error - Optional error object to log.
* @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevelConst.default | LogLevel.default}.
* @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
* If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
*/

@@ -217,4 +221,4 @@ sendPerformanceEvent(

error?: unknown,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.default,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): void;
}

@@ -6,3 +6,3 @@ /*!

import type { ITelemetryBaseEvent } from "@fluidframework/core-interfaces";
import type { ITelemetryBaseEvent, LogLevel } from "@fluidframework/core-interfaces";

@@ -70,3 +70,3 @@ import { loggerToMonitoringContext } from "./config.js";

const sampledLogger = {
send: (event: ITelemetryBaseEvent): void => {
send: (event: ITelemetryBaseEvent, logLevel?: LogLevel): void => {
// The sampler uses the following logic for sending events:

@@ -80,6 +80,10 @@ // 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.

}
logger.send(event);
logger.send(event, logLevel);
}
},
sendTelemetryEvent: (event: ITelemetryGenericEventExt): void => {
sendTelemetryEvent: (
event: ITelemetryGenericEventExt,
error?: unknown,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): void => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -89,6 +93,6 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendTelemetryEvent(event);
logger.sendTelemetryEvent(event, error, logLevel);
}
},
sendErrorEvent: (event: ITelemetryGenericEventExt): void => {
sendErrorEvent: (event: ITelemetryGenericEventExt, error?: unknown): void => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -98,6 +102,10 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendErrorEvent(event);
logger.sendErrorEvent(event, error);
}
},
sendPerformanceEvent: (event: ITelemetryGenericEventExt): void => {
sendPerformanceEvent: (
event: ITelemetryGenericEventExt,
error?: unknown,
logLevel?: typeof LogLevel.verbose | typeof LogLevel.info,
): void => {
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {

@@ -107,3 +115,3 @@ if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {

}
logger.sendPerformanceEvent(event);
logger.sendPerformanceEvent(event, error, logLevel);
}

@@ -110,0 +118,0 @@ },