@fluidframework/telemetry-utils 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.204906
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 +77 -0
- package/api-extractor.json +9 -1
- package/api-report/telemetry-utils.api.md +444 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/error.d.ts +8 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +10 -1
- package/dist/error.js.map +1 -1
- package/dist/errorLogging.d.ts +26 -0
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js +43 -15
- package/dist/errorLogging.js.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +50 -6
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +108 -46
- package/dist/logger.js.map +1 -1
- package/dist/telemetry-utils-alpha.d.ts +668 -0
- package/dist/telemetry-utils-beta.d.ts +668 -0
- package/dist/telemetry-utils-public.d.ts +668 -0
- package/dist/telemetry-utils-untrimmed.d.ts +909 -0
- package/dist/telemetryTypes.d.ts +2 -2
- package/dist/telemetryTypes.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils.d.ts +45 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +50 -1
- package/dist/utils.js.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +4 -2
- package/lib/config.js.map +1 -1
- package/lib/error.d.ts +8 -0
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +10 -1
- package/lib/error.js.map +1 -1
- package/lib/errorLogging.d.ts +26 -0
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js +43 -15
- package/lib/errorLogging.js.map +1 -1
- package/lib/events.d.ts.map +1 -1
- package/lib/events.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/logger.d.ts +50 -6
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +107 -45
- package/lib/logger.js.map +1 -1
- package/lib/telemetryTypes.d.ts +2 -2
- package/lib/telemetryTypes.d.ts.map +1 -1
- package/lib/utils.d.ts +45 -0
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +48 -0
- package/lib/utils.js.map +1 -1
- package/package.json +18 -19
- package/src/config.ts +4 -2
- package/src/error.ts +15 -3
- package/src/errorLogging.ts +43 -10
- package/src/events.ts +2 -0
- package/src/index.ts +1 -1
- package/src/logger.ts +94 -22
- package/src/utils.ts +85 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,82 @@
|
|
|
1
1
|
# @fluidframework/telemetry-utils
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.7.1.0
|
|
4
|
+
|
|
5
|
+
Dependency updates only.
|
|
6
|
+
|
|
7
|
+
## 2.0.0-internal.7.0.0
|
|
8
|
+
|
|
9
|
+
### Major Changes
|
|
10
|
+
|
|
11
|
+
- Dependencies on @fluidframework/protocol-definitions package updated to 3.0.0 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
12
|
+
|
|
13
|
+
This included the following changes from the protocol-definitions release:
|
|
14
|
+
|
|
15
|
+
- Updating signal interfaces for some planned improvements. The intention is split the interface between signals
|
|
16
|
+
submitted by clients to the server and the resulting signals sent from the server to clients.
|
|
17
|
+
- A new optional type member is available on the ISignalMessage interface and a new ISentSignalMessage interface has
|
|
18
|
+
been added, which will be the typing for signals sent from the client to the server. Both extend a new
|
|
19
|
+
ISignalMessageBase interface that contains common members.
|
|
20
|
+
- The @fluidframework/common-definitions package dependency has been updated to version 1.0.0.
|
|
21
|
+
|
|
22
|
+
- Server upgrade: dependencies on Fluid server packages updated to 2.0.1 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
23
|
+
|
|
24
|
+
Dependencies on the following Fluid server package have been updated to version 2.0.1:
|
|
25
|
+
|
|
26
|
+
- @fluidframework/gitresources: 2.0.1
|
|
27
|
+
- @fluidframework/server-kafka-orderer: 2.0.1
|
|
28
|
+
- @fluidframework/server-lambdas: 2.0.1
|
|
29
|
+
- @fluidframework/server-lambdas-driver: 2.0.1
|
|
30
|
+
- @fluidframework/server-local-server: 2.0.1
|
|
31
|
+
- @fluidframework/server-memory-orderer: 2.0.1
|
|
32
|
+
- @fluidframework/protocol-base: 2.0.1
|
|
33
|
+
- @fluidframework/server-routerlicious: 2.0.1
|
|
34
|
+
- @fluidframework/server-routerlicious-base: 2.0.1
|
|
35
|
+
- @fluidframework/server-services: 2.0.1
|
|
36
|
+
- @fluidframework/server-services-client: 2.0.1
|
|
37
|
+
- @fluidframework/server-services-core: 2.0.1
|
|
38
|
+
- @fluidframework/server-services-ordering-kafkanode: 2.0.1
|
|
39
|
+
- @fluidframework/server-services-ordering-rdkafka: 2.0.1
|
|
40
|
+
- @fluidframework/server-services-ordering-zookeeper: 2.0.1
|
|
41
|
+
- @fluidframework/server-services-shared: 2.0.1
|
|
42
|
+
- @fluidframework/server-services-telemetry: 2.0.1
|
|
43
|
+
- @fluidframework/server-services-utils: 2.0.1
|
|
44
|
+
- @fluidframework/server-test-utils: 2.0.1
|
|
45
|
+
- tinylicious: 2.0.1
|
|
46
|
+
|
|
47
|
+
- Minimum TypeScript version now 5.1.6 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
48
|
+
|
|
49
|
+
The minimum supported TypeScript version for Fluid 2.0 clients is now 5.1.6.
|
|
50
|
+
|
|
51
|
+
- @fluidframework/container-utils package removed [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
52
|
+
|
|
53
|
+
All members of the **@fluidframework/container-utils** package have been deprecated and the package is now removed.
|
|
54
|
+
|
|
55
|
+
Migration by API member:
|
|
56
|
+
|
|
57
|
+
- `ClientSessionExpiredError` (deprecated in `2.0.0-internal.6.2.0`): No replacement API offered.
|
|
58
|
+
- `DataCorruptionError` (deprecated in `2.0.0-internal.6.2.0`): Import from [@fluidframework/telemetry-utils](https://www.npmjs.com/package/@fluidframework/telemetry-utils) instead.
|
|
59
|
+
- `DataProcessingError` (deprecated in `2.0.0-internal.6.2.0`): Import from [@fluidframework/telemetry-utils](https://www.npmjs.com/package/@fluidframework/telemetry-utils) instead.
|
|
60
|
+
- `DeltaManagerProxyBase` (deprecated in `2.0.0-internal.6.1.0`): No replacement API offered.
|
|
61
|
+
- `extractSafePropertiesFromMessage` (deprecated in `2.0.0-internal.6.2.0`): Import from [@fluidframework/telemetry-utils](https://www.npmjs.com/package/@fluidframework/telemetry-utils) instead.
|
|
62
|
+
- `GenericError` (deprecated in `2.0.0-internal.6.2.0`): Import from [@fluidframework/telemetry-utils](https://www.npmjs.com/package/@fluidframework/telemetry-utils) instead.
|
|
63
|
+
- `ThrottlingWarning` (deprecated in `2.0.0-internal.6.2.0`): No replacement API offered.
|
|
64
|
+
- `UsageError` (deprecated in `2.0.0-internal.6.2.0`): Import from [@fluidframework/telemetry-utils](https://www.npmjs.com/package/@fluidframework/telemetry-utils) instead.
|
|
65
|
+
|
|
66
|
+
## 2.0.0-internal.6.4.0
|
|
67
|
+
|
|
68
|
+
### Minor Changes
|
|
69
|
+
|
|
70
|
+
- Upcoming: The type of the logger property/param in various APIs will be changing ([#17350](https://github.com/microsoft/FluidFramework/issues/17350)) [27284bcda3](https://github.com/microsoft/FluidFramework/commits/27284bcda3d63cc4306cf76806f8a075db0db60f)
|
|
71
|
+
|
|
72
|
+
- @fluidframework/runtime-definitions
|
|
73
|
+
- `IFluidDataStoreRuntime.logger` will be re-typed as `ITelemetryBaseLogger`
|
|
74
|
+
- @fluidframework/odsp-driver
|
|
75
|
+
- `protected OdspDocumentServiceFactoryCore.createDocumentServiceCore`'s parameter `odspLogger` will be re-typed as `ITelemetryLoggerExt`
|
|
76
|
+
- `protected LocalOdspDocumentServiceFactory.createDocumentServiceCore`'s parameter `odspLogger` will be re-typed as `ITelemetryLoggerExt`
|
|
77
|
+
|
|
78
|
+
Additionally, several of @fluidframework/telemetry-utils's exports are being marked as internal and should not be consumed outside of other FF packages.
|
|
79
|
+
|
|
3
80
|
## 2.0.0-internal.6.3.0
|
|
4
81
|
|
|
5
82
|
### Minor Changes
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "@fluidframework/build-common/api-extractor-
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-base.json",
|
|
4
|
+
"messages": {
|
|
5
|
+
"extractorMessageReporting": {
|
|
6
|
+
"ae-missing-release-tag": {
|
|
7
|
+
// TODO: Fix violations and remove this rule override
|
|
8
|
+
"logLevel": "none"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
4
12
|
}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
## API Report File for "@fluidframework/telemetry-utils"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
9
|
+
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
10
|
+
import { IErrorBase } from '@fluidframework/core-interfaces';
|
|
11
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
12
|
+
import { IGenericError } from '@fluidframework/core-interfaces';
|
|
13
|
+
import { ILoggingError } from '@fluidframework/core-interfaces';
|
|
14
|
+
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
15
|
+
import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
|
|
16
|
+
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
17
|
+
import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
|
|
18
|
+
import { ITelemetryErrorEvent } from '@fluidframework/core-interfaces';
|
|
19
|
+
import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
|
|
20
|
+
import { ITelemetryPerformanceEvent } from '@fluidframework/core-interfaces';
|
|
21
|
+
import { ITelemetryProperties } from '@fluidframework/core-interfaces';
|
|
22
|
+
import { IUsageError } from '@fluidframework/core-interfaces';
|
|
23
|
+
import { Lazy } from '@fluidframework/core-utils';
|
|
24
|
+
import { LogLevel } from '@fluidframework/core-interfaces';
|
|
25
|
+
import { Tagged } from '@fluidframework/core-interfaces';
|
|
26
|
+
import { TelemetryBaseEventPropertyType } from '@fluidframework/core-interfaces';
|
|
27
|
+
import { TelemetryEventPropertyType } from '@fluidframework/core-interfaces';
|
|
28
|
+
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
29
|
+
|
|
30
|
+
// @public (undocumented)
|
|
31
|
+
export type ConfigTypes = string | number | boolean | number[] | string[] | boolean[] | undefined;
|
|
32
|
+
|
|
33
|
+
// @public (undocumented)
|
|
34
|
+
export const connectedEventName = "connected";
|
|
35
|
+
|
|
36
|
+
// @public
|
|
37
|
+
export function createChildLogger(props?: {
|
|
38
|
+
logger?: ITelemetryBaseLogger;
|
|
39
|
+
namespace?: string;
|
|
40
|
+
properties?: ITelemetryLoggerPropertyBags;
|
|
41
|
+
}): ITelemetryLoggerExt;
|
|
42
|
+
|
|
43
|
+
// @public (undocumented)
|
|
44
|
+
export function createChildMonitoringContext(props: Parameters<typeof createChildLogger>[0]): MonitoringContext;
|
|
45
|
+
|
|
46
|
+
// @public
|
|
47
|
+
export function createMultiSinkLogger(props: {
|
|
48
|
+
namespace?: string;
|
|
49
|
+
properties?: ITelemetryLoggerPropertyBags;
|
|
50
|
+
loggers?: (ITelemetryBaseLogger | undefined)[];
|
|
51
|
+
tryInheritProperties?: true;
|
|
52
|
+
}): ITelemetryLoggerExt;
|
|
53
|
+
|
|
54
|
+
// @internal
|
|
55
|
+
export function createSampledLogger(logger: ITelemetryLoggerExt, eventSampler?: IEventSampler): ISampledTelemetryLogger;
|
|
56
|
+
|
|
57
|
+
// @internal
|
|
58
|
+
export class DataCorruptionError extends LoggingError implements IErrorBase, IFluidErrorBase {
|
|
59
|
+
constructor(message: string, props: ITelemetryBaseProperties);
|
|
60
|
+
// (undocumented)
|
|
61
|
+
readonly canRetry = false;
|
|
62
|
+
// (undocumented)
|
|
63
|
+
readonly errorType: "dataCorruptionError";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// @internal
|
|
67
|
+
export class DataProcessingError extends LoggingError implements IErrorBase, IFluidErrorBase {
|
|
68
|
+
// (undocumented)
|
|
69
|
+
readonly canRetry = false;
|
|
70
|
+
static create(errorMessage: string, dataProcessingCodepath: string, sequencedMessage?: ISequencedDocumentMessage, props?: ITelemetryBaseProperties): IFluidErrorBase;
|
|
71
|
+
readonly errorType: "dataProcessingError";
|
|
72
|
+
static wrapIfUnrecognized(originalError: unknown, dataProcessingCodepath: string, messageLike?: Partial<Pick<ISequencedDocumentMessage, "clientId" | "sequenceNumber" | "clientSequenceNumber" | "referenceSequenceNumber" | "minimumSequenceNumber" | "timestamp">>): IFluidErrorBase;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// @public (undocumented)
|
|
76
|
+
export const disconnectedEventName = "disconnected";
|
|
77
|
+
|
|
78
|
+
// @public
|
|
79
|
+
export class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> extends TypedEventEmitter<TEvent> {
|
|
80
|
+
constructor(errorHandler: (eventName: EventEmitterEventType, error: any) => void);
|
|
81
|
+
// (undocumented)
|
|
82
|
+
emit(event: EventEmitterEventType, ...args: unknown[]): boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// @public (undocumented)
|
|
86
|
+
export const eventNamespaceSeparator: ":";
|
|
87
|
+
|
|
88
|
+
// @internal
|
|
89
|
+
export function extractLogSafeErrorProperties(error: unknown, sanitizeStack: boolean): {
|
|
90
|
+
message: string;
|
|
91
|
+
errorType?: string | undefined;
|
|
92
|
+
stack?: string | undefined;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// @public
|
|
96
|
+
export const extractSafePropertiesFromMessage: (messageLike: Partial<Pick<ISequencedDocumentMessage, "clientId" | "sequenceNumber" | "clientSequenceNumber" | "referenceSequenceNumber" | "minimumSequenceNumber" | "timestamp">>) => {
|
|
97
|
+
messageClientId: string | undefined;
|
|
98
|
+
messageSequenceNumber: number | undefined;
|
|
99
|
+
messageClientSequenceNumber: number | undefined;
|
|
100
|
+
messageReferenceSequenceNumber: number | undefined;
|
|
101
|
+
messageMinimumSequenceNumber: number | undefined;
|
|
102
|
+
messageTimestamp: number | undefined;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// @public (undocumented)
|
|
106
|
+
export function formatTick(tick: number): number;
|
|
107
|
+
|
|
108
|
+
// @internal
|
|
109
|
+
export function generateErrorWithStack(): Error;
|
|
110
|
+
|
|
111
|
+
// @internal
|
|
112
|
+
export function generateStack(): string | undefined;
|
|
113
|
+
|
|
114
|
+
// @internal
|
|
115
|
+
export class GenericError extends LoggingError implements IGenericError, IFluidErrorBase {
|
|
116
|
+
constructor(message: string, error?: any, props?: ITelemetryBaseProperties);
|
|
117
|
+
// (undocumented)
|
|
118
|
+
readonly error?: any;
|
|
119
|
+
// (undocumented)
|
|
120
|
+
readonly errorType: "genericError";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// @internal
|
|
124
|
+
export const getCircularReplacer: () => (key: string, value: unknown) => any;
|
|
125
|
+
|
|
126
|
+
// @public
|
|
127
|
+
export const hasErrorInstanceId: (x: unknown) => x is {
|
|
128
|
+
errorInstanceId: string;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// @public
|
|
132
|
+
export interface IConfigProvider extends IConfigProviderBase {
|
|
133
|
+
// (undocumented)
|
|
134
|
+
getBoolean(name: string): boolean | undefined;
|
|
135
|
+
// (undocumented)
|
|
136
|
+
getBooleanArray(name: string): boolean[] | undefined;
|
|
137
|
+
// (undocumented)
|
|
138
|
+
getNumber(name: string): number | undefined;
|
|
139
|
+
// (undocumented)
|
|
140
|
+
getNumberArray(name: string): number[] | undefined;
|
|
141
|
+
// (undocumented)
|
|
142
|
+
getString(name: string): string | undefined;
|
|
143
|
+
// (undocumented)
|
|
144
|
+
getStringArray(name: string): string[] | undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// @public
|
|
148
|
+
export interface IConfigProviderBase {
|
|
149
|
+
// (undocumented)
|
|
150
|
+
getRawConfig(name: string): ConfigTypes;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// @internal
|
|
154
|
+
export interface IEventSampler {
|
|
155
|
+
// (undocumented)
|
|
156
|
+
sample: () => boolean | undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// @internal
|
|
160
|
+
export interface IFluidErrorAnnotations {
|
|
161
|
+
props?: ITelemetryBaseProperties;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// @public
|
|
165
|
+
export interface IFluidErrorBase extends Error {
|
|
166
|
+
addTelemetryProperties: (props: ITelemetryProperties) => void;
|
|
167
|
+
readonly errorInstanceId: string;
|
|
168
|
+
readonly errorType: string;
|
|
169
|
+
getTelemetryProperties(): ITelemetryProperties;
|
|
170
|
+
readonly message: string;
|
|
171
|
+
readonly name: string;
|
|
172
|
+
readonly stack?: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// @public
|
|
176
|
+
export interface IPerformanceEventMarkers {
|
|
177
|
+
// (undocumented)
|
|
178
|
+
cancel?: "generic" | "error";
|
|
179
|
+
// (undocumented)
|
|
180
|
+
end?: true;
|
|
181
|
+
// (undocumented)
|
|
182
|
+
start?: true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// @internal
|
|
186
|
+
export interface ISampledTelemetryLogger extends ITelemetryLoggerExt {
|
|
187
|
+
isSamplingDisabled: boolean;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// @internal
|
|
191
|
+
export function isExternalError(error: unknown): boolean;
|
|
192
|
+
|
|
193
|
+
// @public
|
|
194
|
+
export function isFluidError(error: unknown): error is IFluidErrorBase;
|
|
195
|
+
|
|
196
|
+
// @public
|
|
197
|
+
export const isILoggingError: (x: unknown) => x is ILoggingError;
|
|
198
|
+
|
|
199
|
+
// @public
|
|
200
|
+
export function isTaggedTelemetryPropertyValue(x: Tagged<TelemetryEventPropertyTypeExt> | TelemetryEventPropertyTypeExt): x is Tagged<TelemetryEventPropertyTypeExt>;
|
|
201
|
+
|
|
202
|
+
// @public
|
|
203
|
+
export function isValidLegacyError(error: unknown): error is Omit<IFluidErrorBase, "errorInstanceId">;
|
|
204
|
+
|
|
205
|
+
// @public @deprecated
|
|
206
|
+
export interface ITaggedTelemetryPropertyTypeExt {
|
|
207
|
+
// (undocumented)
|
|
208
|
+
tag: string;
|
|
209
|
+
// (undocumented)
|
|
210
|
+
value: TelemetryEventPropertyTypeExt;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// @public
|
|
214
|
+
export interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
|
|
215
|
+
// (undocumented)
|
|
216
|
+
eventName: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// @public
|
|
220
|
+
export interface ITelemetryEventExt extends ITelemetryPropertiesExt {
|
|
221
|
+
// (undocumented)
|
|
222
|
+
category: string;
|
|
223
|
+
// (undocumented)
|
|
224
|
+
eventName: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// @public
|
|
228
|
+
export interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
|
|
229
|
+
// (undocumented)
|
|
230
|
+
category?: TelemetryEventCategory;
|
|
231
|
+
// (undocumented)
|
|
232
|
+
eventName: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// @public
|
|
236
|
+
export interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
|
|
237
|
+
sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;
|
|
238
|
+
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
|
|
239
|
+
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// @public (undocumented)
|
|
243
|
+
export interface ITelemetryLoggerPropertyBag {
|
|
244
|
+
// (undocumented)
|
|
245
|
+
[index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// @public (undocumented)
|
|
249
|
+
export interface ITelemetryLoggerPropertyBags {
|
|
250
|
+
// (undocumented)
|
|
251
|
+
all?: ITelemetryLoggerPropertyBag;
|
|
252
|
+
// (undocumented)
|
|
253
|
+
error?: ITelemetryLoggerPropertyBag;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// @public
|
|
257
|
+
export interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {
|
|
258
|
+
// (undocumented)
|
|
259
|
+
duration?: number;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// @public
|
|
263
|
+
export interface ITelemetryPropertiesExt {
|
|
264
|
+
// (undocumented)
|
|
265
|
+
[index: string]: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// @public (undocumented)
|
|
269
|
+
export function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(logger: L): MonitoringContext<L>;
|
|
270
|
+
|
|
271
|
+
// @internal
|
|
272
|
+
export class LoggingError extends Error implements ILoggingError, Omit<IFluidErrorBase, "errorType"> {
|
|
273
|
+
constructor(message: string, props?: ITelemetryBaseProperties, omitPropsFromLogging?: Set<string>);
|
|
274
|
+
addTelemetryProperties(props: ITelemetryBaseProperties): void;
|
|
275
|
+
// (undocumented)
|
|
276
|
+
get errorInstanceId(): string;
|
|
277
|
+
getTelemetryProperties(): ITelemetryBaseProperties;
|
|
278
|
+
// (undocumented)
|
|
279
|
+
overwriteErrorInstanceId(id: string): void;
|
|
280
|
+
static typeCheck(object: unknown): object is LoggingError;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// @public
|
|
284
|
+
export function logIfFalse(condition: unknown, logger: ITelemetryBaseLogger, event: string | ITelemetryGenericEvent): condition is true;
|
|
285
|
+
|
|
286
|
+
// @public (undocumented)
|
|
287
|
+
export function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(logger: L, ...configs: (IConfigProviderBase | undefined)[]): MonitoringContext<L>;
|
|
288
|
+
|
|
289
|
+
// @public
|
|
290
|
+
export class MockLogger implements ITelemetryBaseLogger {
|
|
291
|
+
constructor(minLogLevel?: LogLevel | undefined);
|
|
292
|
+
assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
|
|
293
|
+
assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
|
|
294
|
+
assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
|
|
295
|
+
assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
|
|
296
|
+
// (undocumented)
|
|
297
|
+
clear(): void;
|
|
298
|
+
// (undocumented)
|
|
299
|
+
events: ITelemetryBaseEvent[];
|
|
300
|
+
matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
|
|
301
|
+
matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
|
|
302
|
+
matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
|
|
303
|
+
// (undocumented)
|
|
304
|
+
readonly minLogLevel?: LogLevel | undefined;
|
|
305
|
+
// (undocumented)
|
|
306
|
+
send(event: ITelemetryBaseEvent): void;
|
|
307
|
+
// (undocumented)
|
|
308
|
+
toTelemetryLogger(): ITelemetryLoggerExt;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// @public
|
|
312
|
+
export interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {
|
|
313
|
+
// (undocumented)
|
|
314
|
+
config: IConfigProvider;
|
|
315
|
+
// (undocumented)
|
|
316
|
+
logger: L;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// @internal
|
|
320
|
+
export const NORMALIZED_ERROR_TYPE = "genericError";
|
|
321
|
+
|
|
322
|
+
// @internal
|
|
323
|
+
export function normalizeError(error: unknown, annotations?: IFluidErrorAnnotations): IFluidErrorBase;
|
|
324
|
+
|
|
325
|
+
// @public
|
|
326
|
+
export function numberFromString(str: string | null | undefined): string | number | undefined;
|
|
327
|
+
|
|
328
|
+
// @internal
|
|
329
|
+
export function overwriteStack(error: IFluidErrorBase | LoggingError, stack: string): void;
|
|
330
|
+
|
|
331
|
+
// @public
|
|
332
|
+
export class PerformanceEvent {
|
|
333
|
+
protected constructor(logger: ITelemetryLoggerExt, event: ITelemetryGenericEvent, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, emitLogs?: boolean);
|
|
334
|
+
// (undocumented)
|
|
335
|
+
cancel(props?: ITelemetryProperties, error?: unknown): void;
|
|
336
|
+
// (undocumented)
|
|
337
|
+
get duration(): number;
|
|
338
|
+
// (undocumented)
|
|
339
|
+
end(props?: ITelemetryProperties): void;
|
|
340
|
+
reportEvent(eventNameSuffix: string, props?: ITelemetryProperties, error?: unknown): void;
|
|
341
|
+
// (undocumented)
|
|
342
|
+
reportProgress(props?: ITelemetryProperties, eventNameSuffix?: string): void;
|
|
343
|
+
static start(logger: ITelemetryLoggerExt, event: ITelemetryGenericEvent, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, emitLogs?: boolean): PerformanceEvent;
|
|
344
|
+
static timedExec<T>(logger: ITelemetryLoggerExt, event: ITelemetryGenericEvent, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number): T;
|
|
345
|
+
static timedExecAsync<T>(logger: ITelemetryLoggerExt, event: ITelemetryGenericEvent, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, sampleThreshold?: number): Promise<T>;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// @public
|
|
349
|
+
export function raiseConnectedEvent(logger: ITelemetryLoggerExt, emitter: EventEmitter, connected: boolean, clientId?: string, disconnectedReason?: string): void;
|
|
350
|
+
|
|
351
|
+
// @public (undocumented)
|
|
352
|
+
export function safeRaiseEvent(emitter: EventEmitter, logger: ITelemetryLoggerExt, event: string, ...args: unknown[]): void;
|
|
353
|
+
|
|
354
|
+
// @public
|
|
355
|
+
export class SampledTelemetryHelper implements IDisposable {
|
|
356
|
+
constructor(eventBase: ITelemetryGenericEvent, logger: ITelemetryLoggerExt, sampleThreshold: number, includeAggregateMetrics?: boolean, perBucketProperties?: Map<string, ITelemetryProperties>);
|
|
357
|
+
// (undocumented)
|
|
358
|
+
dispose(error?: Error | undefined): void;
|
|
359
|
+
// (undocumented)
|
|
360
|
+
disposed: boolean;
|
|
361
|
+
measure<T>(codeToMeasure: () => T, bucket?: string): T;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// @public
|
|
365
|
+
export const sessionStorageConfigProvider: Lazy<IConfigProviderBase>;
|
|
366
|
+
|
|
367
|
+
// @public
|
|
368
|
+
export const tagCodeArtifacts: <T extends Record<string, TelemetryEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(values: T) => { [P in keyof T]: (T[P] extends () => TelemetryBaseEventPropertyType ? () => {
|
|
369
|
+
value: ReturnType<T[P]>;
|
|
370
|
+
tag: TelemetryDataTag.CodeArtifact;
|
|
371
|
+
} : {
|
|
372
|
+
value: Exclude<T[P], undefined>;
|
|
373
|
+
tag: TelemetryDataTag.CodeArtifact;
|
|
374
|
+
}) | (T[P] extends undefined ? undefined : never); };
|
|
375
|
+
|
|
376
|
+
// @public (undocumented)
|
|
377
|
+
export const tagData: <T extends TelemetryDataTag, V extends Record<string, TelemetryEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(tag: T, values: V) => { [P in keyof V]: (V[P] extends () => TelemetryBaseEventPropertyType ? () => {
|
|
378
|
+
value: ReturnType<V[P]>;
|
|
379
|
+
tag: T;
|
|
380
|
+
} : {
|
|
381
|
+
value: Exclude<V[P], undefined>;
|
|
382
|
+
tag: T;
|
|
383
|
+
}) | (V[P] extends undefined ? undefined : never); };
|
|
384
|
+
|
|
385
|
+
// @public @deprecated (undocumented)
|
|
386
|
+
export class TaggedLoggerAdapter implements ITelemetryBaseLogger {
|
|
387
|
+
constructor(logger: ITelemetryBaseLogger);
|
|
388
|
+
// (undocumented)
|
|
389
|
+
send(eventWithTagsMaybe: ITelemetryBaseEvent): void;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// @public
|
|
393
|
+
export enum TelemetryDataTag {
|
|
394
|
+
CodeArtifact = "CodeArtifact",
|
|
395
|
+
UserData = "UserData"
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// @public
|
|
399
|
+
export type TelemetryEventCategory = "generic" | "error" | "performance";
|
|
400
|
+
|
|
401
|
+
// @public
|
|
402
|
+
export type TelemetryEventPropertyTypeExt = string | number | boolean | undefined | (string | number | boolean)[] | {
|
|
403
|
+
[key: string]: // Flat objects can have the same properties as the event itself
|
|
404
|
+
string | number | boolean | undefined | (string | number | boolean)[];
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// @public (undocumented)
|
|
408
|
+
export type TelemetryEventPropertyTypes = ITelemetryBaseProperties[string];
|
|
409
|
+
|
|
410
|
+
// @public @deprecated
|
|
411
|
+
export class TelemetryNullLogger implements ITelemetryLoggerExt {
|
|
412
|
+
// (undocumented)
|
|
413
|
+
send(event: ITelemetryBaseEvent): void;
|
|
414
|
+
// (undocumented)
|
|
415
|
+
sendErrorEvent(event: ITelemetryErrorEvent, error?: unknown): void;
|
|
416
|
+
// (undocumented)
|
|
417
|
+
sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: unknown): void;
|
|
418
|
+
// (undocumented)
|
|
419
|
+
sendTelemetryEvent(event: ITelemetryGenericEvent, error?: unknown): void;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// @public
|
|
423
|
+
export class ThresholdCounter {
|
|
424
|
+
constructor(threshold: number, logger: ITelemetryLoggerExt, thresholdMultiple?: number);
|
|
425
|
+
send(eventName: string, value: number): void;
|
|
426
|
+
sendIfMultiple(eventName: string, value: number): void;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// @internal
|
|
430
|
+
export class UsageError extends LoggingError implements IUsageError, IFluidErrorBase {
|
|
431
|
+
constructor(message: string, props?: ITelemetryBaseProperties);
|
|
432
|
+
// (undocumented)
|
|
433
|
+
readonly errorType: "usageError";
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// @internal
|
|
437
|
+
export function wrapError<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T): T;
|
|
438
|
+
|
|
439
|
+
// @internal
|
|
440
|
+
export function wrapErrorAndLog<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T, logger: ITelemetryLoggerExt): T;
|
|
441
|
+
|
|
442
|
+
// (No @packageDocumentation comment for this package)
|
|
443
|
+
|
|
444
|
+
```
|
package/dist/config.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
|
6
6
|
import { Lazy } from "@fluidframework/core-utils";
|
|
7
7
|
import { createChildLogger } from "./logger";
|
|
8
8
|
import { ITelemetryLoggerExt } from "./telemetryTypes";
|
|
9
|
-
export
|
|
9
|
+
export type ConfigTypes = string | number | boolean | number[] | string[] | boolean[] | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* Base interface for providing configurations to enable/disable/control features
|
|
12
12
|
*/
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,Y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AAI,yBAAyB,CAAI,MAAM,CAAC,EAAE;QACzC,OAAO,MAAM,CAAC;KACd;IACD,OAAO,sBAAsB,CAAI,MAAM,EAAE,oCAA4B,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAPD,8DAOC;AAED,SAAgB,sBAAsB,CACrC,MAAS,EACT,GAAG,OAA4C;IAE/C,IAAI,yBAAyB,CAAI,MAAM,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC1D;IACD;;;;;;;OAOG;IACH,MAAM,EAAE,GAAsC,MAAM,CAAC;IACrD,EAAE,CAAC,MAAM,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;IACzD,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;IACnB,OAAO,EAA0B,CAAC;AACnC,CAAC;AAnBD,wDAmBC;AAED,SAAS,oBAAoB,CAAC,GAAY;IACzC,MAAM,WAAW,GAAG,GAA+C,CAAC;IACpE,OAAO,OAAO,WAAW,EAAE,YAAY,KAAK,UAAU,CAAC;AACxD,CAAC;AAED,SAAgB,4BAA4B,CAC3C,KAA8C;IAE9C,OAAO,yBAAyB,CAAC,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC;AAJD,oEAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils\";\nimport { createChildLogger, tagCodeArtifacts } from \"./logger\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\nexport type ConfigTypes = string | number | boolean | number[] | string[] | boolean[] | undefined;\n\n/**\n * Base interface for providing configurations to enable/disable/control features\n */\nexport interface IConfigProviderBase {\n\tgetRawConfig(name: string): ConfigTypes;\n}\n\n/**\n * Explicitly typed interface for reading configurations\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(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\tdefault:\n\t\t\treturn false;\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) 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 * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tconstructor(\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\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tgetBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tgetNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tgetString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tgetBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tgetNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tgetStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tgetRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\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 */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\tlogger: L;\n}\n\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = 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\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAKA,2DAAkD;AAClD,qCAA+D;AAuB/D;;;;GAIG;AACU,QAAA,4BAA4B,GAAG,IAAI,iBAAI,CAAsB,GAAG,EAAE,CAC9E,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,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I,yBAAyB,CAAI,MAAM,CAAC,EAAE;QACzC,OAAO,MAAM,CAAC;KACd;IACD,OAAO,sBAAsB,CAAI,MAAM,EAAE,oCAA4B,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAPD,8DAOC;AAED,SAAgB,sBAAsB,CACrC,MAAS,EACT,GAAG,OAA4C;IAE/C,IAAI,yBAAyB,CAAI,MAAM,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC1D;IACD;;;;;;;OAOG;IACH,MAAM,EAAE,GAAsC,MAAM,CAAC;IACrD,EAAE,CAAC,MAAM,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;IACzD,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;IACnB,OAAO,EAA0B,CAAC;AACnC,CAAC;AAnBD,wDAmBC;AAED,SAAS,oBAAoB,CAAC,GAAY;IACzC,MAAM,WAAW,GAAG,GAA+C,CAAC;IACpE,OAAO,OAAO,WAAW,EAAE,YAAY,KAAK,UAAU,CAAC;AACxD,CAAC;AAED,SAAgB,4BAA4B,CAC3C,KAA8C;IAE9C,OAAO,yBAAyB,CAAC,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC;AAJD,oEAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils\";\nimport { createChildLogger, tagCodeArtifacts } from \"./logger\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\nexport type ConfigTypes = string | number | boolean | number[] | string[] | boolean[] | undefined;\n\n/**\n * Base interface for providing configurations to enable/disable/control features\n */\nexport interface IConfigProviderBase {\n\tgetRawConfig(name: string): ConfigTypes;\n}\n\n/**\n * Explicitly typed interface for reading configurations\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(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 * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tconstructor(\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\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tgetBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tgetNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tgetString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tgetBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tgetNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tgetStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tgetRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\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 */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\tlogger: L;\n}\n\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = 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\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n"]}
|