@fluidframework/telemetry-utils 0.59.2000 → 0.59.3000-67119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +0 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/debugLogger.js +2 -2
- package/dist/debugLogger.js.map +1 -1
- package/dist/errorLogging.js +7 -7
- package/dist/errorLogging.js.map +1 -1
- package/dist/fluidErrorBase.js +1 -1
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +5 -5
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.d.ts +1 -0
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +3 -0
- package/dist/mockLogger.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/debugLogger.js.map +1 -1
- package/lib/errorLogging.js.map +1 -1
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.d.ts +1 -0
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +3 -0
- package/lib/mockLogger.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +12 -7
- package/src/config.ts +3 -3
- package/src/debugLogger.ts +2 -2
- package/src/errorLogging.ts +4 -4
- package/src/fluidErrorBase.ts +1 -1
- package/src/logger.ts +16 -17
- package/src/mockLogger.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/utils.ts +3 -3
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACtB,SAAc,EACd,MAA4B,EAC5B,KAAsC;IAEtC,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACtB,SAAc,EACd,MAA4B,EAC5B,KAAsC;IAEtC,IAAI,SAAS,EAAE;QACX,OAAO,IAAI,CAAC;KACf;IACD,MAAM,QAAQ,GACV,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE;QACzC,CAAC,iBAAG,QAAQ,EAAE,OAAO,IAAK,KAAK,CAAE,CAAC;IACtC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n ITelemetryBaseEvent,\n ITelemetryBaseLogger,\n ITelemetryGenericEvent,\n} from \"@fluidframework/common-definitions\";\n\n/**\n * Like assert, but logs only if the condition is false, rather than throwing\n * @param condition - The condition to attest too\n * @param logger - The logger to log with\n * @param event - The string or event to log\n * @returns - The outcome of the condition\n */\nexport function logIfFalse(\n condition: any,\n logger: ITelemetryBaseLogger,\n event: string | ITelemetryGenericEvent,\n): condition is true {\n if (condition) {\n return true;\n }\n const newEvent: ITelemetryBaseEvent =\n typeof event === \"string\"\n ? { eventName: event, category: \"error\" }\n : { category: \"error\", ...event };\n logger.send(newEvent);\n return false;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/telemetry-utils",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.3000-67119",
|
|
4
4
|
"description": "Collection of telemetry relates utilities for Fluid",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -72,9 +72,10 @@
|
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@fluidframework/build-common": "^0.23.0",
|
|
75
|
-
"@fluidframework/
|
|
76
|
-
"@fluidframework/
|
|
77
|
-
"@fluidframework/
|
|
75
|
+
"@fluidframework/build-tools": "^0.2.66793",
|
|
76
|
+
"@fluidframework/eslint-config-fluid": "^0.28.2000-0",
|
|
77
|
+
"@fluidframework/mocha-test-setup": "0.59.3000-67119",
|
|
78
|
+
"@fluidframework/telemetry-utils-previous": "npm:@fluidframework/telemetry-utils@0.59.2000",
|
|
78
79
|
"@microsoft/api-extractor": "^7.22.2",
|
|
79
80
|
"@rushstack/eslint-config": "^2.5.1",
|
|
80
81
|
"@types/debug": "^4.1.5",
|
|
@@ -100,10 +101,14 @@
|
|
|
100
101
|
"nyc": "^15.0.0",
|
|
101
102
|
"rimraf": "^2.6.2",
|
|
102
103
|
"sinon": "^7.4.2",
|
|
103
|
-
"typescript": "~4.
|
|
104
|
+
"typescript": "~4.5.5"
|
|
104
105
|
},
|
|
105
106
|
"typeValidation": {
|
|
106
|
-
"version": "0.59.
|
|
107
|
-
"broken": {
|
|
107
|
+
"version": "0.59.3000",
|
|
108
|
+
"broken": {
|
|
109
|
+
"ClassDeclaration_MockLogger": {
|
|
110
|
+
"forwardCompat": false
|
|
111
|
+
}
|
|
112
|
+
}
|
|
108
113
|
}
|
|
109
114
|
}
|
package/src/config.ts
CHANGED
|
@@ -95,7 +95,7 @@ interface StronglyTypedValue extends Partial<ConfigTypeStringToType> {
|
|
|
95
95
|
*/
|
|
96
96
|
function stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {
|
|
97
97
|
let output: ConfigTypes = input;
|
|
98
|
-
let defaultReturn: Pick<StronglyTypedValue,"raw" | "string"> | undefined;
|
|
98
|
+
let defaultReturn: Pick<StronglyTypedValue, "raw" | "string"> | undefined;
|
|
99
99
|
// we do special handling for strings to try and coerce
|
|
100
100
|
// them into a config type if we can. This makes it easy
|
|
101
101
|
// for config sources like sessionStorage which only
|
|
@@ -220,7 +220,7 @@ export class CachedConfigProvider implements IConfigProvider {
|
|
|
220
220
|
* A type containing both a telemetry logger and a configuration provider
|
|
221
221
|
*/
|
|
222
222
|
export interface MonitoringContext<
|
|
223
|
-
L extends ITelemetryBaseLogger = ITelemetryLogger
|
|
223
|
+
L extends ITelemetryBaseLogger = ITelemetryLogger,
|
|
224
224
|
> {
|
|
225
225
|
config: IConfigProvider;
|
|
226
226
|
logger: L;
|
|
@@ -234,7 +234,7 @@ export function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITele
|
|
|
234
234
|
|
|
235
235
|
export function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLogger>(
|
|
236
236
|
logger: L): MonitoringContext<L> {
|
|
237
|
-
if(loggerIsMonitoringContext<L>(logger)) {
|
|
237
|
+
if (loggerIsMonitoringContext<L>(logger)) {
|
|
238
238
|
return logger;
|
|
239
239
|
}
|
|
240
240
|
return mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);
|
package/src/debugLogger.ts
CHANGED
|
@@ -61,8 +61,8 @@ export class DebugLogger extends TelemetryLogger {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
private static tryGetBaseLoggerProps(baseLogger?: ITelemetryBaseLogger) {
|
|
64
|
-
if(baseLogger instanceof TelemetryLogger) {
|
|
65
|
-
return (baseLogger as any as {properties: ITelemetryLoggerPropertyBags}).properties;
|
|
64
|
+
if (baseLogger instanceof TelemetryLogger) {
|
|
65
|
+
return (baseLogger as any as { properties: ITelemetryLoggerPropertyBags; }).properties;
|
|
66
66
|
}
|
|
67
67
|
return undefined;
|
|
68
68
|
}
|
package/src/errorLogging.ts
CHANGED
|
@@ -40,7 +40,7 @@ export function extractLogSafeErrorProperties(error: any, sanitizeStack: boolean
|
|
|
40
40
|
? error.message as string
|
|
41
41
|
: String(error);
|
|
42
42
|
|
|
43
|
-
const safeProps: { message: string; errorType?: string; stack?: string } = {
|
|
43
|
+
const safeProps: { message: string; errorType?: string; stack?: string; } = {
|
|
44
44
|
message,
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -134,9 +134,9 @@ export function normalizeError(
|
|
|
134
134
|
Object.assign(normalizeError, { canRetry, retryAfterSeconds });
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if (typeof(error) !== "object") {
|
|
137
|
+
if (typeof (error) !== "object") {
|
|
138
138
|
// This is only interesting for non-objects
|
|
139
|
-
fluidError.addTelemetryProperties({ typeofError: typeof(error) });
|
|
139
|
+
fluidError.addTelemetryProperties({ typeofError: typeof (error) });
|
|
140
140
|
}
|
|
141
141
|
return fluidError;
|
|
142
142
|
}
|
|
@@ -267,7 +267,7 @@ export function isExternalError(e: any): boolean {
|
|
|
267
267
|
* Type guard to identify if a particular value (loosely) appears to be a tagged telemetry property
|
|
268
268
|
*/
|
|
269
269
|
export function isTaggedTelemetryPropertyValue(x: any): x is ITaggedTelemetryPropertyType {
|
|
270
|
-
return (typeof(x?.value) !== "object" && typeof(x?.tag) === "string");
|
|
270
|
+
return (typeof (x?.value) !== "object" && typeof (x?.tag) === "string");
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
/**
|
package/src/fluidErrorBase.ts
CHANGED
|
@@ -44,7 +44,7 @@ const hasTelemetryPropFunctions = (x: any): boolean =>
|
|
|
44
44
|
typeof x?.getTelemetryProperties === "function" &&
|
|
45
45
|
typeof x?.addTelemetryProperties === "function";
|
|
46
46
|
|
|
47
|
-
export const hasErrorInstanceId = (x: any): x is { errorInstanceId: string } =>
|
|
47
|
+
export const hasErrorInstanceId = (x: any): x is { errorInstanceId: string; } =>
|
|
48
48
|
typeof x?.errorInstanceId === "string";
|
|
49
49
|
|
|
50
50
|
/** type guard for IFluidErrorBase interface */
|
package/src/logger.ts
CHANGED
|
@@ -44,8 +44,8 @@ export interface ITelemetryLoggerPropertyBag {
|
|
|
44
44
|
[index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);
|
|
45
45
|
}
|
|
46
46
|
export interface ITelemetryLoggerPropertyBags{
|
|
47
|
-
all?: ITelemetryLoggerPropertyBag
|
|
48
|
-
error?: ITelemetryLoggerPropertyBag
|
|
47
|
+
all?: ITelemetryLoggerPropertyBag;
|
|
48
|
+
error?: ITelemetryLoggerPropertyBag;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -86,7 +86,7 @@ export abstract class TelemetryLogger implements ITelemetryLogger {
|
|
|
86
86
|
* @param fetchStack - Whether to fetch the current callstack if error.stack is undefined
|
|
87
87
|
*/
|
|
88
88
|
public static prepareErrorObject(event: ITelemetryBaseEvent, error: any, fetchStack: boolean) {
|
|
89
|
-
const { message, errorType, stack} = extractLogSafeErrorProperties(error, true /* sanitizeStack */);
|
|
89
|
+
const { message, errorType, stack } = extractLogSafeErrorProperties(error, true /* sanitizeStack */);
|
|
90
90
|
// First, copy over error message, stack, and errorType directly (overwrite if present on event)
|
|
91
91
|
event.stack = stack;
|
|
92
92
|
event.error = message; // Note that the error message goes on the 'error' field
|
|
@@ -139,9 +139,8 @@ export abstract class TelemetryLogger implements ITelemetryLogger {
|
|
|
139
139
|
* @param error - optional error object to log
|
|
140
140
|
*/
|
|
141
141
|
protected sendTelemetryEventCore(
|
|
142
|
-
event: ITelemetryGenericEvent & { category: TelemetryEventCategory },
|
|
143
|
-
error?: any)
|
|
144
|
-
{
|
|
142
|
+
event: ITelemetryGenericEvent & { category: TelemetryEventCategory; },
|
|
143
|
+
error?: any) {
|
|
145
144
|
const newEvent = { ...event };
|
|
146
145
|
if (error !== undefined) {
|
|
147
146
|
TelemetryLogger.prepareErrorObject(newEvent, error, false);
|
|
@@ -188,14 +187,14 @@ export abstract class TelemetryLogger implements ITelemetryLogger {
|
|
|
188
187
|
if (this.namespace !== undefined) {
|
|
189
188
|
newEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;
|
|
190
189
|
}
|
|
191
|
-
if(this.properties) {
|
|
190
|
+
if (this.properties) {
|
|
192
191
|
const properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];
|
|
193
192
|
properties.push(this.properties.all);
|
|
194
|
-
if(includeErrorProps) {
|
|
193
|
+
if (includeErrorProps) {
|
|
195
194
|
properties.push(this.properties.error);
|
|
196
195
|
}
|
|
197
|
-
for(const props of properties) {
|
|
198
|
-
if(props !== undefined) {
|
|
196
|
+
for (const props of properties) {
|
|
197
|
+
if (props !== undefined) {
|
|
199
198
|
for (const key of Object.keys(props)) {
|
|
200
199
|
if (event[key] !== undefined) {
|
|
201
200
|
continue;
|
|
@@ -282,15 +281,15 @@ export class ChildLogger extends TelemetryLogger {
|
|
|
282
281
|
// the callstack overhead, just generate a new logger that includes everything from the previous
|
|
283
282
|
if (baseLogger instanceof ChildLogger) {
|
|
284
283
|
const combinedProperties: ITelemetryLoggerPropertyBags = {};
|
|
285
|
-
for(const extendedProps of [baseLogger.properties, properties]) {
|
|
286
|
-
if(extendedProps !== undefined) {
|
|
287
|
-
if(extendedProps.all !== undefined) {
|
|
284
|
+
for (const extendedProps of [baseLogger.properties, properties]) {
|
|
285
|
+
if (extendedProps !== undefined) {
|
|
286
|
+
if (extendedProps.all !== undefined) {
|
|
288
287
|
combinedProperties.all = {
|
|
289
288
|
... combinedProperties.all,
|
|
290
289
|
... extendedProps.all,
|
|
291
290
|
};
|
|
292
291
|
}
|
|
293
|
-
if(extendedProps.error !== undefined) {
|
|
292
|
+
if (extendedProps.error !== undefined) {
|
|
294
293
|
combinedProperties.error = {
|
|
295
294
|
... combinedProperties.error,
|
|
296
295
|
... extendedProps.error,
|
|
@@ -326,7 +325,7 @@ export class ChildLogger extends TelemetryLogger {
|
|
|
326
325
|
super(namespace, properties);
|
|
327
326
|
|
|
328
327
|
// propagate the monitoring context
|
|
329
|
-
if(loggerIsMonitoringContext(baseLogger)) {
|
|
328
|
+
if (loggerIsMonitoringContext(baseLogger)) {
|
|
330
329
|
mixinMonitoringContext(
|
|
331
330
|
this,
|
|
332
331
|
new CachedConfigProvider(baseLogger.config));
|
|
@@ -449,7 +448,7 @@ export class PerformanceEvent {
|
|
|
449
448
|
protected constructor(
|
|
450
449
|
private readonly logger: ITelemetryLogger,
|
|
451
450
|
event: ITelemetryGenericEvent,
|
|
452
|
-
private readonly markers: IPerformanceEventMarkers = {end: true, cancel: "generic"},
|
|
451
|
+
private readonly markers: IPerformanceEventMarkers = { end: true, cancel: "generic" },
|
|
453
452
|
) {
|
|
454
453
|
this.event = { ...event };
|
|
455
454
|
if (this.markers.start) {
|
|
@@ -492,7 +491,7 @@ export class PerformanceEvent {
|
|
|
492
491
|
|
|
493
492
|
public cancel(props?: ITelemetryProperties, error?: any): void {
|
|
494
493
|
if (this.markers.cancel !== undefined) {
|
|
495
|
-
this.reportEvent("cancel", {category: this.markers.cancel, ...props}, error);
|
|
494
|
+
this.reportEvent("cancel", { category: this.markers.cancel, ...props }, error);
|
|
496
495
|
}
|
|
497
496
|
this.event = undefined;
|
|
498
497
|
}
|
package/src/mockLogger.ts
CHANGED
package/src/packageVersion.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -20,13 +20,13 @@ export function logIfFalse(
|
|
|
20
20
|
logger: ITelemetryBaseLogger,
|
|
21
21
|
event: string | ITelemetryGenericEvent,
|
|
22
22
|
): condition is true {
|
|
23
|
-
if(condition) {
|
|
23
|
+
if (condition) {
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
const newEvent: ITelemetryBaseEvent =
|
|
27
27
|
typeof event === "string"
|
|
28
|
-
? {eventName: event, category: "error"}
|
|
29
|
-
: {category: "error", ...event };
|
|
28
|
+
? { eventName: event, category: "error" }
|
|
29
|
+
: { category: "error", ...event };
|
|
30
30
|
logger.send(newEvent);
|
|
31
31
|
return false;
|
|
32
32
|
}
|