@fluidframework/telemetry-utils 2.93.0 → 2.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/DEV.md +33 -0
- package/api-extractor/api-extractor-lint-api-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-bundle.json +1 -1
- package/api-extractor.json +2 -1
- package/api-report/telemetry-utils.legacy.beta.api.md +8 -5
- package/dist/api.d.ts +26 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +40 -0
- package/dist/api.js.map +1 -0
- package/dist/config.d.ts +6 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/errorLogging.d.ts +2 -2
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js.map +1 -1
- package/dist/events.d.ts +3 -3
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/{index.d.ts → internal.d.ts} +16 -4
- package/dist/internal.d.ts.map +1 -0
- package/dist/{index.js → internal.js} +22 -5
- package/dist/internal.js.map +1 -0
- package/dist/legacy.d.ts +2 -2
- package/dist/logger.d.ts +45 -10
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +43 -5
- package/dist/logger.js.map +1 -1
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +13 -0
- package/dist/main.js.map +1 -0
- package/dist/mockLogger.d.ts +5 -4
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/sampledTelemetryHelper.d.ts +2 -2
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/telemetryEventBatcher.d.ts +2 -2
- package/dist/telemetryEventBatcher.d.ts.map +1 -1
- package/dist/telemetryEventBatcher.js.map +1 -1
- package/dist/telemetryTypes.d.ts +58 -3
- package/dist/telemetryTypes.d.ts.map +1 -1
- package/dist/telemetryTypes.js.map +1 -1
- package/dist/telemetryTypesUndeprecated.d.ts +36 -0
- package/dist/telemetryTypesUndeprecated.d.ts.map +1 -0
- package/dist/telemetryTypesUndeprecated.js +7 -0
- package/dist/telemetryTypesUndeprecated.js.map +1 -0
- package/dist/thresholdCounter.d.ts +2 -2
- package/dist/thresholdCounter.d.ts.map +1 -1
- package/dist/thresholdCounter.js.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/internal.d.ts +2 -2
- package/legacy.d.ts +1 -1
- package/lib/api.d.ts +26 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +22 -0
- package/lib/api.js.map +1 -0
- package/lib/config.d.ts +6 -6
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -0
- package/lib/config.js.map +1 -1
- package/lib/errorLogging.d.ts +2 -2
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js.map +1 -1
- package/lib/events.d.ts +3 -3
- package/lib/events.d.ts.map +1 -1
- package/lib/events.js.map +1 -1
- package/lib/{index.d.ts → internal.d.ts} +16 -4
- package/lib/internal.d.ts.map +1 -0
- package/lib/{index.js → internal.js} +5 -3
- package/lib/internal.js.map +1 -0
- package/lib/legacy.d.ts +2 -2
- package/lib/logger.d.ts +45 -10
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +40 -4
- package/lib/logger.js.map +1 -1
- package/lib/main.d.ts +8 -0
- package/lib/main.d.ts.map +1 -0
- package/lib/main.js +9 -0
- package/lib/main.js.map +1 -0
- package/lib/mockLogger.d.ts +5 -4
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/sampledTelemetryHelper.d.ts +2 -2
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/telemetryEventBatcher.d.ts +2 -2
- package/lib/telemetryEventBatcher.d.ts.map +1 -1
- package/lib/telemetryEventBatcher.js.map +1 -1
- package/lib/telemetryTypes.d.ts +58 -3
- package/lib/telemetryTypes.d.ts.map +1 -1
- package/lib/telemetryTypes.js.map +1 -1
- package/lib/telemetryTypesUndeprecated.d.ts +36 -0
- package/lib/telemetryTypesUndeprecated.d.ts.map +1 -0
- package/lib/telemetryTypesUndeprecated.js +6 -0
- package/lib/telemetryTypesUndeprecated.js.map +1 -0
- package/lib/thresholdCounter.d.ts +2 -2
- package/lib/thresholdCounter.d.ts.map +1 -1
- package/lib/thresholdCounter.js.map +1 -1
- package/lib/utils.d.ts +4 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +21 -19
- package/src/api.ts +44 -0
- package/src/config.ts +17 -11
- package/src/errorLogging.ts +2 -2
- package/src/events.ts +3 -3
- package/src/{index.ts → internal.ts} +23 -8
- package/src/logger.ts +74 -15
- package/src/main.ts +19 -0
- package/src/mockLogger.ts +4 -4
- package/src/sampledTelemetryHelper.ts +3 -3
- package/src/telemetryEventBatcher.ts +3 -3
- package/src/telemetryTypes.ts +69 -3
- package/src/telemetryTypesUndeprecated.ts +51 -0
- package/src/thresholdCounter.ts +2 -2
- package/src/utils.ts +7 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @fluidframework/telemetry-utils
|
|
2
2
|
|
|
3
|
+
## 2.100.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Node 22 is now the minimum supported Node.js version ([#27116](https://github.com/microsoft/FluidFramework/pull/27116)) [e8214d29663](https://github.com/microsoft/FluidFramework/commit/e8214d29663f5ee98d737daed82506a25d8de8d0)
|
|
8
|
+
|
|
9
|
+
All Fluid Framework client packages now require Node.js 22 or later. This aligns with the standing Node upgrade policy as Node 20 reaches end-of-life on April 30, 2026.
|
|
10
|
+
|
|
11
|
+
- Deprecate ITelemetryLoggerExt methods and related types ([#26912](https://github.com/microsoft/FluidFramework/pull/26912)) [42b77ab8455](https://github.com/microsoft/FluidFramework/commit/42b77ab8455dd2a691442bcfbca7bac970f988fe)
|
|
12
|
+
|
|
13
|
+
`ITelemetryLoggerExt` is only for internal Fluid Framework use. The following deprecations help formalize that. See [issue #26910](https://github.com/microsoft/FluidFramework/issues/26910) for details.
|
|
14
|
+
|
|
15
|
+
| API | Kind | Package Export |
|
|
16
|
+
| -------------------------------------------- | ---------- | ----------------- |
|
|
17
|
+
| `TelemetryEventCategory` | Type alias | `@legacy` `@beta` |
|
|
18
|
+
| `ITelemetryGenericEventExt` | Interface | `@legacy` `@beta` |
|
|
19
|
+
| `ITelemetryErrorEventExt` | Interface | `@legacy` `@beta` |
|
|
20
|
+
| `ITelemetryPerformanceEventExt` | Interface | `@legacy` `@beta` |
|
|
21
|
+
| `ITelemetryLoggerExt.sendTelemetryEvent()` | Method | `@legacy` `@beta` |
|
|
22
|
+
| `ITelemetryLoggerExt.sendErrorEvent()` | Method | `@legacy` `@beta` |
|
|
23
|
+
| `ITelemetryLoggerExt.sendPerformanceEvent()` | Method | `@legacy` `@beta` |
|
|
24
|
+
|
|
3
25
|
## 2.93.0
|
|
4
26
|
|
|
5
27
|
Dependency updates only.
|
package/DEV.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Internal entrypoint source structure for `@fluidframework/telemetry-utils`
|
|
2
|
+
|
|
3
|
+
Note: index.ts is avoided as the external (see [src/api.ts](#srcapits) and internal (see [src/internal.ts](#srcinternalts) entrypoints are reasonably different.
|
|
4
|
+
There is no way in which a single file can act as source for both use cases as there are exports common to both that have different attributes or even definitions.
|
|
5
|
+
Even if those conflicts were removed isolating internals provides clarity and offers ability to stage deprecations and refactors cleanly.
|
|
6
|
+
|
|
7
|
+
## src/main.ts
|
|
8
|
+
|
|
9
|
+
Barrel file for all of the common externally accessible APIs.
|
|
10
|
+
|
|
11
|
+
## src/api.ts
|
|
12
|
+
|
|
13
|
+
Main entry for external access that re-exports main.ts and adds external specific APIs or at least specifically typed versions of APIs.
|
|
14
|
+
This is processed for entrypoint generation along public and legacy lines.
|
|
15
|
+
|
|
16
|
+
## src/internal.ts
|
|
17
|
+
|
|
18
|
+
Main entry for internal access that re-exports main.ts and all internal only APIs, which mak up the largest part of this package.
|
|
19
|
+
This can include non-deprecated versions of externally accessible APIs and/or APIs with internal-only typing.
|
|
20
|
+
|
|
21
|
+
# Current work
|
|
22
|
+
|
|
23
|
+
## ITelemetryLoggerExt external deprecation
|
|
24
|
+
|
|
25
|
+
Internally `TelemetryLoggerExt` maybe used to access internal, extended logger. Externally `ITelemetryLoggerExt` is passed around.
|
|
26
|
+
Until a breaking change can be made these two types are structurally equivalent and must remain so.
|
|
27
|
+
The one difference is that `ITelemetryLoggerExt` has `@deprecated` methods to discourage use.
|
|
28
|
+
Once breaking change can be made, `ITelemetryLoggerExt` will become a branded type without any viable methods and thus neither external nor internal code may act upon it.
|
|
29
|
+
Internally, `extractTelemetryLoggerExt` can be used to get `TelemetryLoggerExt` from `ITelemetryLoggerExt`.
|
|
30
|
+
These transitions are already put in place and should be preserved.
|
|
31
|
+
Similarly, `toITelemetryLoggerExt` can be used to go the other direction.
|
|
32
|
+
|
|
33
|
+
The deprecation is tracked by [issue #26910](https://github.com/microsoft/FluidFramework/issues/26910).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
3
|
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.json",
|
|
4
|
-
"mainEntryPointFilePath": "<projectFolder>/lib/
|
|
4
|
+
"mainEntryPointFilePath": "<projectFolder>/lib/internal.d.ts"
|
|
5
5
|
}
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "../../../common/build/build-common/api-extractor-model.esm.json"
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-model.esm.json",
|
|
4
|
+
"mainEntryPointFilePath": "<projectFolder>/lib/api.d.ts"
|
|
4
5
|
}
|
|
@@ -18,21 +18,24 @@ export class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> exten
|
|
|
18
18
|
emit(event: EventEmitterEventType, ...args: unknown[]): boolean;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// @beta @legacy
|
|
21
|
+
// @beta @deprecated @legacy
|
|
22
22
|
export interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
|
|
23
23
|
eventName: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// @beta @legacy
|
|
26
|
+
// @beta @deprecated @legacy
|
|
27
27
|
export interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
|
|
28
28
|
category?: TelemetryEventCategory;
|
|
29
29
|
eventName: string;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// @beta @legacy
|
|
32
|
+
// @beta @sealed @legacy
|
|
33
33
|
export interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
|
|
34
|
+
// @deprecated
|
|
34
35
|
sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;
|
|
36
|
+
// @deprecated
|
|
35
37
|
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
|
|
38
|
+
// @deprecated
|
|
36
39
|
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -47,7 +50,7 @@ export interface ITelemetryLoggerPropertyBags {
|
|
|
47
50
|
error?: ITelemetryLoggerPropertyBag;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
// @beta @legacy
|
|
53
|
+
// @beta @deprecated @legacy
|
|
51
54
|
export interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {
|
|
52
55
|
duration?: number;
|
|
53
56
|
}
|
|
@@ -55,7 +58,7 @@ export interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt
|
|
|
55
58
|
// @beta @legacy
|
|
56
59
|
export type ITelemetryPropertiesExt = Record<string, TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>>;
|
|
57
60
|
|
|
58
|
-
// @beta @legacy
|
|
61
|
+
// @beta @deprecated @legacy
|
|
59
62
|
export type TelemetryEventCategory = "generic" | "error" | "performance";
|
|
60
63
|
|
|
61
64
|
// @beta @legacy
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./main.js";
|
|
6
|
+
export type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryLoggerExt, ITelemetryPerformanceEventExt, TelemetryEventCategory, } from "./telemetryTypes.js";
|
|
7
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
8
|
+
import type { ITelemetryLoggerPropertyBags } from "./logger.js";
|
|
9
|
+
import type { ITelemetryLoggerExt } from "./telemetryTypes.js";
|
|
10
|
+
/**
|
|
11
|
+
* Create a child logger based on the provided props object.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.
|
|
15
|
+
*
|
|
16
|
+
* @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.
|
|
17
|
+
*
|
|
18
|
+
* @legacy
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export declare function createChildLogger(props?: {
|
|
22
|
+
logger?: ITelemetryBaseLogger;
|
|
23
|
+
namespace?: string;
|
|
24
|
+
properties?: ITelemetryLoggerPropertyBags;
|
|
25
|
+
}): ITelemetryLoggerExt;
|
|
26
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,WAAW,CAAC;AAG1B,YAAY,EACX,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE;IACzC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,4BAA4B,CAAC;CAC1C,GAAG,mBAAmB,CAEtB"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.createChildLogger = void 0;
|
|
22
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
23
|
+
__exportStar(require("./main.js"), exports);
|
|
24
|
+
const logger_js_1 = require("./logger.js");
|
|
25
|
+
/**
|
|
26
|
+
* Create a child logger based on the provided props object.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.
|
|
30
|
+
*
|
|
31
|
+
* @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.
|
|
32
|
+
*
|
|
33
|
+
* @legacy
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
36
|
+
function createChildLogger(props) {
|
|
37
|
+
return (0, logger_js_1.createChildLogger)(props);
|
|
38
|
+
}
|
|
39
|
+
exports.createChildLogger = createChildLogger;
|
|
40
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,gDAAgD;AAChD,4CAA0B;AAiB1B,2CAA6E;AAG7E;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAAC,KAIjC;IACA,OAAO,IAAA,6BAAyB,EAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line no-restricted-syntax\nexport * from \"./main.js\";\n\n// Additional APIs that are deprecated and thus left out of the common export set.\nexport type {\n\tITelemetryErrorEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypes.js\";\n\n// ----------------------------------------------------------------------------\n// Export `createChildLogger` helper without internal `TelemetryLoggerExt`\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\n\nimport type { ITelemetryLoggerPropertyBags } from \"./logger.js\";\nimport { createChildLogger as createChildLoggerInternal } from \"./logger.js\";\nimport type { ITelemetryLoggerExt } from \"./telemetryTypes.js\";\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 * @legacy\n * @beta\n */\nexport function createChildLogger(props?: {\n\tlogger?: ITelemetryBaseLogger;\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n}): ITelemetryLoggerExt {\n\treturn createChildLoggerInternal(props);\n}\n"]}
|
package/dist/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { ConfigTypes, IConfigProviderBase, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { Lazy } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { createChildLogger } from "./logger.js";
|
|
8
|
-
import type { ITelemetryLoggerExt } from "./telemetryTypes.js";
|
|
8
|
+
import type { ITelemetryLoggerExt, TelemetryLoggerExt } from "./telemetryTypes.js";
|
|
9
9
|
/**
|
|
10
10
|
* Explicitly typed interface for reading configurations.
|
|
11
11
|
*
|
|
@@ -69,9 +69,9 @@ export declare class CachedConfigProvider implements IConfigProvider {
|
|
|
69
69
|
*
|
|
70
70
|
* @internal
|
|
71
71
|
*/
|
|
72
|
-
export interface MonitoringContext<L extends ITelemetryBaseLogger =
|
|
72
|
+
export interface MonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt> {
|
|
73
73
|
config: IConfigProvider;
|
|
74
|
-
logger: L;
|
|
74
|
+
logger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Determines whether or not the provided object is a {@link MonitoringContext}.
|
|
@@ -79,13 +79,13 @@ export interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLo
|
|
|
79
79
|
*
|
|
80
80
|
* @internal
|
|
81
81
|
*/
|
|
82
|
-
export declare function loggerIsMonitoringContext<L extends ITelemetryBaseLogger =
|
|
82
|
+
export declare function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(obj: L): obj is L & MonitoringContext<L>;
|
|
83
83
|
/**
|
|
84
84
|
* Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.
|
|
85
85
|
*
|
|
86
86
|
* @internal
|
|
87
87
|
*/
|
|
88
|
-
export declare function loggerToMonitoringContext<L extends ITelemetryBaseLogger =
|
|
88
|
+
export declare function loggerToMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(logger: L): MonitoringContext<L>;
|
|
89
89
|
/**
|
|
90
90
|
* Creates a {@link MonitoringContext} from the provided logger.
|
|
91
91
|
*
|
|
@@ -97,7 +97,7 @@ export declare function loggerToMonitoringContext<L extends ITelemetryBaseLogger
|
|
|
97
97
|
*
|
|
98
98
|
* @internal
|
|
99
99
|
*/
|
|
100
|
-
export declare function mixinMonitoringContext<L extends ITelemetryBaseLogger =
|
|
100
|
+
export declare function mixinMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(logger: L, ...configs: (IConfigProviderBase | undefined)[]): MonitoringContext<L>;
|
|
101
101
|
/**
|
|
102
102
|
* Creates a child logger with a {@link MonitoringContext}.
|
|
103
103
|
*
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;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,MAAM,qBAAqB,CAAC;
|
|
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,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG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zB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CA6BtB"}
|
package/dist/config.js
CHANGED
|
@@ -261,6 +261,8 @@ function mixinMonitoringContext(logger, ...configs) {
|
|
|
261
261
|
*/
|
|
262
262
|
const mc = logger;
|
|
263
263
|
mc.config = new CachedConfigProvider(logger, ...configs);
|
|
264
|
+
// Cast is similar to `extractTelemetryLoggerExt` but preserves other
|
|
265
|
+
// logger types rather than just returning `TelemetryLoggerExt`.
|
|
264
266
|
mc.logger = logger;
|
|
265
267
|
return mc;
|
|
266
268
|
}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,CAA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AAG,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 { Lazy } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger, tagCodeArtifacts } from \"./logger.js\";\nimport type { ITelemetryLoggerExt } 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 = ITelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\tlogger: 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<\n\tL extends ITelemetryBaseLogger = ITelemetryLoggerExt,\n>(obj: L): 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<\n\tL extends ITelemetryBaseLogger = ITelemetryLoggerExt,\n>(logger: L): 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 = ITelemetryLoggerExt>(\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\tmc.logger = logger;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\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"]}
|
|
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;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AAG,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 { 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"]}
|
package/dist/errorLogging.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { ITelemetryBaseProperties, Tagged } from "@fluidframework/core-interfaces";
|
|
6
6
|
import type { ILoggingError } from "@fluidframework/core-interfaces/internal";
|
|
7
7
|
import { type IFluidErrorBase } from "./fluidErrorBase.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { TelemetryLoggerExt, ITelemetryPropertiesExt, TelemetryEventPropertyTypeExt } from "./telemetryTypes.js";
|
|
9
9
|
/**
|
|
10
10
|
* Inspect the given error for common "safe" props and return them.
|
|
11
11
|
*
|
|
@@ -80,7 +80,7 @@ export declare function wrapError<T extends LoggingError>(innerError: unknown, n
|
|
|
80
80
|
*
|
|
81
81
|
* @internal
|
|
82
82
|
*/
|
|
83
|
-
export declare function wrapErrorAndLog<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T, logger:
|
|
83
|
+
export declare function wrapErrorAndLog<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T, logger: TelemetryLoggerExt): T;
|
|
84
84
|
/**
|
|
85
85
|
* Attempts to overwrite the error's stack
|
|
86
86
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorLogging.d.ts","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAG9E,OAAO,EAAE,KAAK,eAAe,EAAoC,MAAM,qBAAqB,CAAC;AAE7F,OAAO,KAAK,EACX,
|
|
1
|
+
{"version":3,"file":"errorLogging.d.ts","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAG9E,OAAO,EAAE,KAAK,eAAe,EAAoC,MAAM,qBAAqB,CAAC;AAE7F,OAAO,KAAK,EACX,kBAAkB,EAClB,uBAAuB,EACvB,6BAA6B,EAC7B,MAAM,qBAAqB,CAAC;AAS7B;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,KAAK,EAAE,OAAO,EACd,aAAa,EAAE,OAAO,GACpB;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAoCA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,MAAO,OAAO,uBACkC,CAAC;AAgB7E;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,wBAAwB,CAAC;CACjC;A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AAmB,UAAsD;QACxE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAL3B,2EAA2E;QAC3E,4EAA4E;QAC5D,cAAS,GAAG,6BAAqB,CAAC;QAKjD,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACpC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties, Tagged } from \"@fluidframework/core-interfaces\";\nimport type { ILoggingError } from \"@fluidframework/core-interfaces/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { type IFluidErrorBase, hasErrorInstanceId, isFluidError } from \"./fluidErrorBase.js\";\nimport { convertToBasePropertyType } from \"./logger.js\";\nimport type {\n\tITelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes.js\";\n\n/**\n * Determines if the provided value is an object but neither null nor an array.\n */\nconst isRegularObject = (value: unknown): boolean => {\n\treturn value !== null && !Array.isArray(value) && typeof value === \"object\";\n};\n\n/**\n * Inspect the given error for common \"safe\" props and return them.\n *\n * @internal\n */\nexport function extractLogSafeErrorProperties(\n\terror: unknown,\n\tsanitizeStack: boolean,\n): {\n\tmessage: string;\n\terrorType?: string | undefined;\n\tstack?: string | undefined;\n} {\n\tconst removeMessageFromStack = (stack: string, errorName?: string): string => {\n\t\tif (!sanitizeStack) {\n\t\t\treturn stack;\n\t\t}\n\t\tconst stackFrames = stack.split(\"\\n\");\n\t\tstackFrames.shift(); // Remove \"[ErrorName]: [ErrorMessage]\"\n\t\tif (errorName !== undefined) {\n\t\t\tstackFrames.unshift(errorName); // Add \"[ErrorName]\"\n\t\t}\n\t\treturn stackFrames.join(\"\\n\");\n\t};\n\n\tconst message =\n\t\ttypeof (error as Partial<Error>)?.message === \"string\"\n\t\t\t? (error as Error).message\n\t\t\t: String(error);\n\n\tconst safeProps: { message: string; errorType?: string; stack?: string } = {\n\t\tmessage,\n\t};\n\n\tif (isRegularObject(error)) {\n\t\tconst { errorType, stack, name } = error as Partial<IFluidErrorBase>;\n\n\t\tif (typeof errorType === \"string\") {\n\t\t\tsafeProps.errorType = errorType;\n\t\t}\n\n\t\tif (typeof stack === \"string\") {\n\t\t\tconst errorName = typeof name === \"string\" ? name : undefined;\n\t\t\tsafeProps.stack = removeMessageFromStack(stack, errorName);\n\t\t}\n\t}\n\n\treturn safeProps;\n}\n\n/**\n * Type-guard for {@link @fluidframework/core-interfaces#ILoggingError}.\n *\n * @internal\n */\nexport const isILoggingError = (x: unknown): x is ILoggingError =>\n\ttypeof (x as Partial<ILoggingError>)?.getTelemetryProperties === \"function\";\n\n/**\n * Copy props from source onto target, but do not overwrite an existing prop that matches\n */\nfunction copyProps(\n\ttarget: ITelemetryPropertiesExt | LoggingError,\n\tsource: ITelemetryPropertiesExt,\n): void {\n\tfor (const [key, value] of Object.entries(source)) {\n\t\tif (target[key] === undefined) {\n\t\t\ttarget[key] = value;\n\t\t}\n\t}\n}\n\n/**\n * Metadata to annotate an error object when annotating or normalizing it\n *\n * @internal\n */\nexport interface IFluidErrorAnnotations {\n\t/**\n\t * Telemetry props to log with the error\n\t */\n\tprops?: ITelemetryBaseProperties;\n}\n\n/**\n * Normalize the given error yielding a valid Fluid Error\n * @returns A valid Fluid Error with any provided annotations applied\n * @param error - The error to normalize\n * @param annotations - Annotations to apply to the normalized error\n *\n * @internal\n */\nexport function normalizeError(\n\terror: unknown,\n\tannotations: IFluidErrorAnnotations = {},\n): IFluidErrorBase {\n\tif (isFluidError(error)) {\n\t\t// We can simply add the telemetry props to the error and return it\n\t\terror.addTelemetryProperties(annotations.props ?? {});\n\t\treturn error;\n\t}\n\n\t// We have to construct a new Fluid Error, copying safe properties over\n\tconst { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);\n\tconst fluidError: IFluidErrorBase = new NormalizedLoggingError({\n\t\tmessage,\n\t\tstack,\n\t});\n\n\t// We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)\n\t// Anywhere they are set should be on a valid Fluid Error that would have been returned above,\n\t// but we can't prove it with the types, so adding this defensive measure.\n\tif (typeof error === \"object\" && error !== null) {\n\t\tconst maybeHasRetry: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> = error;\n\t\tlet retryProps: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> | undefined;\n\t\tif (\"canRetry\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.canRetry = maybeHasRetry.canRetry;\n\t\t}\n\t\tif (\"retryAfterSeconds\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.retryAfterSeconds = maybeHasRetry.retryAfterSeconds;\n\t\t}\n\t\tif (retryProps !== undefined) {\n\t\t\tObject.assign(fluidError, retryProps);\n\t\t}\n\t}\n\n\tif (typeof error !== \"object\") {\n\t\t// This is only interesting for non-objects\n\t\tfluidError.addTelemetryProperties({ typeofError: typeof error });\n\t}\n\n\tconst errorTelemetryProps = LoggingError.typeCheck(error)\n\t\t? error.getTelemetryProperties()\n\t\t: {\n\t\t\t\tuntrustedOrigin: 1, // This will let us filter errors that did not originate from our own codebase\n\t\t\t\t// FUTURE: Once 2.0 becomes LTS, switch to this more explicit property name\n\t\t\t\t// Consider using a string to distinguish cases like \"dependency\" v. \"callback\"\n\t\t\t\t// errorRunningExternalCode: 1,\n\t\t\t};\n\n\tfluidError.addTelemetryProperties({\n\t\t...errorTelemetryProps,\n\t\t...annotations.props,\n\t});\n\n\treturn fluidError;\n}\n\nlet stackPopulatedOnCreation: boolean | undefined;\n\n/**\n * The purpose of this function is to provide ability to capture stack context quickly.\n * Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.\n * There are scenarios where we generate error with stack, but error is handled in most cases and\n * stack property is not accessed.\n * For such cases it's better to not read stack property right away, but rather delay it until / if it's needed\n * Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.\n * @param stackTraceLimit - stack trace limit for an error\n * @returns Error object that has stack populated.\n *\n * @internal\n */\nexport function generateErrorWithStack(stackTraceLimit?: number): Error {\n\tconst ErrorConfig = Error as unknown as { stackTraceLimit: number };\n\tconst originalStackTraceLimit = ErrorConfig.stackTraceLimit;\n\tif (stackTraceLimit !== undefined) {\n\t\tErrorConfig.stackTraceLimit = stackTraceLimit;\n\t}\n\tconst err = new Error(\"<<generated stack>>\");\n\n\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\tif (stackPopulatedOnCreation === undefined) {\n\t\tstackPopulatedOnCreation = err.stack !== undefined;\n\t}\n\n\tif (stackPopulatedOnCreation) {\n\t\tErrorConfig.stackTraceLimit = originalStackTraceLimit;\n\t\treturn err;\n\t}\n\n\ttry {\n\t\tthrow err;\n\t} catch (error) {\n\t\tErrorConfig.stackTraceLimit = originalStackTraceLimit;\n\t\treturn error as Error;\n\t}\n}\n\n/**\n * Generate a stack at this callsite as if an error were thrown from here.\n * @param stackTraceLimit - stack trace limit for an error\n * @returns the callstack (does not throw)\n *\n * @internal\n */\nexport function generateStack(stackTraceLimit?: number): string | undefined {\n\treturn generateErrorWithStack(stackTraceLimit).stack;\n}\n\n/**\n * Create a new error using newErrorFn, wrapping and caused by the given unknown error.\n * Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present\n * @param innerError - An error from untrusted/unknown origins\n * @param newErrorFn - callback that will create a new error given the original error's message\n * @returns A new error object \"wrapping\" the given error\n *\n * @internal\n */\nexport function wrapError<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n): T {\n\tconst { message, stack } = extractLogSafeErrorProperties(\n\t\tinnerError,\n\t\tfalse /* sanitizeStack */,\n\t);\n\n\tconst newError = newErrorFn(message);\n\n\tnewError.cause = innerError;\n\n\tif (stack !== undefined) {\n\t\toverwriteStack(newError, stack);\n\t}\n\n\t// Mark external errors with untrustedOrigin flag\n\tif (isExternalError(innerError)) {\n\t\tnewError.addTelemetryProperties({\n\t\t\tuntrustedOrigin: 1,\n\t\t\t// FUTURE: Once 2.0 becomes LTS, switch to this more explicit property name\n\t\t\t// Consider using a string to distinguish cases like \"dependency\" v. \"callback\"\n\t\t\t// errorRunningExternalCode: 1,\n\t\t});\n\t}\n\n\t// Reuse errorInstanceId\n\tif (hasErrorInstanceId(innerError)) {\n\t\tnewError.overwriteErrorInstanceId(innerError.errorInstanceId);\n\n\t\t// For \"back-compat\" in the logs\n\t\tnewError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\n\t}\n\n\t// Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties\n\t// This will include the untrustedOrigin/errorRunningExternalCode info if the inner error itself was created from an external error\n\tif (isILoggingError(innerError)) {\n\t\tnewError.addTelemetryProperties(innerError.getTelemetryProperties());\n\t}\n\n\treturn newError;\n}\n\n/**\n * The same as wrapError, but also logs the innerError, including the wrapping error's instance ID.\n *\n * @typeParam T - The kind of wrapper error to create.\n *\n * @internal\n */\nexport function wrapErrorAndLog<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n\tlogger: ITelemetryLoggerExt,\n): T {\n\tconst newError = wrapError(innerError, newErrorFn);\n\n\t// This will match innerError.errorInstanceId if present (see wrapError)\n\tconst errorInstanceId = newError.errorInstanceId;\n\n\t// For \"back-compat\" in the logs\n\tconst wrappedByErrorInstanceId = errorInstanceId;\n\n\tlogger.sendTelemetryEvent(\n\t\t{\n\t\t\teventName: \"WrapError\",\n\t\t\terrorInstanceId,\n\t\t\twrappedByErrorInstanceId,\n\t\t},\n\t\tinnerError,\n\t);\n\n\treturn newError;\n}\n\n/**\n * Attempts to overwrite the error's stack\n *\n * There have been reports of certain JS environments where overwriting stack will throw.\n * If that happens, this adds the given stack as the telemetry property \"stack2\"\n *\n * @internal\n */\nexport function overwriteStack(error: IFluidErrorBase | LoggingError, stack: string): void {\n\ttry {\n\t\tObject.assign(error, { stack });\n\t} catch {\n\t\terror.addTelemetryProperties({ stack2: stack });\n\t}\n}\n\n/**\n * True for any error object that is an (optionally normalized) external error\n * False for any error we created and raised within the FF codebase via LoggingError base class,\n * or wrapped in a well-known error type\n *\n * @internal\n */\nexport function isExternalError(error: unknown): boolean {\n\t// LoggingErrors are an internal FF error type. However, an external error can be converted\n\t// into a LoggingError if it is normalized. In this case we must use the untrustedOrigin/errorRunningExternalCode flag to\n\t// determine whether the original error was in fact external.\n\tif (LoggingError.typeCheck(error)) {\n\t\tif ((error as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {\n\t\t\tconst props = error.getTelemetryProperties();\n\t\t\t// NOTE: errorRunningExternalCode is not currently used - once this \"read\" code reaches LTS,\n\t\t\t// we can switch to writing this more explicit property\n\t\t\treturn props.untrustedOrigin === 1 || Boolean(props.errorRunningExternalCode);\n\t\t}\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Type guard to identify if a particular telemetry property appears to be a\n * {@link @fluidframework/core-interfaces#Tagged} telemetry property.\n *\n * @internal\n */\nexport function isTaggedTelemetryPropertyValue(\n\tx: Tagged<TelemetryEventPropertyTypeExt> | TelemetryEventPropertyTypeExt,\n): x is Tagged<TelemetryEventPropertyTypeExt> {\n\treturn typeof (x as Partial<Tagged<unknown>>)?.tag === \"string\";\n}\n\n// TODO: Use `unknown` instead (API breaking change)\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Borrowed from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}\n * Avoids runtime errors with circular references.\n * Not ideal, as will cut values that are not necessarily circular references.\n * Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)\n *\n * @internal\n */\nexport const getCircularReplacer = (): ((key: string, value: unknown) => any) => {\n\tconst seen = new WeakSet();\n\treturn (key: string, value: unknown): any => {\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\tif (seen.has(value)) {\n\t\t\t\treturn \"<removed/circular>\";\n\t\t\t}\n\t\t\tseen.add(value);\n\t\t}\n\t\treturn value;\n\t};\n};\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n/**\n * Base class for \"trusted\" errors we create, whose properties can generally be logged to telemetry safely.\n * All properties set on the object, or passed in (via the constructor or addTelemetryProperties),\n * will be logged in accordance with their tag, if present.\n *\n * PLEASE take care to avoid setting sensitive data on this object without proper tagging!\n *\n * @internal\n */\nexport class LoggingError\n\textends Error\n\timplements ILoggingError, Omit<IFluidErrorBase, \"errorType\">\n{\n\tpublic cause?: unknown;\n\n\tprivate _errorInstanceId = uuid();\n\tpublic get errorInstanceId(): string {\n\t\treturn this._errorInstanceId;\n\t}\n\tpublic overwriteErrorInstanceId(id: string): void {\n\t\tthis._errorInstanceId = id;\n\t}\n\n\t/**\n\t * Create a new LoggingError\n\t * @param message - Error message to use for Error base class\n\t * @param props - telemetry props to include on the error for when it's logged\n\t * @param omitPropsFromLogging - properties by name to omit from telemetry props\n\t */\n\tpublic constructor(\n\t\tmessage: string,\n\t\tprops?: ITelemetryBaseProperties,\n\t\tprivate readonly omitPropsFromLogging: Set<string> = new Set(),\n\t) {\n\t\tsuper(message);\n\n\t\t// Don't log this list itself, or the private _errorInstanceId\n\t\tomitPropsFromLogging.add(\"omitPropsFromLogging\");\n\t\tomitPropsFromLogging.add(\"_errorInstanceId\");\n\t\t// Nor log the unknown cause property, which could be anything.\n\t\t// Core elements of \"cause\" are already promoted by wrapError.\n\t\tomitPropsFromLogging.add(\"cause\");\n\n\t\tif (props) {\n\t\t\tthis.addTelemetryProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * Determines if a given object is an instance of a LoggingError\n\t * @param object - any object\n\t * @returns true if the object is an instance of a LoggingError, false if not.\n\t */\n\tpublic static typeCheck(object: unknown): object is LoggingError {\n\t\tif (typeof object === \"object\" && object !== null) {\n\t\t\treturn (\n\t\t\t\ttypeof (object as LoggingError).addTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).getTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).errorInstanceId === \"string\"\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Add additional properties to be logged\n\t */\n\tpublic addTelemetryProperties(props: ITelemetryPropertiesExt): void {\n\t\tcopyProps(this, props);\n\t}\n\n\t/**\n\t * Get all properties fit to be logged to telemetry for this error\n\t */\n\tpublic getTelemetryProperties(): ITelemetryBaseProperties {\n\t\t// Only pick properties fit for telemetry out of all of this object's enumerable properties.\n\t\tconst telemetryProps: ITelemetryBaseProperties = {};\n\t\tfor (const key of Object.keys(this)) {\n\t\t\tif (this.omitPropsFromLogging.has(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst val = this[key] as\n\t\t\t\t| TelemetryEventPropertyTypeExt\n\t\t\t\t| Tagged<TelemetryEventPropertyTypeExt>;\n\n\t\t\t// Ensure only valid props get logged, since props of logging error could be in any shape\n\t\t\ttelemetryProps[key] = convertToBasePropertyType(val);\n\t\t}\n\t\t// Ensure a few extra props always exist\n\t\treturn {\n\t\t\t...telemetryProps,\n\t\t\tstack: this.stack,\n\t\t\tmessage: this.message,\n\t\t\terrorInstanceId: this._errorInstanceId,\n\t\t};\n\t}\n}\n\n/**\n * The Error class used when normalizing an external error\n *\n * @internal\n */\nexport const NORMALIZED_ERROR_TYPE = \"genericError\";\n\n/**\n * Subclass of LoggingError returned by normalizeError\n *\n * @internal\n */\nclass NormalizedLoggingError extends LoggingError {\n\t// errorType \"genericError\" is used as a default value throughout the code.\n\t// Note that this matches ContainerErrorTypes/DriverErrorTypes' genericError\n\tpublic readonly errorType = NORMALIZED_ERROR_TYPE;\n\n\tpublic constructor(errorProps: Pick<IFluidErrorBase, \"message\" | \"stack\">) {\n\t\tsuper(errorProps.message);\n\n\t\tif (errorProps.stack !== undefined) {\n\t\t\toverwriteStack(this, errorProps.stack);\n\t\t}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C;QACpD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxC,SAAS;YACV,CAAC;YACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAEoB,CAAC;YAEzC,yFAAyF;YACzF,cAAc,CAAC,GAAG,CAAC,GAAG,IAAA,qCAAyB,EAAC,GAAG,CAAC,CAAC;QACtD,CAAC;QACD,wCAAwC;QACxC,OAAO;YACN,GAAG,cAAc;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,eAAe,EAAE,IAAI,CAAC,gBAAgB;SACtC,CAAC;IACH,CAAC;CACD;AAvFD,oCAuFC;AAED;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD;;;;GAIG;AACH,MAAM,sBAAuB,SAAQ,YAAY;IAKhD,YAAmB,UAAsD;QACxE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAL3B,2EAA2E;QAC3E,4EAA4E;QAC5D,cAAS,GAAG,6BAAqB,CAAC;QAKjD,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACpC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties, Tagged } from \"@fluidframework/core-interfaces\";\nimport type { ILoggingError } from \"@fluidframework/core-interfaces/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { type IFluidErrorBase, hasErrorInstanceId, isFluidError } from \"./fluidErrorBase.js\";\nimport { convertToBasePropertyType } from \"./logger.js\";\nimport type {\n\tTelemetryLoggerExt,\n\tITelemetryPropertiesExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes.js\";\n\n/**\n * Determines if the provided value is an object but neither null nor an array.\n */\nconst isRegularObject = (value: unknown): boolean => {\n\treturn value !== null && !Array.isArray(value) && typeof value === \"object\";\n};\n\n/**\n * Inspect the given error for common \"safe\" props and return them.\n *\n * @internal\n */\nexport function extractLogSafeErrorProperties(\n\terror: unknown,\n\tsanitizeStack: boolean,\n): {\n\tmessage: string;\n\terrorType?: string | undefined;\n\tstack?: string | undefined;\n} {\n\tconst removeMessageFromStack = (stack: string, errorName?: string): string => {\n\t\tif (!sanitizeStack) {\n\t\t\treturn stack;\n\t\t}\n\t\tconst stackFrames = stack.split(\"\\n\");\n\t\tstackFrames.shift(); // Remove \"[ErrorName]: [ErrorMessage]\"\n\t\tif (errorName !== undefined) {\n\t\t\tstackFrames.unshift(errorName); // Add \"[ErrorName]\"\n\t\t}\n\t\treturn stackFrames.join(\"\\n\");\n\t};\n\n\tconst message =\n\t\ttypeof (error as Partial<Error>)?.message === \"string\"\n\t\t\t? (error as Error).message\n\t\t\t: String(error);\n\n\tconst safeProps: { message: string; errorType?: string; stack?: string } = {\n\t\tmessage,\n\t};\n\n\tif (isRegularObject(error)) {\n\t\tconst { errorType, stack, name } = error as Partial<IFluidErrorBase>;\n\n\t\tif (typeof errorType === \"string\") {\n\t\t\tsafeProps.errorType = errorType;\n\t\t}\n\n\t\tif (typeof stack === \"string\") {\n\t\t\tconst errorName = typeof name === \"string\" ? name : undefined;\n\t\t\tsafeProps.stack = removeMessageFromStack(stack, errorName);\n\t\t}\n\t}\n\n\treturn safeProps;\n}\n\n/**\n * Type-guard for {@link @fluidframework/core-interfaces#ILoggingError}.\n *\n * @internal\n */\nexport const isILoggingError = (x: unknown): x is ILoggingError =>\n\ttypeof (x as Partial<ILoggingError>)?.getTelemetryProperties === \"function\";\n\n/**\n * Copy props from source onto target, but do not overwrite an existing prop that matches\n */\nfunction copyProps(\n\ttarget: ITelemetryPropertiesExt | LoggingError,\n\tsource: ITelemetryPropertiesExt,\n): void {\n\tfor (const [key, value] of Object.entries(source)) {\n\t\tif (target[key] === undefined) {\n\t\t\ttarget[key] = value;\n\t\t}\n\t}\n}\n\n/**\n * Metadata to annotate an error object when annotating or normalizing it\n *\n * @internal\n */\nexport interface IFluidErrorAnnotations {\n\t/**\n\t * Telemetry props to log with the error\n\t */\n\tprops?: ITelemetryBaseProperties;\n}\n\n/**\n * Normalize the given error yielding a valid Fluid Error\n * @returns A valid Fluid Error with any provided annotations applied\n * @param error - The error to normalize\n * @param annotations - Annotations to apply to the normalized error\n *\n * @internal\n */\nexport function normalizeError(\n\terror: unknown,\n\tannotations: IFluidErrorAnnotations = {},\n): IFluidErrorBase {\n\tif (isFluidError(error)) {\n\t\t// We can simply add the telemetry props to the error and return it\n\t\terror.addTelemetryProperties(annotations.props ?? {});\n\t\treturn error;\n\t}\n\n\t// We have to construct a new Fluid Error, copying safe properties over\n\tconst { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);\n\tconst fluidError: IFluidErrorBase = new NormalizedLoggingError({\n\t\tmessage,\n\t\tstack,\n\t});\n\n\t// We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)\n\t// Anywhere they are set should be on a valid Fluid Error that would have been returned above,\n\t// but we can't prove it with the types, so adding this defensive measure.\n\tif (typeof error === \"object\" && error !== null) {\n\t\tconst maybeHasRetry: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> = error;\n\t\tlet retryProps: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> | undefined;\n\t\tif (\"canRetry\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.canRetry = maybeHasRetry.canRetry;\n\t\t}\n\t\tif (\"retryAfterSeconds\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.retryAfterSeconds = maybeHasRetry.retryAfterSeconds;\n\t\t}\n\t\tif (retryProps !== undefined) {\n\t\t\tObject.assign(fluidError, retryProps);\n\t\t}\n\t}\n\n\tif (typeof error !== \"object\") {\n\t\t// This is only interesting for non-objects\n\t\tfluidError.addTelemetryProperties({ typeofError: typeof error });\n\t}\n\n\tconst errorTelemetryProps = LoggingError.typeCheck(error)\n\t\t? error.getTelemetryProperties()\n\t\t: {\n\t\t\t\tuntrustedOrigin: 1, // This will let us filter errors that did not originate from our own codebase\n\t\t\t\t// FUTURE: Once 2.0 becomes LTS, switch to this more explicit property name\n\t\t\t\t// Consider using a string to distinguish cases like \"dependency\" v. \"callback\"\n\t\t\t\t// errorRunningExternalCode: 1,\n\t\t\t};\n\n\tfluidError.addTelemetryProperties({\n\t\t...errorTelemetryProps,\n\t\t...annotations.props,\n\t});\n\n\treturn fluidError;\n}\n\nlet stackPopulatedOnCreation: boolean | undefined;\n\n/**\n * The purpose of this function is to provide ability to capture stack context quickly.\n * Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.\n * There are scenarios where we generate error with stack, but error is handled in most cases and\n * stack property is not accessed.\n * For such cases it's better to not read stack property right away, but rather delay it until / if it's needed\n * Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.\n * @param stackTraceLimit - stack trace limit for an error\n * @returns Error object that has stack populated.\n *\n * @internal\n */\nexport function generateErrorWithStack(stackTraceLimit?: number): Error {\n\tconst ErrorConfig = Error as unknown as { stackTraceLimit: number };\n\tconst originalStackTraceLimit = ErrorConfig.stackTraceLimit;\n\tif (stackTraceLimit !== undefined) {\n\t\tErrorConfig.stackTraceLimit = stackTraceLimit;\n\t}\n\tconst err = new Error(\"<<generated stack>>\");\n\n\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\tif (stackPopulatedOnCreation === undefined) {\n\t\tstackPopulatedOnCreation = err.stack !== undefined;\n\t}\n\n\tif (stackPopulatedOnCreation) {\n\t\tErrorConfig.stackTraceLimit = originalStackTraceLimit;\n\t\treturn err;\n\t}\n\n\ttry {\n\t\tthrow err;\n\t} catch (error) {\n\t\tErrorConfig.stackTraceLimit = originalStackTraceLimit;\n\t\treturn error as Error;\n\t}\n}\n\n/**\n * Generate a stack at this callsite as if an error were thrown from here.\n * @param stackTraceLimit - stack trace limit for an error\n * @returns the callstack (does not throw)\n *\n * @internal\n */\nexport function generateStack(stackTraceLimit?: number): string | undefined {\n\treturn generateErrorWithStack(stackTraceLimit).stack;\n}\n\n/**\n * Create a new error using newErrorFn, wrapping and caused by the given unknown error.\n * Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present\n * @param innerError - An error from untrusted/unknown origins\n * @param newErrorFn - callback that will create a new error given the original error's message\n * @returns A new error object \"wrapping\" the given error\n *\n * @internal\n */\nexport function wrapError<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n): T {\n\tconst { message, stack } = extractLogSafeErrorProperties(\n\t\tinnerError,\n\t\tfalse /* sanitizeStack */,\n\t);\n\n\tconst newError = newErrorFn(message);\n\n\tnewError.cause = innerError;\n\n\tif (stack !== undefined) {\n\t\toverwriteStack(newError, stack);\n\t}\n\n\t// Mark external errors with untrustedOrigin flag\n\tif (isExternalError(innerError)) {\n\t\tnewError.addTelemetryProperties({\n\t\t\tuntrustedOrigin: 1,\n\t\t\t// FUTURE: Once 2.0 becomes LTS, switch to this more explicit property name\n\t\t\t// Consider using a string to distinguish cases like \"dependency\" v. \"callback\"\n\t\t\t// errorRunningExternalCode: 1,\n\t\t});\n\t}\n\n\t// Reuse errorInstanceId\n\tif (hasErrorInstanceId(innerError)) {\n\t\tnewError.overwriteErrorInstanceId(innerError.errorInstanceId);\n\n\t\t// For \"back-compat\" in the logs\n\t\tnewError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\n\t}\n\n\t// Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties\n\t// This will include the untrustedOrigin/errorRunningExternalCode info if the inner error itself was created from an external error\n\tif (isILoggingError(innerError)) {\n\t\tnewError.addTelemetryProperties(innerError.getTelemetryProperties());\n\t}\n\n\treturn newError;\n}\n\n/**\n * The same as wrapError, but also logs the innerError, including the wrapping error's instance ID.\n *\n * @typeParam T - The kind of wrapper error to create.\n *\n * @internal\n */\nexport function wrapErrorAndLog<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n\tlogger: TelemetryLoggerExt,\n): T {\n\tconst newError = wrapError(innerError, newErrorFn);\n\n\t// This will match innerError.errorInstanceId if present (see wrapError)\n\tconst errorInstanceId = newError.errorInstanceId;\n\n\t// For \"back-compat\" in the logs\n\tconst wrappedByErrorInstanceId = errorInstanceId;\n\n\tlogger.sendTelemetryEvent(\n\t\t{\n\t\t\teventName: \"WrapError\",\n\t\t\terrorInstanceId,\n\t\t\twrappedByErrorInstanceId,\n\t\t},\n\t\tinnerError,\n\t);\n\n\treturn newError;\n}\n\n/**\n * Attempts to overwrite the error's stack\n *\n * There have been reports of certain JS environments where overwriting stack will throw.\n * If that happens, this adds the given stack as the telemetry property \"stack2\"\n *\n * @internal\n */\nexport function overwriteStack(error: IFluidErrorBase | LoggingError, stack: string): void {\n\ttry {\n\t\tObject.assign(error, { stack });\n\t} catch {\n\t\terror.addTelemetryProperties({ stack2: stack });\n\t}\n}\n\n/**\n * True for any error object that is an (optionally normalized) external error\n * False for any error we created and raised within the FF codebase via LoggingError base class,\n * or wrapped in a well-known error type\n *\n * @internal\n */\nexport function isExternalError(error: unknown): boolean {\n\t// LoggingErrors are an internal FF error type. However, an external error can be converted\n\t// into a LoggingError if it is normalized. In this case we must use the untrustedOrigin/errorRunningExternalCode flag to\n\t// determine whether the original error was in fact external.\n\tif (LoggingError.typeCheck(error)) {\n\t\tif ((error as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {\n\t\t\tconst props = error.getTelemetryProperties();\n\t\t\t// NOTE: errorRunningExternalCode is not currently used - once this \"read\" code reaches LTS,\n\t\t\t// we can switch to writing this more explicit property\n\t\t\treturn props.untrustedOrigin === 1 || Boolean(props.errorRunningExternalCode);\n\t\t}\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Type guard to identify if a particular telemetry property appears to be a\n * {@link @fluidframework/core-interfaces#Tagged} telemetry property.\n *\n * @internal\n */\nexport function isTaggedTelemetryPropertyValue(\n\tx: Tagged<TelemetryEventPropertyTypeExt> | TelemetryEventPropertyTypeExt,\n): x is Tagged<TelemetryEventPropertyTypeExt> {\n\treturn typeof (x as Partial<Tagged<unknown>>)?.tag === \"string\";\n}\n\n// TODO: Use `unknown` instead (API breaking change)\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Borrowed from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}\n * Avoids runtime errors with circular references.\n * Not ideal, as will cut values that are not necessarily circular references.\n * Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)\n *\n * @internal\n */\nexport const getCircularReplacer = (): ((key: string, value: unknown) => any) => {\n\tconst seen = new WeakSet();\n\treturn (key: string, value: unknown): any => {\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\tif (seen.has(value)) {\n\t\t\t\treturn \"<removed/circular>\";\n\t\t\t}\n\t\t\tseen.add(value);\n\t\t}\n\t\treturn value;\n\t};\n};\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n/**\n * Base class for \"trusted\" errors we create, whose properties can generally be logged to telemetry safely.\n * All properties set on the object, or passed in (via the constructor or addTelemetryProperties),\n * will be logged in accordance with their tag, if present.\n *\n * PLEASE take care to avoid setting sensitive data on this object without proper tagging!\n *\n * @internal\n */\nexport class LoggingError\n\textends Error\n\timplements ILoggingError, Omit<IFluidErrorBase, \"errorType\">\n{\n\tpublic cause?: unknown;\n\n\tprivate _errorInstanceId = uuid();\n\tpublic get errorInstanceId(): string {\n\t\treturn this._errorInstanceId;\n\t}\n\tpublic overwriteErrorInstanceId(id: string): void {\n\t\tthis._errorInstanceId = id;\n\t}\n\n\t/**\n\t * Create a new LoggingError\n\t * @param message - Error message to use for Error base class\n\t * @param props - telemetry props to include on the error for when it's logged\n\t * @param omitPropsFromLogging - properties by name to omit from telemetry props\n\t */\n\tpublic constructor(\n\t\tmessage: string,\n\t\tprops?: ITelemetryBaseProperties,\n\t\tprivate readonly omitPropsFromLogging: Set<string> = new Set(),\n\t) {\n\t\tsuper(message);\n\n\t\t// Don't log this list itself, or the private _errorInstanceId\n\t\tomitPropsFromLogging.add(\"omitPropsFromLogging\");\n\t\tomitPropsFromLogging.add(\"_errorInstanceId\");\n\t\t// Nor log the unknown cause property, which could be anything.\n\t\t// Core elements of \"cause\" are already promoted by wrapError.\n\t\tomitPropsFromLogging.add(\"cause\");\n\n\t\tif (props) {\n\t\t\tthis.addTelemetryProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * Determines if a given object is an instance of a LoggingError\n\t * @param object - any object\n\t * @returns true if the object is an instance of a LoggingError, false if not.\n\t */\n\tpublic static typeCheck(object: unknown): object is LoggingError {\n\t\tif (typeof object === \"object\" && object !== null) {\n\t\t\treturn (\n\t\t\t\ttypeof (object as LoggingError).addTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).getTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).errorInstanceId === \"string\"\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Add additional properties to be logged\n\t */\n\tpublic addTelemetryProperties(props: ITelemetryPropertiesExt): void {\n\t\tcopyProps(this, props);\n\t}\n\n\t/**\n\t * Get all properties fit to be logged to telemetry for this error\n\t */\n\tpublic getTelemetryProperties(): ITelemetryBaseProperties {\n\t\t// Only pick properties fit for telemetry out of all of this object's enumerable properties.\n\t\tconst telemetryProps: ITelemetryBaseProperties = {};\n\t\tfor (const key of Object.keys(this)) {\n\t\t\tif (this.omitPropsFromLogging.has(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst val = this[key] as\n\t\t\t\t| TelemetryEventPropertyTypeExt\n\t\t\t\t| Tagged<TelemetryEventPropertyTypeExt>;\n\n\t\t\t// Ensure only valid props get logged, since props of logging error could be in any shape\n\t\t\ttelemetryProps[key] = convertToBasePropertyType(val);\n\t\t}\n\t\t// Ensure a few extra props always exist\n\t\treturn {\n\t\t\t...telemetryProps,\n\t\t\tstack: this.stack,\n\t\t\tmessage: this.message,\n\t\t\terrorInstanceId: this._errorInstanceId,\n\t\t};\n\t}\n}\n\n/**\n * The Error class used when normalizing an external error\n *\n * @internal\n */\nexport const NORMALIZED_ERROR_TYPE = \"genericError\";\n\n/**\n * Subclass of LoggingError returned by normalizeError\n *\n * @internal\n */\nclass NormalizedLoggingError extends LoggingError {\n\t// errorType \"genericError\" is used as a default value throughout the code.\n\t// Note that this matches ContainerErrorTypes/DriverErrorTypes' genericError\n\tpublic readonly errorType = NORMALIZED_ERROR_TYPE;\n\n\tpublic constructor(errorProps: Pick<IFluidErrorBase, \"message\" | \"stack\">) {\n\t\tsuper(errorProps.message);\n\n\t\tif (errorProps.stack !== undefined) {\n\t\t\toverwriteStack(this, errorProps.stack);\n\t\t}\n\t}\n}\n"]}
|
package/dist/events.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { EventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
-
import type {
|
|
6
|
+
import type { TelemetryLoggerExt } from "./telemetryTypes.js";
|
|
7
7
|
/**
|
|
8
8
|
* Note: The contents of this file really don't belong in this package, as they are only intended for internal use.
|
|
9
9
|
* They should be moved into the `core-utils` package in the future.
|
|
@@ -19,7 +19,7 @@ export declare const disconnectedEventName = "disconnected";
|
|
|
19
19
|
/**
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
export declare function safeRaiseEvent(emitter: EventEmitter, logger:
|
|
22
|
+
export declare function safeRaiseEvent(emitter: EventEmitter, logger: TelemetryLoggerExt, event: string, ...args: unknown[]): void;
|
|
23
23
|
/**
|
|
24
24
|
* Raises events pertaining to the connection
|
|
25
25
|
* @param logger - The logger to log telemetry
|
|
@@ -30,5 +30,5 @@ export declare function safeRaiseEvent(emitter: EventEmitter, logger: ITelemetry
|
|
|
30
30
|
*
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
|
-
export declare function raiseConnectedEvent(logger:
|
|
33
|
+
export declare function raiseConnectedEvent(logger: TelemetryLoggerExt, emitter: EventEmitter, connected: boolean, clientId?: string, disconnectedReason?: string): void;
|
|
34
34
|
//# sourceMappingURL=events.d.ts.map
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAGpD;;GAEG;AACH,wBAAgB,cAAc,CAC7B,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,MAAM,EACb,GAAG,IAAI,EAAE,OAAO,EAAE,GAChB,IAAI,CAMN;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,MAAM,GACzB,IAAI,CAUN"}
|
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;GAGG;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,WAAW,CAAC;AAE9C;;GAEG;AACU,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD,qDAAqD;AACrD;;GAEG;AACH,SAAgB,cAAc,CAC7B,OAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;GAGG;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,WAAW,CAAC;AAE9C;;GAEG;AACU,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD,qDAAqD;AACrD;;GAEG;AACH,SAAgB,cAAc,CAC7B,OAAqB,EACrB,MAA0B,EAC1B,KAAa,EACb,GAAG,IAAe;IAElB,IAAI,CAAC;QACJ,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;AACF,CAAC;AAXD,wCAWC;AAED;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CAClC,MAA0B,EAC1B,OAAqB,EACrB,SAAkB,EAClB,QAAiB,EACjB,kBAA2B;IAE3B,IAAI,CAAC;QACJ,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,0BAAkB,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,OAAO,CAAC,IAAI,CAAC,6BAAqB,EAAE,kBAAkB,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;AACF,CAAC;AAhBD,kDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitter } from \"@fluid-internal/client-utils\";\n\nimport type { TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Note: The contents of this file really don't belong in this package, as they are only intended for internal use.\n * They should be moved into the `core-utils` package in the future.\n */\n\n/**\n * @internal\n */\nexport const connectedEventName = \"connected\";\n\n/**\n * @internal\n */\nexport const disconnectedEventName = \"disconnected\";\n\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function safeRaiseEvent(\n\temitter: EventEmitter,\n\tlogger: TelemetryLoggerExt,\n\tevent: string,\n\t...args: unknown[]\n): void {\n\ttry {\n\t\temitter.emit(event, ...args);\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseEventError\", event }, error);\n\t}\n}\n\n/**\n * Raises events pertaining to the connection\n * @param logger - The logger to log telemetry\n * @param emitter - The event emitter instance\n * @param connected - A boolean tracking whether the connection was in a connected state or not\n * @param clientId - The connected/disconnected clientId\n * @param disconnectedReason - The reason for the connection to be disconnected (Used for telemetry purposes only)\n *\n * @internal\n */\nexport function raiseConnectedEvent(\n\tlogger: TelemetryLoggerExt,\n\temitter: EventEmitter,\n\tconnected: boolean,\n\tclientId?: string,\n\tdisconnectedReason?: string,\n): void {\n\ttry {\n\t\tif (connected) {\n\t\t\temitter.emit(connectedEventName, clientId);\n\t\t} else {\n\t\t\temitter.emit(disconnectedEventName, disconnectedReason);\n\t\t}\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseConnectedEventError\" }, error);\n\t}\n}\n"]}
|