@fluidframework/telemetry-utils 2.0.0-dev-rc.5.0.0.268409 → 2.0.0-dev-rc.5.0.0.270987
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/api-report/telemetry-utils.alpha.api.md +1 -1
- package/api-report/telemetry-utils.beta.api.md +1 -1
- package/api-report/telemetry-utils.public.api.md +1 -1
- package/biome.jsonc +4 -0
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/error.d.ts +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +10 -9
- package/dist/error.js.map +1 -1
- package/dist/errorLogging.d.ts +0 -4
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js +8 -27
- package/dist/errorLogging.js.map +1 -1
- package/dist/eventEmitterWithErrorHandling.js +1 -0
- package/dist/eventEmitterWithErrorHandling.js.map +1 -1
- package/dist/fluidErrorBase.d.ts +0 -6
- package/dist/fluidErrorBase.d.ts.map +1 -1
- package/dist/fluidErrorBase.js +1 -12
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/logger.js +19 -7
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.js +2 -1
- package/dist/mockLogger.js.map +1 -1
- package/dist/sampledTelemetryHelper.js +7 -2
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/thresholdCounter.js +3 -0
- package/dist/thresholdCounter.js.map +1 -1
- package/lib/config.js +3 -1
- package/lib/config.js.map +1 -1
- package/lib/error.d.ts +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +10 -9
- package/lib/error.js.map +1 -1
- package/lib/errorLogging.d.ts +0 -4
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js +9 -28
- package/lib/errorLogging.js.map +1 -1
- package/lib/eventEmitterWithErrorHandling.js +1 -0
- package/lib/eventEmitterWithErrorHandling.js.map +1 -1
- package/lib/fluidErrorBase.d.ts +0 -6
- package/lib/fluidErrorBase.d.ts.map +1 -1
- package/lib/fluidErrorBase.js +0 -10
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/logger.js +19 -7
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.js +2 -1
- package/lib/mockLogger.js.map +1 -1
- package/lib/sampledTelemetryHelper.js +7 -2
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/thresholdCounter.js +3 -0
- package/lib/thresholdCounter.js.map +1 -1
- package/package.json +18 -10
- package/src/error.ts +1 -1
- package/src/errorLogging.ts +2 -32
- package/src/fluidErrorBase.ts +0 -15
- package/src/index.ts +1 -6
- package/tsconfig.json +2 -0
package/src/errorLogging.ts
CHANGED
|
@@ -7,12 +7,7 @@ import type { ITelemetryBaseProperties, Tagged } from "@fluidframework/core-inte
|
|
|
7
7
|
import type { ILoggingError } from "@fluidframework/core-interfaces/internal";
|
|
8
8
|
import { v4 as uuid } from "uuid";
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
IFluidErrorBase,
|
|
12
|
-
hasErrorInstanceId,
|
|
13
|
-
isFluidError,
|
|
14
|
-
isValidLegacyError,
|
|
15
|
-
} from "./fluidErrorBase.js";
|
|
10
|
+
import { IFluidErrorBase, hasErrorInstanceId, isFluidError } from "./fluidErrorBase.js";
|
|
16
11
|
import { convertToBasePropertyType } from "./logger.js";
|
|
17
12
|
import type {
|
|
18
13
|
ITelemetryLoggerExt,
|
|
@@ -111,19 +106,6 @@ export interface IFluidErrorAnnotations {
|
|
|
111
106
|
props?: ITelemetryBaseProperties;
|
|
112
107
|
}
|
|
113
108
|
|
|
114
|
-
/**
|
|
115
|
-
* For backwards compatibility with pre-errorInstanceId valid errors
|
|
116
|
-
*/
|
|
117
|
-
function patchLegacyError(
|
|
118
|
-
legacyError: Omit<IFluidErrorBase, "errorInstanceId">,
|
|
119
|
-
): asserts legacyError is IFluidErrorBase {
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
121
|
-
const patchMe: { -readonly [P in "errorInstanceId"]?: IFluidErrorBase[P] } = legacyError as any;
|
|
122
|
-
if (patchMe.errorInstanceId === undefined) {
|
|
123
|
-
patchMe.errorInstanceId = uuid();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
109
|
/**
|
|
128
110
|
* Normalize the given error yielding a valid Fluid Error
|
|
129
111
|
* @returns A valid Fluid Error with any provided annotations applied
|
|
@@ -136,11 +118,6 @@ export function normalizeError(
|
|
|
136
118
|
error: unknown,
|
|
137
119
|
annotations: IFluidErrorAnnotations = {},
|
|
138
120
|
): IFluidErrorBase {
|
|
139
|
-
// Back-compat, while IFluidErrorBase is rolled out
|
|
140
|
-
if (isValidLegacyError(error)) {
|
|
141
|
-
patchLegacyError(error);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
121
|
if (isFluidError(error)) {
|
|
145
122
|
// We can simply add the telemetry props to the error and return it
|
|
146
123
|
error.addTelemetryProperties(annotations.props ?? {});
|
|
@@ -339,7 +316,7 @@ export function isExternalError(error: unknown): boolean {
|
|
|
339
316
|
}
|
|
340
317
|
return false;
|
|
341
318
|
}
|
|
342
|
-
return
|
|
319
|
+
return true;
|
|
343
320
|
}
|
|
344
321
|
|
|
345
322
|
/**
|
|
@@ -400,13 +377,6 @@ export class LoggingError
|
|
|
400
377
|
this._errorInstanceId = id;
|
|
401
378
|
}
|
|
402
379
|
|
|
403
|
-
/**
|
|
404
|
-
* Backwards compatibility to appease {@link isFluidError} in old code that may handle this error.
|
|
405
|
-
*/
|
|
406
|
-
// @ts-expect-error - This field shouldn't be referenced in the current version, but needs to exist at runtime.
|
|
407
|
-
// eslint-disable-next-line @typescript-eslint/prefer-as-const
|
|
408
|
-
private readonly fluidErrorCode: "-" = "-";
|
|
409
|
-
|
|
410
380
|
/**
|
|
411
381
|
* Create a new LoggingError
|
|
412
382
|
* @param message - Error message to use for Error base class
|
package/src/fluidErrorBase.ts
CHANGED
|
@@ -96,18 +96,3 @@ export function isFluidError(error: unknown): error is IFluidErrorBase {
|
|
|
96
96
|
hasTelemetryPropFunctions(error)
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Type guard for old standard of valid/known errors.
|
|
102
|
-
*
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
105
|
-
export function isValidLegacyError(
|
|
106
|
-
error: unknown,
|
|
107
|
-
): error is Omit<IFluidErrorBase, "errorInstanceId"> {
|
|
108
|
-
return (
|
|
109
|
-
typeof (error as Partial<IFluidErrorBase>)?.errorType === "string" &&
|
|
110
|
-
typeof (error as Partial<IFluidErrorBase>)?.message === "string" &&
|
|
111
|
-
hasTelemetryPropFunctions(error)
|
|
112
|
-
);
|
|
113
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -43,12 +43,7 @@ export {
|
|
|
43
43
|
raiseConnectedEvent,
|
|
44
44
|
safeRaiseEvent,
|
|
45
45
|
} from "./events.js";
|
|
46
|
-
export {
|
|
47
|
-
hasErrorInstanceId,
|
|
48
|
-
IFluidErrorBase,
|
|
49
|
-
isFluidError,
|
|
50
|
-
isValidLegacyError,
|
|
51
|
-
} from "./fluidErrorBase.js";
|
|
46
|
+
export { hasErrorInstanceId, IFluidErrorBase, isFluidError } from "./fluidErrorBase.js";
|
|
52
47
|
export {
|
|
53
48
|
eventNamespaceSeparator,
|
|
54
49
|
createChildLogger,
|