@fluidframework/telemetry-utils 2.0.0-internal.5.4.2 → 2.0.0-internal.6.0.1
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 +21 -0
- package/dist/config.js +25 -31
- package/dist/config.js.map +1 -1
- package/dist/errorLogging.js +16 -10
- package/dist/errorLogging.js.map +1 -1
- package/dist/fluidErrorBase.js +7 -7
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -8
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +5 -47
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -120
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.d.ts +3 -5
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +6 -15
- package/dist/mockLogger.js.map +1 -1
- package/dist/sampledTelemetryHelper.js +8 -5
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/config.js +25 -31
- package/lib/config.js.map +1 -1
- package/lib/errorLogging.js +16 -10
- package/lib/errorLogging.js.map +1 -1
- package/lib/fluidErrorBase.js +7 -7
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/logger.d.ts +5 -47
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +46 -117
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.d.ts +3 -5
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +7 -16
- package/lib/mockLogger.js.map +1 -1
- package/lib/sampledTelemetryHelper.js +8 -5
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +0 -6
- package/src/logger.ts +16 -89
- package/src/mockLogger.ts +8 -8
- package/dist/debugLogger.d.ts +0 -39
- package/dist/debugLogger.d.ts.map +0 -1
- package/dist/debugLogger.js +0 -105
- package/dist/debugLogger.js.map +0 -1
- package/lib/debugLogger.d.ts +0 -39
- package/lib/debugLogger.d.ts.map +0 -1
- package/lib/debugLogger.js +0 -101
- package/lib/debugLogger.js.map +0 -1
- package/src/debugLogger.ts +0 -138
package/dist/logger.d.ts
CHANGED
|
@@ -43,24 +43,11 @@ export declare const eventNamespaceSeparator: ":";
|
|
|
43
43
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
44
44
|
* Creates sub-logger that appends properties to all events
|
|
45
45
|
*
|
|
46
|
-
* @deprecated - In a subsequent release this type will no longer be exported, use ITelemetryLogger instead
|
|
47
46
|
*/
|
|
48
47
|
export declare abstract class TelemetryLogger implements ITelemetryLoggerExt {
|
|
49
48
|
protected readonly namespace?: string | undefined;
|
|
50
49
|
protected readonly properties?: ITelemetryLoggerPropertyBags | undefined;
|
|
51
50
|
static readonly eventNamespaceSeparator: ":";
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated - use formatTick
|
|
54
|
-
*/
|
|
55
|
-
static formatTick(tick: number): number;
|
|
56
|
-
/**
|
|
57
|
-
* Attempts to parse number from string.
|
|
58
|
-
* If fails,returns original string.
|
|
59
|
-
* Used to make telemetry data typed (and support math operations, like comparison),
|
|
60
|
-
* in places where we do expect numbers (like contentsize/duration property in http header)
|
|
61
|
-
* @deprecated - use numberFromString
|
|
62
|
-
*/
|
|
63
|
-
static numberFromString(str: string | null | undefined): string | number | undefined;
|
|
64
51
|
static sanitizePkgName(name: string): string;
|
|
65
52
|
/**
|
|
66
53
|
* Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied
|
|
@@ -136,7 +123,6 @@ export declare function createChildLogger(props?: {
|
|
|
136
123
|
* ChildLogger class contains various helper telemetry methods,
|
|
137
124
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
138
125
|
* Creates sub-logger that appends properties to all events
|
|
139
|
-
* @deprecated - Use createChildLogger instead
|
|
140
126
|
*/
|
|
141
127
|
export declare class ChildLogger extends TelemetryLogger {
|
|
142
128
|
protected readonly baseLogger: ITelemetryBaseLogger;
|
|
@@ -170,7 +156,6 @@ export declare function createMultiSinkLogger(props: {
|
|
|
170
156
|
/**
|
|
171
157
|
* Multi-sink logger
|
|
172
158
|
* Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink
|
|
173
|
-
* @deprecated - use createMultiSinkLogger instead
|
|
174
159
|
*/
|
|
175
160
|
export declare class MultiSinkLogger extends TelemetryLogger {
|
|
176
161
|
protected loggers: ITelemetryBaseLogger[];
|
|
@@ -232,38 +217,11 @@ export declare class PerformanceEvent {
|
|
|
232
217
|
reportEvent(eventNameSuffix: string, props?: ITelemetryProperties, error?: any): void;
|
|
233
218
|
}
|
|
234
219
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
send(event: ITelemetryBaseEvent): void;
|
|
241
|
-
sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void;
|
|
242
|
-
sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void;
|
|
243
|
-
sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void;
|
|
244
|
-
logGenericError(eventName: string, error: any): void;
|
|
245
|
-
logException(event: ITelemetryErrorEvent, exception: any): void;
|
|
246
|
-
debugAssert(condition: boolean, event?: ITelemetryErrorEvent): void;
|
|
247
|
-
shipAssert(condition: boolean, event?: ITelemetryErrorEvent): void;
|
|
248
|
-
private reportError;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Null logger
|
|
252
|
-
* It can be used in places where logger instance is required, but events should be not send over.
|
|
253
|
-
* @deprecated - for internal use only
|
|
254
|
-
*/
|
|
255
|
-
export declare class BaseTelemetryNullLogger implements ITelemetryBaseLogger {
|
|
256
|
-
/**
|
|
257
|
-
* Send an event with the logger
|
|
258
|
-
*
|
|
259
|
-
* @param event - the event to send
|
|
260
|
-
*/
|
|
261
|
-
send(event: ITelemetryBaseEvent): void;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Null logger
|
|
265
|
-
* It can be used in places where logger instance is required, but events should be not send over.
|
|
266
|
-
* @deprecated - for internal use only
|
|
220
|
+
* Null logger that no-ops for all telemetry events passed to it.
|
|
221
|
+
* @deprecated - This will be removed in a future release.
|
|
222
|
+
* For internal use within the FluidFramework codebase, use {@link createChildLogger} with no arguments instead.
|
|
223
|
+
* For external consumers we recommend writing a trivial implementation of {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}
|
|
224
|
+
* where the send() method does nothing and using that.
|
|
267
225
|
*/
|
|
268
226
|
export declare class TelemetryNullLogger implements ITelemetryLoggerExt {
|
|
269
227
|
send(event: ITelemetryBaseEvent): void;
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAe,MAAM,8BAA8B,CAAC;AAQlF,OAAO,EACN,+BAA+B,EAE/B,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,MAAM;IACtB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IACnE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AACD;;;GAGG;AACH,oBAAY,gBAAgB;IAC3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M,gBAAgB;;;mDAEsB,CAAC"}
|
package/dist/logger.js
CHANGED
|
@@ -3,19 +3,8 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
7
|
-
var t = {};
|
|
8
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
9
|
-
t[p] = s[p];
|
|
10
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
11
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
12
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
13
|
-
t[p[i]] = s[p[i]];
|
|
14
|
-
}
|
|
15
|
-
return t;
|
|
16
|
-
};
|
|
17
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.tagCodeArtifacts = exports.tagData = exports.convertToBasePropertyType = exports.TelemetryNullLogger = exports.
|
|
7
|
+
exports.tagCodeArtifacts = exports.tagData = exports.convertToBasePropertyType = exports.TelemetryNullLogger = exports.PerformanceEvent = exports.MultiSinkLogger = exports.createMultiSinkLogger = exports.ChildLogger = exports.createChildLogger = exports.TaggedLoggerAdapter = exports.TelemetryLogger = exports.eventNamespaceSeparator = exports.formatTick = exports.numberFromString = exports.TelemetryDataTag = void 0;
|
|
19
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
20
9
|
const config_1 = require("./config");
|
|
21
10
|
const errorLogging_1 = require("./errorLogging");
|
|
@@ -54,33 +43,12 @@ exports.eventNamespaceSeparator = ":";
|
|
|
54
43
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
55
44
|
* Creates sub-logger that appends properties to all events
|
|
56
45
|
*
|
|
57
|
-
* @deprecated - In a subsequent release this type will no longer be exported, use ITelemetryLogger instead
|
|
58
46
|
*/
|
|
59
47
|
class TelemetryLogger {
|
|
60
48
|
constructor(namespace, properties) {
|
|
61
49
|
this.namespace = namespace;
|
|
62
50
|
this.properties = properties;
|
|
63
51
|
}
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated - use formatTick
|
|
66
|
-
*/
|
|
67
|
-
static formatTick(tick) {
|
|
68
|
-
return Math.floor(tick);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Attempts to parse number from string.
|
|
72
|
-
* If fails,returns original string.
|
|
73
|
-
* Used to make telemetry data typed (and support math operations, like comparison),
|
|
74
|
-
* in places where we do expect numbers (like contentsize/duration property in http header)
|
|
75
|
-
* @deprecated - use numberFromString
|
|
76
|
-
*/
|
|
77
|
-
static numberFromString(str) {
|
|
78
|
-
if (str === undefined || str === null) {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
const num = Number(str);
|
|
82
|
-
return Number.isNaN(num) ? str : num;
|
|
83
|
-
}
|
|
84
52
|
static sanitizePkgName(name) {
|
|
85
53
|
return name.replace("@", "").replace("/", "-");
|
|
86
54
|
}
|
|
@@ -120,8 +88,7 @@ class TelemetryLogger {
|
|
|
120
88
|
* @param error - optional error object to log
|
|
121
89
|
*/
|
|
122
90
|
sendTelemetryEvent(event, error) {
|
|
123
|
-
|
|
124
|
-
this.sendTelemetryEventCore(Object.assign(Object.assign({}, event), { category: (_a = event.category) !== null && _a !== void 0 ? _a : "generic" }), error);
|
|
91
|
+
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error);
|
|
125
92
|
}
|
|
126
93
|
/**
|
|
127
94
|
* Send a telemetry event with the logger
|
|
@@ -147,10 +114,13 @@ class TelemetryLogger {
|
|
|
147
114
|
* @param error - optional error object to log
|
|
148
115
|
*/
|
|
149
116
|
sendErrorEvent(event, error) {
|
|
150
|
-
this.sendTelemetryEventCore(
|
|
117
|
+
this.sendTelemetryEventCore({
|
|
151
118
|
// ensure the error field has some value,
|
|
152
119
|
// this can and will be overridden by event, or error
|
|
153
|
-
error: event.eventName
|
|
120
|
+
error: event.eventName,
|
|
121
|
+
...event,
|
|
122
|
+
category: "error",
|
|
123
|
+
}, error);
|
|
154
124
|
}
|
|
155
125
|
/**
|
|
156
126
|
* Send a performance telemetry event with the logger
|
|
@@ -159,13 +129,17 @@ class TelemetryLogger {
|
|
|
159
129
|
* @param error - optional error object to log
|
|
160
130
|
*/
|
|
161
131
|
sendPerformanceEvent(event, error) {
|
|
162
|
-
|
|
163
|
-
|
|
132
|
+
const perfEvent = {
|
|
133
|
+
...event,
|
|
134
|
+
category: event.category ?? "performance",
|
|
135
|
+
};
|
|
164
136
|
this.sendTelemetryEventCore(perfEvent, error);
|
|
165
137
|
}
|
|
166
138
|
prepareEvent(event) {
|
|
167
139
|
const includeErrorProps = event.category === "error" || event.error !== undefined;
|
|
168
|
-
const newEvent =
|
|
140
|
+
const newEvent = {
|
|
141
|
+
...event,
|
|
142
|
+
};
|
|
169
143
|
if (this.namespace !== undefined) {
|
|
170
144
|
newEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;
|
|
171
145
|
}
|
|
@@ -254,17 +228,13 @@ exports.TaggedLoggerAdapter = TaggedLoggerAdapter;
|
|
|
254
228
|
* Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.
|
|
255
229
|
*/
|
|
256
230
|
function createChildLogger(props) {
|
|
257
|
-
|
|
258
|
-
return new TelemetryNullLogger();
|
|
259
|
-
}
|
|
260
|
-
return ChildLogger.create(props === null || props === void 0 ? void 0 : props.logger, props === null || props === void 0 ? void 0 : props.namespace, props === null || props === void 0 ? void 0 : props.properties);
|
|
231
|
+
return ChildLogger.create(props?.logger, props?.namespace, props?.properties);
|
|
261
232
|
}
|
|
262
233
|
exports.createChildLogger = createChildLogger;
|
|
263
234
|
/**
|
|
264
235
|
* ChildLogger class contains various helper telemetry methods,
|
|
265
236
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
266
237
|
* Creates sub-logger that appends properties to all events
|
|
267
|
-
* @deprecated - Use createChildLogger instead
|
|
268
238
|
*/
|
|
269
239
|
class ChildLogger extends TelemetryLogger {
|
|
270
240
|
constructor(baseLogger, namespace, properties) {
|
|
@@ -290,10 +260,16 @@ class ChildLogger extends TelemetryLogger {
|
|
|
290
260
|
for (const extendedProps of [baseLogger.properties, properties]) {
|
|
291
261
|
if (extendedProps !== undefined) {
|
|
292
262
|
if (extendedProps.all !== undefined) {
|
|
293
|
-
combinedProperties.all =
|
|
263
|
+
combinedProperties.all = {
|
|
264
|
+
...combinedProperties.all,
|
|
265
|
+
...extendedProps.all,
|
|
266
|
+
};
|
|
294
267
|
}
|
|
295
268
|
if (extendedProps.error !== undefined) {
|
|
296
|
-
combinedProperties.error =
|
|
269
|
+
combinedProperties.error = {
|
|
270
|
+
...combinedProperties.error,
|
|
271
|
+
...extendedProps.error,
|
|
272
|
+
};
|
|
297
273
|
}
|
|
298
274
|
}
|
|
299
275
|
}
|
|
@@ -302,9 +278,13 @@ class ChildLogger extends TelemetryLogger {
|
|
|
302
278
|
: namespace === undefined
|
|
303
279
|
? baseLogger.namespace
|
|
304
280
|
: `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;
|
|
305
|
-
|
|
281
|
+
const child = new ChildLogger(baseLogger.baseLogger, combinedNamespace, combinedProperties);
|
|
282
|
+
if (!(0, config_1.loggerIsMonitoringContext)(child) && (0, config_1.loggerIsMonitoringContext)(baseLogger)) {
|
|
283
|
+
(0, config_1.mixinMonitoringContext)(child, baseLogger.config);
|
|
284
|
+
}
|
|
285
|
+
return child;
|
|
306
286
|
}
|
|
307
|
-
return new ChildLogger(baseLogger ? baseLogger :
|
|
287
|
+
return new ChildLogger(baseLogger ? baseLogger : { send() { } }, namespace, properties);
|
|
308
288
|
}
|
|
309
289
|
/**
|
|
310
290
|
* Send an event with the logger
|
|
@@ -322,14 +302,12 @@ exports.ChildLogger = ChildLogger;
|
|
|
322
302
|
* tryInheritProperties will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package
|
|
323
303
|
*/
|
|
324
304
|
function createMultiSinkLogger(props) {
|
|
325
|
-
|
|
326
|
-
return new MultiSinkLogger(props.namespace, props.properties, (_a = props.loggers) === null || _a === void 0 ? void 0 : _a.filter((l) => l !== undefined), props.tryInheritProperties);
|
|
305
|
+
return new MultiSinkLogger(props.namespace, props.properties, props.loggers?.filter((l) => l !== undefined), props.tryInheritProperties);
|
|
327
306
|
}
|
|
328
307
|
exports.createMultiSinkLogger = createMultiSinkLogger;
|
|
329
308
|
/**
|
|
330
309
|
* Multi-sink logger
|
|
331
310
|
* Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink
|
|
332
|
-
* @deprecated - use createMultiSinkLogger instead
|
|
333
311
|
*/
|
|
334
312
|
class MultiSinkLogger extends TelemetryLogger {
|
|
335
313
|
/**
|
|
@@ -340,15 +318,15 @@ class MultiSinkLogger extends TelemetryLogger {
|
|
|
340
318
|
* @param tryInheritProperties - Will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package
|
|
341
319
|
*/
|
|
342
320
|
constructor(namespace, properties, loggers = [], tryInheritProperties) {
|
|
343
|
-
let realProperties = properties !== undefined ?
|
|
321
|
+
let realProperties = properties !== undefined ? { ...properties } : undefined;
|
|
344
322
|
if (tryInheritProperties === true) {
|
|
345
|
-
const merge = (realProperties
|
|
323
|
+
const merge = (realProperties ?? (realProperties = {}));
|
|
346
324
|
loggers
|
|
347
325
|
.filter((l) => l instanceof TelemetryLogger)
|
|
348
|
-
.map((l) =>
|
|
326
|
+
.map((l) => l.properties ?? {})
|
|
349
327
|
.forEach((cv) => {
|
|
350
328
|
Object.keys(cv).forEach((k) => {
|
|
351
|
-
merge[k] =
|
|
329
|
+
merge[k] = { ...cv[k], ...merge?.[k] };
|
|
352
330
|
});
|
|
353
331
|
});
|
|
354
332
|
}
|
|
@@ -382,17 +360,16 @@ exports.MultiSinkLogger = MultiSinkLogger;
|
|
|
382
360
|
*/
|
|
383
361
|
class PerformanceEvent {
|
|
384
362
|
constructor(logger, event, markers = { end: true, cancel: "generic" }, recordHeapSize = false) {
|
|
385
|
-
var _a;
|
|
386
363
|
this.logger = logger;
|
|
387
364
|
this.markers = markers;
|
|
388
365
|
this.recordHeapSize = recordHeapSize;
|
|
389
366
|
this.startTime = common_utils_1.performance.now();
|
|
390
367
|
this.startMemoryCollection = 0;
|
|
391
|
-
this.event =
|
|
368
|
+
this.event = { ...event };
|
|
392
369
|
if (this.markers.start) {
|
|
393
370
|
this.reportEvent("start");
|
|
394
371
|
}
|
|
395
|
-
if (typeof window === "object" && window != null &&
|
|
372
|
+
if (typeof window === "object" && window != null && window.performance?.mark) {
|
|
396
373
|
this.startMark = `${event.eventName}-start`;
|
|
397
374
|
window.performance.mark(this.startMark);
|
|
398
375
|
}
|
|
@@ -453,7 +430,7 @@ class PerformanceEvent {
|
|
|
453
430
|
}
|
|
454
431
|
cancel(props, error) {
|
|
455
432
|
if (this.markers.cancel !== undefined) {
|
|
456
|
-
this.reportEvent("cancel",
|
|
433
|
+
this.reportEvent("cancel", { category: this.markers.cancel, ...props }, error);
|
|
457
434
|
}
|
|
458
435
|
this.event = undefined;
|
|
459
436
|
}
|
|
@@ -461,19 +438,19 @@ class PerformanceEvent {
|
|
|
461
438
|
* Report the event, if it hasn't already been reported.
|
|
462
439
|
*/
|
|
463
440
|
reportEvent(eventNameSuffix, props, error) {
|
|
464
|
-
var _a, _b, _c, _d;
|
|
465
441
|
// There are strange sequences involving multiple Promise chains
|
|
466
442
|
// where the event can be cancelled and then later a callback is invoked
|
|
467
443
|
// and the caller attempts to end directly, e.g. issue #3936. Just return.
|
|
468
444
|
if (!this.event) {
|
|
469
445
|
return;
|
|
470
446
|
}
|
|
471
|
-
const event =
|
|
447
|
+
const event = { ...this.event, ...props };
|
|
472
448
|
event.eventName = `${event.eventName}_${eventNameSuffix}`;
|
|
473
449
|
if (eventNameSuffix !== "start") {
|
|
474
450
|
event.duration = this.duration;
|
|
475
451
|
if (this.startMemoryCollection) {
|
|
476
|
-
const currentMemory =
|
|
452
|
+
const currentMemory = common_utils_1.performance?.memory
|
|
453
|
+
?.usedJSHeapSize;
|
|
477
454
|
const differenceInKBytes = Math.floor((currentMemory - this.startMemoryCollection) / 1024);
|
|
478
455
|
if (differenceInKBytes > 0) {
|
|
479
456
|
event.usedJSHeapSize = differenceInKBytes;
|
|
@@ -481,67 +458,18 @@ class PerformanceEvent {
|
|
|
481
458
|
}
|
|
482
459
|
}
|
|
483
460
|
else if (this.recordHeapSize) {
|
|
484
|
-
this.startMemoryCollection =
|
|
461
|
+
this.startMemoryCollection = common_utils_1.performance?.memory?.usedJSHeapSize;
|
|
485
462
|
}
|
|
486
463
|
this.logger.sendPerformanceEvent(event, error);
|
|
487
464
|
}
|
|
488
465
|
}
|
|
489
466
|
exports.PerformanceEvent = PerformanceEvent;
|
|
490
467
|
/**
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
send(event) { }
|
|
497
|
-
sendTelemetryEvent(event, error) { }
|
|
498
|
-
sendErrorEvent(event, error) {
|
|
499
|
-
this.reportError("errorEvent in UT logger!", event, error);
|
|
500
|
-
}
|
|
501
|
-
sendPerformanceEvent(event, error) { }
|
|
502
|
-
logGenericError(eventName, error) {
|
|
503
|
-
this.reportError(`genericError in UT logger!`, { eventName }, error);
|
|
504
|
-
}
|
|
505
|
-
logException(event, exception) {
|
|
506
|
-
this.reportError("exception in UT logger!", event, exception);
|
|
507
|
-
}
|
|
508
|
-
debugAssert(condition, event) {
|
|
509
|
-
this.reportError("debugAssert in UT logger!");
|
|
510
|
-
}
|
|
511
|
-
shipAssert(condition, event) {
|
|
512
|
-
this.reportError("shipAssert in UT logger!");
|
|
513
|
-
}
|
|
514
|
-
reportError(message, event, err) {
|
|
515
|
-
const error = new Error(message);
|
|
516
|
-
error.error = error;
|
|
517
|
-
error.event = event;
|
|
518
|
-
// report to console as exception can be eaten
|
|
519
|
-
console.error(message);
|
|
520
|
-
console.error(error);
|
|
521
|
-
throw error;
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
exports.TelemetryUTLogger = TelemetryUTLogger;
|
|
525
|
-
/**
|
|
526
|
-
* Null logger
|
|
527
|
-
* It can be used in places where logger instance is required, but events should be not send over.
|
|
528
|
-
* @deprecated - for internal use only
|
|
529
|
-
*/
|
|
530
|
-
class BaseTelemetryNullLogger {
|
|
531
|
-
/**
|
|
532
|
-
* Send an event with the logger
|
|
533
|
-
*
|
|
534
|
-
* @param event - the event to send
|
|
535
|
-
*/
|
|
536
|
-
send(event) {
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
exports.BaseTelemetryNullLogger = BaseTelemetryNullLogger;
|
|
541
|
-
/**
|
|
542
|
-
* Null logger
|
|
543
|
-
* It can be used in places where logger instance is required, but events should be not send over.
|
|
544
|
-
* @deprecated - for internal use only
|
|
468
|
+
* Null logger that no-ops for all telemetry events passed to it.
|
|
469
|
+
* @deprecated - This will be removed in a future release.
|
|
470
|
+
* For internal use within the FluidFramework codebase, use {@link createChildLogger} with no arguments instead.
|
|
471
|
+
* For external consumers we recommend writing a trivial implementation of {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}
|
|
472
|
+
* where the send() method does nothing and using that.
|
|
545
473
|
*/
|
|
546
474
|
class TelemetryNullLogger {
|
|
547
475
|
send(event) { }
|
|
@@ -555,8 +483,7 @@ exports.TelemetryNullLogger = TelemetryNullLogger;
|
|
|
555
483
|
* In the case of an invalid property type, the value will be converted to an error string.
|
|
556
484
|
* @param event - Event with fields you want to stringify.
|
|
557
485
|
*/
|
|
558
|
-
function convertToBaseEvent(
|
|
559
|
-
var { category, eventName } = _a, props = __rest(_a, ["category", "eventName"]);
|
|
486
|
+
function convertToBaseEvent({ category, eventName, ...props }) {
|
|
560
487
|
const newEvent = { category, eventName };
|
|
561
488
|
for (const key of Object.keys(props)) {
|
|
562
489
|
newEvent[key] = convertToBasePropertyType(props[key]);
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AAaH,+DAAkF;AAClF,qCAAmG;AACnG,iDAKwB;AAiBxB;;;GAGG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,4FAA4F;IAC5F,iDAA6B,CAAA;IAC7B,8EAA8E;IAC9E,yCAAqB,CAAA;AACtB,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAYD;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,GAA8B;IAC9D,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE;QACtC,OAAO,SAAS,CAAC;KACjB;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACtC,CAAC;AAND,4CAMC;AAED,SAAgB,UAAU,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAFD,gCAEC;AAEY,QAAA,uBAAuB,GAAG,GAAY,CAAC;AAEpD;;;;;;GAMG;AACH,MAAsB,eAAe;IAgEpC,YACoB,SAAkB,EAClB,UAAyC;QADzC,cAAS,GAAT,SAAS,CAAS;QAClB,eAAU,GAAV,UAAU,CAA+B;IAC1D,CAAC;IAhEJ;;OAEG;IACI,MAAM,CAAC,UAAU,CAAC,IAAY;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,GAA8B;QAC5D,IAAI,GAAG,KAAK,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AAK,CAAC;YACjD,GAAG,EAAE,CAAC,CAAC,GAAG;SACT;QACH,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AATD,8DASC;AAED,SAAS,iCAAiC,CACzC,CAAgC;IAEhC,QAAQ,OAAO,CAAC,EAAE;QACjB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,WAAW;YACf,OAAO,CAAC,CAAC;QACV,KAAK,QAAQ;YACZ,qEAAqE;YACrE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1B;YACC,wDAAwD;YACxD,OAAO,CAAC,KAAK,CACZ,iEAAiE,OAAO,CAAC,GAAG,CAC5E,CAAC;YACF,OAAO,8BAA8B,OAAO,CAAC,GAAG,CAAC;KAClD;AACF,CAAC;AAEM,MAAM,OAAO,GAAG,CAItB,GAAM,EACN,MAAS,EACR,EAAE,CACF,MAAM,CAAC,OAAO,CAAC,MAAM,CAA6B;KACjD,MAAM,CAAC,CAAC,CAAC,EAAkD,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;KACjF,MAAM,CAIJ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IACb,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAClC,OAAO,EAAE,CAAC;AACX,CAAC,EAAE,EAAS,CAAC,CAAC;AAhBH,QAAA,OAAO,WAgBJ;AAET,MAAM,gBAAgB,GAAG,CAC/B,MAAS,EACR,EAAE,CAAC,IAAA,eAAO,EAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAFvC,QAAA,gBAAgB,oBAEuB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryErrorEvent,\n\tITelemetryGenericEvent,\n\tITelemetryPerformanceEvent,\n\tITelemetryProperties,\n\tTelemetryEventPropertyType,\n\tITaggedTelemetryPropertyType,\n\tTelemetryEventCategory,\n} from \"@fluidframework/core-interfaces\";\nimport { IsomorphicPerformance, performance } from \"@fluidframework/common-utils\";\nimport { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext } from \"./config\";\nimport {\n\tisILoggingError,\n\textractLogSafeErrorProperties,\n\tgenerateStack,\n\tisTaggedTelemetryPropertyValue,\n} from \"./errorLogging\";\nimport {\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes\";\n\nexport interface Memory {\n\tusedJSHeapSize: number;\n}\n\nexport interface PerformanceWithMemory extends IsomorphicPerformance {\n\treadonly memory: Memory;\n}\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n * Please do not modify existing entries for backwards compatibility.\n */\nexport enum TelemetryDataTag {\n\t/** Data containing terms or IDs from code packages that may have been dynamically loaded */\n\tCodeArtifact = \"CodeArtifact\",\n\t/** Personal data of a variety of classifications that pertains to the user */\n\tUserData = \"UserData\",\n}\n\nexport type TelemetryEventPropertyTypes = TelemetryEventPropertyType | ITaggedTelemetryPropertyType;\n\nexport interface ITelemetryLoggerPropertyBag {\n\t[index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);\n}\nexport interface ITelemetryLoggerPropertyBags {\n\tall?: ITelemetryLoggerPropertyBag;\n\terror?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * Attempts to parse number from string.\n * If fails,returns original string.\n * Used to make telemetry data typed (and support math operations, like comparison),\n * in places where we do expect numbers (like contentsize/duration property in http header)\n */\nexport function numberFromString(str: string | null | undefined): string | number | undefined {\n\tif (str === undefined || str === null) {\n\t\treturn undefined;\n\t}\n\tconst num = Number(str);\n\treturn Number.isNaN(num) ? str : num;\n}\n\nexport function formatTick(tick: number): number {\n\treturn Math.floor(tick);\n}\n\nexport const eventNamespaceSeparator = \":\" as const;\n\n/**\n * TelemetryLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n *\n * @deprecated - In a subsequent release this type will no longer be exported, use ITelemetryLogger instead\n */\nexport abstract class TelemetryLogger implements ITelemetryLoggerExt {\n\tpublic static readonly eventNamespaceSeparator = eventNamespaceSeparator;\n\n\t/**\n\t * @deprecated - use formatTick\n\t */\n\tpublic static formatTick(tick: number): number {\n\t\treturn Math.floor(tick);\n\t}\n\n\t/**\n\t * Attempts to parse number from string.\n\t * If fails,returns original string.\n\t * Used to make telemetry data typed (and support math operations, like comparison),\n\t * in places where we do expect numbers (like contentsize/duration property in http header)\n\t * @deprecated - use numberFromString\n\t */\n\tpublic static numberFromString(str: string | null | undefined): string | number | undefined {\n\t\tif (str === undefined || str === null) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst num = Number(str);\n\t\treturn Number.isNaN(num) ? str : num;\n\t}\n\n\tpublic static sanitizePkgName(name: string) {\n\t\treturn name.replace(\"@\", \"\").replace(\"/\", \"-\");\n\t}\n\n\t/**\n\t * Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied\n\t * over from the error object, along with other telemetry properties if it's an ILoggingError.\n\t * @param event - Event being logged\n\t * @param error - Error to extract info from\n\t * @param fetchStack - Whether to fetch the current callstack if error.stack is undefined\n\t */\n\tpublic static prepareErrorObject(event: ITelemetryBaseEvent, error: any, fetchStack: boolean) {\n\t\tconst { message, errorType, stack } = extractLogSafeErrorProperties(\n\t\t\terror,\n\t\t\ttrue /* sanitizeStack */,\n\t\t);\n\t\t// First, copy over error message, stack, and errorType directly (overwrite if present on event)\n\t\tevent.stack = stack;\n\t\tevent.error = message; // Note that the error message goes on the 'error' field\n\t\tevent.errorType = errorType;\n\n\t\tif (isILoggingError(error)) {\n\t\t\t// Add any other telemetry properties from the LoggingError\n\t\t\tconst telemetryProp = error.getTelemetryProperties();\n\t\t\tfor (const key of Object.keys(telemetryProp)) {\n\t\t\t\tif (event[key] !== undefined) {\n\t\t\t\t\t// Don't overwrite existing properties on the event\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tevent[key] = telemetryProp[key];\n\t\t\t}\n\t\t}\n\n\t\t// Collect stack if we were not able to extract it from error\n\t\tif (event.stack === undefined && fetchStack) {\n\t\t\tevent.stack = generateStack();\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprotected readonly namespace?: string,\n\t\tprotected readonly properties?: ITelemetryLoggerPropertyBags,\n\t) {}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic abstract send(event: ITelemetryBaseEvent): void;\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: any) {\n\t\tthis.sendTelemetryEventCore({ ...event, category: event.category ?? \"generic\" }, error);\n\t}\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tprotected sendTelemetryEventCore(\n\t\tevent: ITelemetryGenericEventExt & { category: TelemetryEventCategory },\n\t\terror?: any,\n\t) {\n\t\tconst newEvent = convertToBaseEvent(event);\n\t\tif (error !== undefined) {\n\t\t\tTelemetryLogger.prepareErrorObject(newEvent, error, false);\n\t\t}\n\n\t\t// Will include Nan & Infinity, but probably we do not care\n\t\tif (typeof newEvent.duration === \"number\") {\n\t\t\tnewEvent.duration = formatTick(newEvent.duration);\n\t\t}\n\n\t\tthis.send(newEvent);\n\t}\n\n\t/**\n\t * Send an error telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: any) {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{\n\t\t\t\t// ensure the error field has some value,\n\t\t\t\t// this can and will be overridden by event, or error\n\t\t\t\terror: event.eventName,\n\t\t\t\t...event,\n\t\t\t\tcategory: \"error\",\n\t\t\t},\n\t\t\terror,\n\t\t);\n\t}\n\n\t/**\n\t * Send a performance telemetry event with the logger\n\t *\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: any): void {\n\t\tconst perfEvent = {\n\t\t\t...event,\n\t\t\tcategory: event.category ?? \"performance\",\n\t\t};\n\n\t\tthis.sendTelemetryEventCore(perfEvent, error);\n\t}\n\n\tprotected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent {\n\t\tconst includeErrorProps = event.category === \"error\" || event.error !== undefined;\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\t...event,\n\t\t};\n\t\tif (this.namespace !== undefined) {\n\t\t\tnewEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;\n\t\t}\n\t\treturn this.extendProperties(newEvent, includeErrorProps);\n\t}\n\n\tprivate extendProperties<T extends ITelemetryLoggerPropertyBag = ITelemetryLoggerPropertyBag>(\n\t\ttoExtend: T,\n\t\tincludeErrorProps: boolean,\n\t) {\n\t\tconst eventLike: ITelemetryLoggerPropertyBag = toExtend;\n\t\tif (this.properties) {\n\t\t\tconst properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];\n\t\t\tproperties.push(this.properties.all);\n\t\t\tif (includeErrorProps) {\n\t\t\t\tproperties.push(this.properties.error);\n\t\t\t}\n\t\t\tfor (const props of properties) {\n\t\t\t\tif (props !== undefined) {\n\t\t\t\t\tfor (const key of Object.keys(props)) {\n\t\t\t\t\t\tif (eventLike[key] !== undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst getterOrValue = props[key];\n\t\t\t\t\t\t// If this throws, hopefully it is handled elsewhere\n\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\ttypeof getterOrValue === \"function\" ? getterOrValue() : getterOrValue;\n\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\teventLike[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn toExtend;\n\t}\n}\n\n/**\n * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from\n * container-runtime. Issue: #8191\n * TaggedLoggerAdapter class can add tag handling to your logger.\n */\nexport class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n\tpublic constructor(private readonly logger: ITelemetryBaseLogger) {}\n\n\tpublic send(eventWithTagsMaybe: ITelemetryBaseEvent) {\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\tcategory: eventWithTagsMaybe.category,\n\t\t\teventName: eventWithTagsMaybe.eventName,\n\t\t};\n\t\tfor (const key of Object.keys(eventWithTagsMaybe)) {\n\t\t\tconst taggableProp = eventWithTagsMaybe[key];\n\t\t\tconst { value, tag } =\n\t\t\t\ttypeof taggableProp === \"object\"\n\t\t\t\t\t? taggableProp\n\t\t\t\t\t: { value: taggableProp, tag: undefined };\n\t\t\tswitch (tag) {\n\t\t\t\tcase undefined:\n\t\t\t\t\t// No tag means we can log plainly\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"PackageData\": // For back-compat\n\t\t\t\tcase TelemetryDataTag.CodeArtifact:\n\t\t\t\t\t// For Microsoft applications, CodeArtifact is safe for now\n\t\t\t\t\t// (we don't load 3P code in 1P apps)\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase TelemetryDataTag.UserData:\n\t\t\t\t\t// Strip out anything tagged explicitly as UserData.\n\t\t\t\t\t// Alternate strategy would be to hash these props\n\t\t\t\t\tnewEvent[key] = \"REDACTED (UserData)\";\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// If we encounter a tag we don't recognize\n\t\t\t\t\t// then we must assume we should scrub.\n\t\t\t\t\tnewEvent[key] = \"REDACTED (unknown tag)\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tthis.logger.send(newEvent);\n\t}\n}\n\n/**\n * Create a child logger based on the provided props object\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 * @remarks\n * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.\n */\nexport function createChildLogger(props?: {\n\tlogger?: ITelemetryBaseLogger;\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n}): ITelemetryLoggerExt {\n\tif (props === undefined) {\n\t\treturn new TelemetryNullLogger();\n\t}\n\treturn ChildLogger.create(props?.logger, props?.namespace, props?.properties);\n}\n\n/**\n * ChildLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n * @deprecated - Use createChildLogger instead\n */\nexport class ChildLogger extends TelemetryLogger {\n\t/**\n\t * Create child logger\n\t * @param baseLogger - Base logger to use to output events. If undefined, proper child logger\n\t * is created, but it does not send telemetry events anywhere.\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t */\n\tpublic static create(\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// if we are creating a child of a child, rather than nest, which will increase\n\t\t// the callstack overhead, just generate a new logger that includes everything from the previous\n\t\tif (baseLogger instanceof ChildLogger) {\n\t\t\tconst combinedProperties: ITelemetryLoggerPropertyBags = {};\n\t\t\tfor (const extendedProps of [baseLogger.properties, properties]) {\n\t\t\t\tif (extendedProps !== undefined) {\n\t\t\t\t\tif (extendedProps.all !== undefined) {\n\t\t\t\t\t\tcombinedProperties.all = {\n\t\t\t\t\t\t\t...combinedProperties.all,\n\t\t\t\t\t\t\t...extendedProps.all,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (extendedProps.error !== undefined) {\n\t\t\t\t\t\tcombinedProperties.error = {\n\t\t\t\t\t\t\t...combinedProperties.error,\n\t\t\t\t\t\t\t...extendedProps.error,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst combinedNamespace =\n\t\t\t\tbaseLogger.namespace === undefined\n\t\t\t\t\t? namespace\n\t\t\t\t\t: namespace === undefined\n\t\t\t\t\t? baseLogger.namespace\n\t\t\t\t\t: `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;\n\n\t\t\treturn new ChildLogger(baseLogger.baseLogger, combinedNamespace, combinedProperties);\n\t\t}\n\n\t\treturn new ChildLogger(\n\t\t\tbaseLogger ? baseLogger : new BaseTelemetryNullLogger(),\n\t\t\tnamespace,\n\t\t\tproperties,\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tprotected readonly baseLogger: ITelemetryBaseLogger,\n\t\tnamespace: string | undefined,\n\t\tproperties: ITelemetryLoggerPropertyBags | undefined,\n\t) {\n\t\tsuper(namespace, properties);\n\n\t\t// propagate the monitoring context\n\t\tif (loggerIsMonitoringContext(baseLogger)) {\n\t\t\tmixinMonitoringContext(this, new CachedConfigProvider(this, baseLogger.config));\n\t\t}\n\t}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tthis.baseLogger.send(this.prepareEvent(event));\n\t}\n}\n\n/**\n * Create a logger which logs to multiple other loggers based on the provided props object\n * @param props - loggers are the base loggers that will logged to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.\n * tryInheritProperties will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n */\nexport function createMultiSinkLogger(props: {\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n\tloggers?: (ITelemetryBaseLogger | undefined)[];\n\ttryInheritProperties?: true;\n}): ITelemetryLoggerExt {\n\treturn new MultiSinkLogger(\n\t\tprops.namespace,\n\t\tprops.properties,\n\t\tprops.loggers?.filter((l): l is ITelemetryBaseLogger => l !== undefined),\n\t\tprops.tryInheritProperties,\n\t);\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n * @deprecated - use createMultiSinkLogger instead\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n\tprotected loggers: ITelemetryBaseLogger[];\n\t/**\n\t * Create multiple sink logger (i.e. logger that sends events to multiple sinks)\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param loggers - The list of loggers to use as sinks\n\t * @param tryInheritProperties - Will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n\t */\n\tconstructor(\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t\tloggers: ITelemetryBaseLogger[] = [],\n\t\ttryInheritProperties?: true,\n\t) {\n\t\tlet realProperties = properties !== undefined ? { ...properties } : undefined;\n\t\tif (tryInheritProperties === true) {\n\t\t\tconst merge = (realProperties ??= {});\n\t\t\tloggers\n\t\t\t\t.filter((l): l is this => l instanceof TelemetryLogger)\n\t\t\t\t.map((l) => l.properties ?? {})\n\t\t\t\t.forEach((cv) => {\n\t\t\t\t\tObject.keys(cv).forEach((k) => {\n\t\t\t\t\t\tmerge[k] = { ...cv[k], ...merge?.[k] };\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\n\t\tsuper(namespace, realProperties);\n\t\tthis.loggers = loggers;\n\t}\n\n\t/**\n\t * Add logger to send all events to\n\t * @param logger - Logger to add\n\t */\n\tpublic addLogger(logger?: ITelemetryBaseLogger) {\n\t\tif (logger !== undefined && logger !== null) {\n\t\t\tthis.loggers.push(logger);\n\t\t}\n\t}\n\n\t/**\n\t * Send an event to the loggers\n\t *\n\t * @param event - the event to send to all the registered logger\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tconst newEvent = this.prepareEvent(event);\n\t\tthis.loggers.forEach((logger: ITelemetryBaseLogger) => {\n\t\t\tlogger.send(newEvent);\n\t\t});\n\t}\n}\n\n/**\n * Describes what events PerformanceEvent should log\n * By default, all events are logged, but client can override this behavior\n * For example, there is rarely a need to record start event, as we really after\n * success / failure tracking, including duration (on success).\n */\nexport interface IPerformanceEventMarkers {\n\tstart?: true;\n\tend?: true;\n\tcancel?: \"generic\" | \"error\"; // tells wether to issue \"generic\" or \"error\" category cancel event\n}\n\n/**\n * Helper class to log performance events\n */\nexport class PerformanceEvent {\n\tpublic static start(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\trecordHeapSize: boolean = false,\n\t) {\n\t\treturn new PerformanceEvent(logger, event, markers, recordHeapSize);\n\t}\n\n\tpublic static timedExec<T>(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tcallback: (event: PerformanceEvent) => T,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t) {\n\t\tconst perfEvent = PerformanceEvent.start(logger, event, markers);\n\t\ttry {\n\t\t\tconst ret = callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic static async timedExecAsync<T>(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tcallback: (event: PerformanceEvent) => Promise<T>,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\trecordHeapSize?: boolean,\n\t) {\n\t\tconst perfEvent = PerformanceEvent.start(logger, event, markers, recordHeapSize);\n\t\ttry {\n\t\t\tconst ret = await callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic get duration() {\n\t\treturn performance.now() - this.startTime;\n\t}\n\n\tprivate event?: ITelemetryGenericEvent;\n\tprivate readonly startTime = performance.now();\n\tprivate startMark?: string;\n\tprivate startMemoryCollection: number | undefined = 0;\n\n\tprotected constructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tprivate readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n\t\tprivate readonly recordHeapSize: boolean = false,\n\t) {\n\t\tthis.event = { ...event };\n\t\tif (this.markers.start) {\n\t\t\tthis.reportEvent(\"start\");\n\t\t}\n\n\t\tif (typeof window === \"object\" && window != null && window.performance?.mark) {\n\t\t\tthis.startMark = `${event.eventName}-start`;\n\t\t\twindow.performance.mark(this.startMark);\n\t\t}\n\t}\n\n\tpublic reportProgress(props?: ITelemetryProperties, eventNameSuffix: string = \"update\"): void {\n\t\tthis.reportEvent(eventNameSuffix, props);\n\t}\n\n\tprivate autoEnd() {\n\t\t// Event might have been cancelled or ended in the callback\n\t\tif (this.event && this.markers.end) {\n\t\t\tthis.reportEvent(\"end\");\n\t\t}\n\t\tthis.performanceEndMark();\n\t\tthis.event = undefined;\n\t}\n\n\tpublic end(props?: ITelemetryProperties): void {\n\t\tthis.reportEvent(\"end\", props);\n\t\tthis.performanceEndMark();\n\t\tthis.event = undefined;\n\t}\n\n\tprivate performanceEndMark() {\n\t\tif (this.startMark && this.event) {\n\t\t\tconst endMark = `${this.event.eventName}-end`;\n\t\t\twindow.performance.mark(endMark);\n\t\t\twindow.performance.measure(`${this.event.eventName}`, this.startMark, endMark);\n\t\t\tthis.startMark = undefined;\n\t\t}\n\t}\n\n\tpublic cancel(props?: ITelemetryProperties, error?: any): void {\n\t\tif (this.markers.cancel !== undefined) {\n\t\t\tthis.reportEvent(\"cancel\", { category: this.markers.cancel, ...props }, error);\n\t\t}\n\t\tthis.event = undefined;\n\t}\n\n\t/**\n\t * Report the event, if it hasn't already been reported.\n\t */\n\tpublic reportEvent(eventNameSuffix: string, props?: ITelemetryProperties, error?: any) {\n\t\t// There are strange sequences involving multiple Promise chains\n\t\t// where the event can be cancelled and then later a callback is invoked\n\t\t// and the caller attempts to end directly, e.g. issue #3936. Just return.\n\t\tif (!this.event) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst event: ITelemetryPerformanceEvent = { ...this.event, ...props };\n\t\tevent.eventName = `${event.eventName}_${eventNameSuffix}`;\n\t\tif (eventNameSuffix !== \"start\") {\n\t\t\tevent.duration = this.duration;\n\t\t\tif (this.startMemoryCollection) {\n\t\t\t\tconst currentMemory = (performance as PerformanceWithMemory)?.memory\n\t\t\t\t\t?.usedJSHeapSize;\n\t\t\t\tconst differenceInKBytes = Math.floor(\n\t\t\t\t\t(currentMemory - this.startMemoryCollection) / 1024,\n\t\t\t\t);\n\t\t\t\tif (differenceInKBytes > 0) {\n\t\t\t\t\tevent.usedJSHeapSize = differenceInKBytes;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.recordHeapSize) {\n\t\t\tthis.startMemoryCollection = (\n\t\t\t\tperformance as PerformanceWithMemory\n\t\t\t)?.memory?.usedJSHeapSize;\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(event, error);\n\t}\n}\n\n/**\n * Logger that is useful for UT\n * It can be used in places where logger instance is required, but events should be not send over.\n * @deprecated - Use createChildLogger instead\n */\nexport class TelemetryUTLogger implements ITelemetryLoggerExt {\n\tpublic send(event: ITelemetryBaseEvent): void {}\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any) {}\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: any) {\n\t\tthis.reportError(\"errorEvent in UT logger!\", event, error);\n\t}\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void {}\n\tpublic logGenericError(eventName: string, error: any) {\n\t\tthis.reportError(`genericError in UT logger!`, { eventName }, error);\n\t}\n\tpublic logException(event: ITelemetryErrorEvent, exception: any): void {\n\t\tthis.reportError(\"exception in UT logger!\", event, exception);\n\t}\n\tpublic debugAssert(condition: boolean, event?: ITelemetryErrorEvent): void {\n\t\tthis.reportError(\"debugAssert in UT logger!\");\n\t}\n\tpublic shipAssert(condition: boolean, event?: ITelemetryErrorEvent): void {\n\t\tthis.reportError(\"shipAssert in UT logger!\");\n\t}\n\n\tprivate reportError(message: string, event?: ITelemetryErrorEvent, err?: any) {\n\t\tconst error = new Error(message);\n\t\t(error as any).error = error;\n\t\t(error as any).event = event;\n\t\t// report to console as exception can be eaten\n\t\tconsole.error(message);\n\t\tconsole.error(error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Null logger\n * It can be used in places where logger instance is required, but events should be not send over.\n * @deprecated - for internal use only\n */\nexport class BaseTelemetryNullLogger implements ITelemetryBaseLogger {\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\treturn;\n\t}\n}\n\n/**\n * Null logger\n * It can be used in places where logger instance is required, but events should be not send over.\n * @deprecated - for internal use only\n */\nexport class TelemetryNullLogger implements ITelemetryLoggerExt {\n\tpublic send(event: ITelemetryBaseEvent): void {}\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void {}\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void {}\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void {}\n}\n\n/**\n * Takes in an event object, and converts all of its values to a basePropertyType.\n * In the case of an invalid property type, the value will be converted to an error string.\n * @param event - Event with fields you want to stringify.\n */\nfunction convertToBaseEvent({\n\tcategory,\n\teventName,\n\t...props\n}: ITelemetryEventExt): ITelemetryBaseEvent {\n\tconst newEvent: ITelemetryBaseEvent = { category, eventName };\n\tfor (const key of Object.keys(props)) {\n\t\tnewEvent[key] = convertToBasePropertyType(props[key]);\n\t}\n\treturn newEvent;\n}\n\n/**\n * Takes in value, and does one of 4 things.\n * if value is of primitive type - returns the original value.\n * If the value is an array of primitives - returns a stringified version of the array.\n * If the value is an object of type ITaggedTelemetryPropertyType - returns the object\n * with its values recursively converted to base property Type.\n * If none of these cases are reached - returns an error string\n * @param x - value passed in to convert to a base property type\n */\nexport function convertToBasePropertyType(\n\tx: TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt,\n): TelemetryEventPropertyType | ITaggedTelemetryPropertyType {\n\treturn isTaggedTelemetryPropertyValue(x)\n\t\t? {\n\t\t\t\tvalue: convertToBasePropertyTypeUntagged(x.value),\n\t\t\t\ttag: x.tag,\n\t\t }\n\t\t: convertToBasePropertyTypeUntagged(x);\n}\n\nfunction convertToBasePropertyTypeUntagged(\n\tx: TelemetryEventPropertyTypeExt,\n): TelemetryEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\":\n\t\t\treturn x;\n\t\tcase \"object\":\n\t\t\t// We assume this is an array or flat object based on the input types\n\t\t\treturn JSON.stringify(x);\n\t\tdefault:\n\t\t\t// should never reach this case based on the input types\n\t\t\tconsole.error(\n\t\t\t\t`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`,\n\t\t\t);\n\t\t\treturn `INVALID PROPERTY (typed as ${typeof x})`;\n\t}\n}\n\nexport const tagData = <\n\tT extends TelemetryDataTag,\n\tV extends Record<string, TelemetryEventPropertyTypeExt>,\n>(\n\ttag: T,\n\tvalues: V,\n) =>\n\t(Object.entries(values) as [keyof V, V[keyof V]][])\n\t\t.filter((e): e is [keyof V, Exclude<V[keyof V], undefined>] => e[1] !== undefined)\n\t\t.reduce<{\n\t\t\t[P in keyof V]:\n\t\t\t\t| (V[P] extends undefined ? undefined : never)\n\t\t\t\t| { value: Exclude<V[P], undefined>; tag: T };\n\t\t}>((pv, cv) => {\n\t\t\tpv[cv[0]] = { tag, value: cv[1] };\n\t\t\treturn pv;\n\t\t}, {} as any);\n\nexport const tagCodeArtifacts = <T extends Record<string, TelemetryEventPropertyTypeExt>>(\n\tvalues: T,\n) => tagData(TelemetryDataTag.CodeArtifact, values);\n"]}
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAaH,+DAAkF;AAClF,qCAAmG;AACnG,iDAKwB;AAiBxB;;;GAGG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,4FAA4F;IAC5F,iDAA6B,CAAA;IAC7B,8EAA8E;IAC9E,yCAAqB,CAAA;AACtB,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAYD;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,GAA8B;IAC9D,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE;QACtC,OAAO,SAAS,CAAC;KACjB;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACtC,CAAC;AAND,4CAMC;AAED,SAAgB,UAAU,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAFD,gCAEC;AAEY,QAAA,uBAAuB,GAAG,GAAY,CAAC;AAEpD;;;;;GAKG;AACH,MAAsB,eAAe;IA0CpC,YACoB,SAAkB,EAClB,UAAyC;QADzC,cAAS,GAAT,SAAS,CAAS;QAClB,eAAU,GAAV,UAAU,CAA+B;IAC1D,CAAC;IA1CG,MAAM,CAAC,eAAe,CAAC,IAAY;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EA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K,SAAS,CAAC;QACf,KAAK,WAAW;YACf,OAAO,CAAC,CAAC;QACV,KAAK,QAAQ;YACZ,qEAAqE;YACrE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1B;YACC,wDAAwD;YACxD,OAAO,CAAC,KAAK,CACZ,iEAAiE,OAAO,CAAC,GAAG,CAC5E,CAAC;YACF,OAAO,8BAA8B,OAAO,CAAC,GAAG,CAAC;KAClD;AACF,CAAC;AAEM,MAAM,OAAO,GAAG,CAItB,GAAM,EACN,MAAS,EACR,EAAE,CACF,MAAM,CAAC,OAAO,CAAC,MAAM,CAA6B;KACjD,MAAM,CAAC,CAAC,CAAC,EAAkD,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;KACjF,MAAM,CAIJ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IACb,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAClC,OAAO,EAAE,CAAC;AACX,CAAC,EAAE,EAAS,CAAC,CAAC;AAhBH,QAAA,OAAO,WAgBJ;AAET,MAAM,gBAAgB,GAAG,CAC/B,MAAS,EACR,EAAE,CAAC,IAAA,eAAO,EAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAFvC,QAAA,gBAAgB,oBAEuB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryErrorEvent,\n\tITelemetryGenericEvent,\n\tITelemetryPerformanceEvent,\n\tITelemetryProperties,\n\tTelemetryEventPropertyType,\n\tITaggedTelemetryPropertyType,\n\tTelemetryEventCategory,\n} from \"@fluidframework/core-interfaces\";\nimport { IsomorphicPerformance, performance } from \"@fluidframework/common-utils\";\nimport { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext } from \"./config\";\nimport {\n\tisILoggingError,\n\textractLogSafeErrorProperties,\n\tgenerateStack,\n\tisTaggedTelemetryPropertyValue,\n} from \"./errorLogging\";\nimport {\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes\";\n\nexport interface Memory {\n\tusedJSHeapSize: number;\n}\n\nexport interface PerformanceWithMemory extends IsomorphicPerformance {\n\treadonly memory: Memory;\n}\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n * Please do not modify existing entries for backwards compatibility.\n */\nexport enum TelemetryDataTag {\n\t/** Data containing terms or IDs from code packages that may have been dynamically loaded */\n\tCodeArtifact = \"CodeArtifact\",\n\t/** Personal data of a variety of classifications that pertains to the user */\n\tUserData = \"UserData\",\n}\n\nexport type TelemetryEventPropertyTypes = TelemetryEventPropertyType | ITaggedTelemetryPropertyType;\n\nexport interface ITelemetryLoggerPropertyBag {\n\t[index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);\n}\nexport interface ITelemetryLoggerPropertyBags {\n\tall?: ITelemetryLoggerPropertyBag;\n\terror?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * Attempts to parse number from string.\n * If fails,returns original string.\n * Used to make telemetry data typed (and support math operations, like comparison),\n * in places where we do expect numbers (like contentsize/duration property in http header)\n */\nexport function numberFromString(str: string | null | undefined): string | number | undefined {\n\tif (str === undefined || str === null) {\n\t\treturn undefined;\n\t}\n\tconst num = Number(str);\n\treturn Number.isNaN(num) ? str : num;\n}\n\nexport function formatTick(tick: number): number {\n\treturn Math.floor(tick);\n}\n\nexport const eventNamespaceSeparator = \":\" as const;\n\n/**\n * TelemetryLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n *\n */\nexport abstract class TelemetryLogger implements ITelemetryLoggerExt {\n\tpublic static readonly eventNamespaceSeparator = eventNamespaceSeparator;\n\n\tpublic static sanitizePkgName(name: string) {\n\t\treturn name.replace(\"@\", \"\").replace(\"/\", \"-\");\n\t}\n\n\t/**\n\t * Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied\n\t * over from the error object, along with other telemetry properties if it's an ILoggingError.\n\t * @param event - Event being logged\n\t * @param error - Error to extract info from\n\t * @param fetchStack - Whether to fetch the current callstack if error.stack is undefined\n\t */\n\tpublic static prepareErrorObject(event: ITelemetryBaseEvent, error: any, fetchStack: boolean) {\n\t\tconst { message, errorType, stack } = extractLogSafeErrorProperties(\n\t\t\terror,\n\t\t\ttrue /* sanitizeStack */,\n\t\t);\n\t\t// First, copy over error message, stack, and errorType directly (overwrite if present on event)\n\t\tevent.stack = stack;\n\t\tevent.error = message; // Note that the error message goes on the 'error' field\n\t\tevent.errorType = errorType;\n\n\t\tif (isILoggingError(error)) {\n\t\t\t// Add any other telemetry properties from the LoggingError\n\t\t\tconst telemetryProp = error.getTelemetryProperties();\n\t\t\tfor (const key of Object.keys(telemetryProp)) {\n\t\t\t\tif (event[key] !== undefined) {\n\t\t\t\t\t// Don't overwrite existing properties on the event\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tevent[key] = telemetryProp[key];\n\t\t\t}\n\t\t}\n\n\t\t// Collect stack if we were not able to extract it from error\n\t\tif (event.stack === undefined && fetchStack) {\n\t\t\tevent.stack = generateStack();\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprotected readonly namespace?: string,\n\t\tprotected readonly properties?: ITelemetryLoggerPropertyBags,\n\t) {}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic abstract send(event: ITelemetryBaseEvent): void;\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: any) {\n\t\tthis.sendTelemetryEventCore({ ...event, category: event.category ?? \"generic\" }, error);\n\t}\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tprotected sendTelemetryEventCore(\n\t\tevent: ITelemetryGenericEventExt & { category: TelemetryEventCategory },\n\t\terror?: any,\n\t) {\n\t\tconst newEvent = convertToBaseEvent(event);\n\t\tif (error !== undefined) {\n\t\t\tTelemetryLogger.prepareErrorObject(newEvent, error, false);\n\t\t}\n\n\t\t// Will include Nan & Infinity, but probably we do not care\n\t\tif (typeof newEvent.duration === \"number\") {\n\t\t\tnewEvent.duration = formatTick(newEvent.duration);\n\t\t}\n\n\t\tthis.send(newEvent);\n\t}\n\n\t/**\n\t * Send an error telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: any) {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{\n\t\t\t\t// ensure the error field has some value,\n\t\t\t\t// this can and will be overridden by event, or error\n\t\t\t\terror: event.eventName,\n\t\t\t\t...event,\n\t\t\t\tcategory: \"error\",\n\t\t\t},\n\t\t\terror,\n\t\t);\n\t}\n\n\t/**\n\t * Send a performance telemetry event with the logger\n\t *\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: any): void {\n\t\tconst perfEvent = {\n\t\t\t...event,\n\t\t\tcategory: event.category ?? \"performance\",\n\t\t};\n\n\t\tthis.sendTelemetryEventCore(perfEvent, error);\n\t}\n\n\tprotected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent {\n\t\tconst includeErrorProps = event.category === \"error\" || event.error !== undefined;\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\t...event,\n\t\t};\n\t\tif (this.namespace !== undefined) {\n\t\t\tnewEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;\n\t\t}\n\t\treturn this.extendProperties(newEvent, includeErrorProps);\n\t}\n\n\tprivate extendProperties<T extends ITelemetryLoggerPropertyBag = ITelemetryLoggerPropertyBag>(\n\t\ttoExtend: T,\n\t\tincludeErrorProps: boolean,\n\t) {\n\t\tconst eventLike: ITelemetryLoggerPropertyBag = toExtend;\n\t\tif (this.properties) {\n\t\t\tconst properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];\n\t\t\tproperties.push(this.properties.all);\n\t\t\tif (includeErrorProps) {\n\t\t\t\tproperties.push(this.properties.error);\n\t\t\t}\n\t\t\tfor (const props of properties) {\n\t\t\t\tif (props !== undefined) {\n\t\t\t\t\tfor (const key of Object.keys(props)) {\n\t\t\t\t\t\tif (eventLike[key] !== undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst getterOrValue = props[key];\n\t\t\t\t\t\t// If this throws, hopefully it is handled elsewhere\n\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\ttypeof getterOrValue === \"function\" ? getterOrValue() : getterOrValue;\n\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\teventLike[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn toExtend;\n\t}\n}\n\n/**\n * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from\n * container-runtime. Issue: #8191\n * TaggedLoggerAdapter class can add tag handling to your logger.\n */\nexport class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n\tpublic constructor(private readonly logger: ITelemetryBaseLogger) {}\n\n\tpublic send(eventWithTagsMaybe: ITelemetryBaseEvent) {\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\tcategory: eventWithTagsMaybe.category,\n\t\t\teventName: eventWithTagsMaybe.eventName,\n\t\t};\n\t\tfor (const key of Object.keys(eventWithTagsMaybe)) {\n\t\t\tconst taggableProp = eventWithTagsMaybe[key];\n\t\t\tconst { value, tag } =\n\t\t\t\ttypeof taggableProp === \"object\"\n\t\t\t\t\t? taggableProp\n\t\t\t\t\t: { value: taggableProp, tag: undefined };\n\t\t\tswitch (tag) {\n\t\t\t\tcase undefined:\n\t\t\t\t\t// No tag means we can log plainly\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"PackageData\": // For back-compat\n\t\t\t\tcase TelemetryDataTag.CodeArtifact:\n\t\t\t\t\t// For Microsoft applications, CodeArtifact is safe for now\n\t\t\t\t\t// (we don't load 3P code in 1P apps)\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase TelemetryDataTag.UserData:\n\t\t\t\t\t// Strip out anything tagged explicitly as UserData.\n\t\t\t\t\t// Alternate strategy would be to hash these props\n\t\t\t\t\tnewEvent[key] = \"REDACTED (UserData)\";\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// If we encounter a tag we don't recognize\n\t\t\t\t\t// then we must assume we should scrub.\n\t\t\t\t\tnewEvent[key] = \"REDACTED (unknown tag)\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tthis.logger.send(newEvent);\n\t}\n}\n\n/**\n * Create a child logger based on the provided props object\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 * @remarks\n * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.\n */\nexport function createChildLogger(props?: {\n\tlogger?: ITelemetryBaseLogger;\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n}): ITelemetryLoggerExt {\n\treturn ChildLogger.create(props?.logger, props?.namespace, props?.properties);\n}\n\n/**\n * ChildLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport class ChildLogger extends TelemetryLogger {\n\t/**\n\t * Create child logger\n\t * @param baseLogger - Base logger to use to output events. If undefined, proper child logger\n\t * is created, but it does not send telemetry events anywhere.\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t */\n\tpublic static create(\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// if we are creating a child of a child, rather than nest, which will increase\n\t\t// the callstack overhead, just generate a new logger that includes everything from the previous\n\t\tif (baseLogger instanceof ChildLogger) {\n\t\t\tconst combinedProperties: ITelemetryLoggerPropertyBags = {};\n\t\t\tfor (const extendedProps of [baseLogger.properties, properties]) {\n\t\t\t\tif (extendedProps !== undefined) {\n\t\t\t\t\tif (extendedProps.all !== undefined) {\n\t\t\t\t\t\tcombinedProperties.all = {\n\t\t\t\t\t\t\t...combinedProperties.all,\n\t\t\t\t\t\t\t...extendedProps.all,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (extendedProps.error !== undefined) {\n\t\t\t\t\t\tcombinedProperties.error = {\n\t\t\t\t\t\t\t...combinedProperties.error,\n\t\t\t\t\t\t\t...extendedProps.error,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst combinedNamespace =\n\t\t\t\tbaseLogger.namespace === undefined\n\t\t\t\t\t? namespace\n\t\t\t\t\t: namespace === undefined\n\t\t\t\t\t? baseLogger.namespace\n\t\t\t\t\t: `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;\n\n\t\t\tconst child = new ChildLogger(\n\t\t\t\tbaseLogger.baseLogger,\n\t\t\t\tcombinedNamespace,\n\t\t\t\tcombinedProperties,\n\t\t\t);\n\n\t\t\tif (!loggerIsMonitoringContext(child) && loggerIsMonitoringContext(baseLogger)) {\n\t\t\t\tmixinMonitoringContext(child, baseLogger.config);\n\t\t\t}\n\t\t\treturn child;\n\t\t}\n\n\t\treturn new ChildLogger(baseLogger ? baseLogger : { send() {} }, namespace, properties);\n\t}\n\n\tprivate constructor(\n\t\tprotected readonly baseLogger: ITelemetryBaseLogger,\n\t\tnamespace: string | undefined,\n\t\tproperties: ITelemetryLoggerPropertyBags | undefined,\n\t) {\n\t\tsuper(namespace, properties);\n\n\t\t// propagate the monitoring context\n\t\tif (loggerIsMonitoringContext(baseLogger)) {\n\t\t\tmixinMonitoringContext(this, new CachedConfigProvider(this, baseLogger.config));\n\t\t}\n\t}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tthis.baseLogger.send(this.prepareEvent(event));\n\t}\n}\n\n/**\n * Create a logger which logs to multiple other loggers based on the provided props object\n * @param props - loggers are the base loggers that will logged to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.\n * tryInheritProperties will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n */\nexport function createMultiSinkLogger(props: {\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n\tloggers?: (ITelemetryBaseLogger | undefined)[];\n\ttryInheritProperties?: true;\n}): ITelemetryLoggerExt {\n\treturn new MultiSinkLogger(\n\t\tprops.namespace,\n\t\tprops.properties,\n\t\tprops.loggers?.filter((l): l is ITelemetryBaseLogger => l !== undefined),\n\t\tprops.tryInheritProperties,\n\t);\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n\tprotected loggers: ITelemetryBaseLogger[];\n\t/**\n\t * Create multiple sink logger (i.e. logger that sends events to multiple sinks)\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param loggers - The list of loggers to use as sinks\n\t * @param tryInheritProperties - Will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n\t */\n\tconstructor(\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t\tloggers: ITelemetryBaseLogger[] = [],\n\t\ttryInheritProperties?: true,\n\t) {\n\t\tlet realProperties = properties !== undefined ? { ...properties } : undefined;\n\t\tif (tryInheritProperties === true) {\n\t\t\tconst merge = (realProperties ??= {});\n\t\t\tloggers\n\t\t\t\t.filter((l): l is this => l instanceof TelemetryLogger)\n\t\t\t\t.map((l) => l.properties ?? {})\n\t\t\t\t.forEach((cv) => {\n\t\t\t\t\tObject.keys(cv).forEach((k) => {\n\t\t\t\t\t\tmerge[k] = { ...cv[k], ...merge?.[k] };\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\n\t\tsuper(namespace, realProperties);\n\t\tthis.loggers = loggers;\n\t}\n\n\t/**\n\t * Add logger to send all events to\n\t * @param logger - Logger to add\n\t */\n\tpublic addLogger(logger?: ITelemetryBaseLogger) {\n\t\tif (logger !== undefined && logger !== null) {\n\t\t\tthis.loggers.push(logger);\n\t\t}\n\t}\n\n\t/**\n\t * Send an event to the loggers\n\t *\n\t * @param event - the event to send to all the registered logger\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tconst newEvent = this.prepareEvent(event);\n\t\tthis.loggers.forEach((logger: ITelemetryBaseLogger) => {\n\t\t\tlogger.send(newEvent);\n\t\t});\n\t}\n}\n\n/**\n * Describes what events PerformanceEvent should log\n * By default, all events are logged, but client can override this behavior\n * For example, there is rarely a need to record start event, as we really after\n * success / failure tracking, including duration (on success).\n */\nexport interface IPerformanceEventMarkers {\n\tstart?: true;\n\tend?: true;\n\tcancel?: \"generic\" | \"error\"; // tells wether to issue \"generic\" or \"error\" category cancel event\n}\n\n/**\n * Helper class to log performance events\n */\nexport class PerformanceEvent {\n\tpublic static start(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\trecordHeapSize: boolean = false,\n\t) {\n\t\treturn new PerformanceEvent(logger, event, markers, recordHeapSize);\n\t}\n\n\tpublic static timedExec<T>(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tcallback: (event: PerformanceEvent) => T,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t) {\n\t\tconst perfEvent = PerformanceEvent.start(logger, event, markers);\n\t\ttry {\n\t\t\tconst ret = callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic static async timedExecAsync<T>(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tcallback: (event: PerformanceEvent) => Promise<T>,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\trecordHeapSize?: boolean,\n\t) {\n\t\tconst perfEvent = PerformanceEvent.start(logger, event, markers, recordHeapSize);\n\t\ttry {\n\t\t\tconst ret = await callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic get duration() {\n\t\treturn performance.now() - this.startTime;\n\t}\n\n\tprivate event?: ITelemetryGenericEvent;\n\tprivate readonly startTime = performance.now();\n\tprivate startMark?: string;\n\tprivate startMemoryCollection: number | undefined = 0;\n\n\tprotected constructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tprivate readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n\t\tprivate readonly recordHeapSize: boolean = false,\n\t) {\n\t\tthis.event = { ...event };\n\t\tif (this.markers.start) {\n\t\t\tthis.reportEvent(\"start\");\n\t\t}\n\n\t\tif (typeof window === \"object\" && window != null && window.performance?.mark) {\n\t\t\tthis.startMark = `${event.eventName}-start`;\n\t\t\twindow.performance.mark(this.startMark);\n\t\t}\n\t}\n\n\tpublic reportProgress(props?: ITelemetryProperties, eventNameSuffix: string = \"update\"): void {\n\t\tthis.reportEvent(eventNameSuffix, props);\n\t}\n\n\tprivate autoEnd() {\n\t\t// Event might have been cancelled or ended in the callback\n\t\tif (this.event && this.markers.end) {\n\t\t\tthis.reportEvent(\"end\");\n\t\t}\n\t\tthis.performanceEndMark();\n\t\tthis.event = undefined;\n\t}\n\n\tpublic end(props?: ITelemetryProperties): void {\n\t\tthis.reportEvent(\"end\", props);\n\t\tthis.performanceEndMark();\n\t\tthis.event = undefined;\n\t}\n\n\tprivate performanceEndMark() {\n\t\tif (this.startMark && this.event) {\n\t\t\tconst endMark = `${this.event.eventName}-end`;\n\t\t\twindow.performance.mark(endMark);\n\t\t\twindow.performance.measure(`${this.event.eventName}`, this.startMark, endMark);\n\t\t\tthis.startMark = undefined;\n\t\t}\n\t}\n\n\tpublic cancel(props?: ITelemetryProperties, error?: any): void {\n\t\tif (this.markers.cancel !== undefined) {\n\t\t\tthis.reportEvent(\"cancel\", { category: this.markers.cancel, ...props }, error);\n\t\t}\n\t\tthis.event = undefined;\n\t}\n\n\t/**\n\t * Report the event, if it hasn't already been reported.\n\t */\n\tpublic reportEvent(eventNameSuffix: string, props?: ITelemetryProperties, error?: any) {\n\t\t// There are strange sequences involving multiple Promise chains\n\t\t// where the event can be cancelled and then later a callback is invoked\n\t\t// and the caller attempts to end directly, e.g. issue #3936. Just return.\n\t\tif (!this.event) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst event: ITelemetryPerformanceEvent = { ...this.event, ...props };\n\t\tevent.eventName = `${event.eventName}_${eventNameSuffix}`;\n\t\tif (eventNameSuffix !== \"start\") {\n\t\t\tevent.duration = this.duration;\n\t\t\tif (this.startMemoryCollection) {\n\t\t\t\tconst currentMemory = (performance as PerformanceWithMemory)?.memory\n\t\t\t\t\t?.usedJSHeapSize;\n\t\t\t\tconst differenceInKBytes = Math.floor(\n\t\t\t\t\t(currentMemory - this.startMemoryCollection) / 1024,\n\t\t\t\t);\n\t\t\t\tif (differenceInKBytes > 0) {\n\t\t\t\t\tevent.usedJSHeapSize = differenceInKBytes;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.recordHeapSize) {\n\t\t\tthis.startMemoryCollection = (\n\t\t\t\tperformance as PerformanceWithMemory\n\t\t\t)?.memory?.usedJSHeapSize;\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(event, error);\n\t}\n}\n\n/**\n * Null logger that no-ops for all telemetry events passed to it.\n * @deprecated - This will be removed in a future release.\n * For internal use within the FluidFramework codebase, use {@link createChildLogger} with no arguments instead.\n * For external consumers we recommend writing a trivial implementation of {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}\n * where the send() method does nothing and using that.\n */\nexport class TelemetryNullLogger implements ITelemetryLoggerExt {\n\tpublic send(event: ITelemetryBaseEvent): void {}\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void {}\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void {}\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void {}\n}\n\n/**\n * Takes in an event object, and converts all of its values to a basePropertyType.\n * In the case of an invalid property type, the value will be converted to an error string.\n * @param event - Event with fields you want to stringify.\n */\nfunction convertToBaseEvent({\n\tcategory,\n\teventName,\n\t...props\n}: ITelemetryEventExt): ITelemetryBaseEvent {\n\tconst newEvent: ITelemetryBaseEvent = { category, eventName };\n\tfor (const key of Object.keys(props)) {\n\t\tnewEvent[key] = convertToBasePropertyType(props[key]);\n\t}\n\treturn newEvent;\n}\n\n/**\n * Takes in value, and does one of 4 things.\n * if value is of primitive type - returns the original value.\n * If the value is an array of primitives - returns a stringified version of the array.\n * If the value is an object of type ITaggedTelemetryPropertyType - returns the object\n * with its values recursively converted to base property Type.\n * If none of these cases are reached - returns an error string\n * @param x - value passed in to convert to a base property type\n */\nexport function convertToBasePropertyType(\n\tx: TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt,\n): TelemetryEventPropertyType | ITaggedTelemetryPropertyType {\n\treturn isTaggedTelemetryPropertyValue(x)\n\t\t? {\n\t\t\t\tvalue: convertToBasePropertyTypeUntagged(x.value),\n\t\t\t\ttag: x.tag,\n\t\t }\n\t\t: convertToBasePropertyTypeUntagged(x);\n}\n\nfunction convertToBasePropertyTypeUntagged(\n\tx: TelemetryEventPropertyTypeExt,\n): TelemetryEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\":\n\t\t\treturn x;\n\t\tcase \"object\":\n\t\t\t// We assume this is an array or flat object based on the input types\n\t\t\treturn JSON.stringify(x);\n\t\tdefault:\n\t\t\t// should never reach this case based on the input types\n\t\t\tconsole.error(\n\t\t\t\t`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`,\n\t\t\t);\n\t\t\treturn `INVALID PROPERTY (typed as ${typeof x})`;\n\t}\n}\n\nexport const tagData = <\n\tT extends TelemetryDataTag,\n\tV extends Record<string, TelemetryEventPropertyTypeExt>,\n>(\n\ttag: T,\n\tvalues: V,\n) =>\n\t(Object.entries(values) as [keyof V, V[keyof V]][])\n\t\t.filter((e): e is [keyof V, Exclude<V[keyof V], undefined>] => e[1] !== undefined)\n\t\t.reduce<{\n\t\t\t[P in keyof V]:\n\t\t\t\t| (V[P] extends undefined ? undefined : never)\n\t\t\t\t| { value: Exclude<V[P], undefined>; tag: T };\n\t\t}>((pv, cv) => {\n\t\t\tpv[cv[0]] = { tag, value: cv[1] };\n\t\t\treturn pv;\n\t\t}, {} as any);\n\nexport const tagCodeArtifacts = <T extends Record<string, TelemetryEventPropertyTypeExt>>(\n\tvalues: T,\n) => tagData(TelemetryDataTag.CodeArtifact, values);\n"]}
|