@fluidframework/telemetry-utils 2.0.0-rc.1.0.6 → 2.0.0-rc.2.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.
Files changed (149) hide show
  1. package/{.mocharc.js → .mocharc.cjs} +1 -1
  2. package/CHANGELOG.md +23 -0
  3. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -2
  4. package/api-extractor-lint.json +1 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/telemetry-utils.api.md +10 -33
  7. package/dist/config.d.ts +2 -2
  8. package/dist/config.d.ts.map +1 -1
  9. package/dist/config.js +3 -3
  10. package/dist/config.js.map +1 -1
  11. package/dist/error.d.ts +2 -2
  12. package/dist/error.d.ts.map +1 -1
  13. package/dist/error.js +9 -9
  14. package/dist/error.js.map +1 -1
  15. package/dist/errorLogging.d.ts +4 -4
  16. package/dist/errorLogging.d.ts.map +1 -1
  17. package/dist/errorLogging.js +19 -60
  18. package/dist/errorLogging.js.map +1 -1
  19. package/dist/eventEmitterWithErrorHandling.d.ts +1 -1
  20. package/dist/eventEmitterWithErrorHandling.js +1 -1
  21. package/dist/eventEmitterWithErrorHandling.js.map +1 -1
  22. package/dist/events.d.ts +2 -3
  23. package/dist/events.d.ts.map +1 -1
  24. package/dist/events.js.map +1 -1
  25. package/dist/fluidErrorBase.d.ts +4 -3
  26. package/dist/fluidErrorBase.d.ts.map +1 -1
  27. package/dist/fluidErrorBase.js.map +1 -1
  28. package/dist/index.d.ts +12 -12
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +58 -60
  31. package/dist/index.js.map +1 -1
  32. package/dist/logger.d.ts +7 -23
  33. package/dist/logger.d.ts.map +1 -1
  34. package/dist/logger.js +12 -29
  35. package/dist/logger.js.map +1 -1
  36. package/dist/mockLogger.d.ts +1 -1
  37. package/dist/mockLogger.d.ts.map +1 -1
  38. package/dist/mockLogger.js +2 -2
  39. package/dist/mockLogger.js.map +1 -1
  40. package/dist/package.json +3 -0
  41. package/dist/sampledTelemetryHelper.d.ts +4 -4
  42. package/dist/sampledTelemetryHelper.d.ts.map +1 -1
  43. package/dist/sampledTelemetryHelper.js +1 -1
  44. package/dist/sampledTelemetryHelper.js.map +1 -1
  45. package/dist/telemetry-utils-alpha.d.ts +4 -15
  46. package/dist/telemetry-utils-beta.d.ts +4 -32
  47. package/dist/telemetry-utils-public.d.ts +4 -32
  48. package/dist/telemetry-utils-untrimmed.d.ts +11 -50
  49. package/dist/thresholdCounter.d.ts +1 -1
  50. package/dist/thresholdCounter.d.ts.map +1 -1
  51. package/dist/thresholdCounter.js.map +1 -1
  52. package/dist/tsdoc-metadata.json +1 -1
  53. package/dist/utils.d.ts +1 -20
  54. package/dist/utils.d.ts.map +1 -1
  55. package/dist/utils.js +3 -27
  56. package/dist/utils.js.map +1 -1
  57. package/lib/config.d.ts +2 -2
  58. package/lib/config.d.ts.map +1 -1
  59. package/lib/config.js +1 -1
  60. package/lib/config.js.map +1 -1
  61. package/lib/error.d.ts +2 -2
  62. package/lib/error.d.ts.map +1 -1
  63. package/lib/error.js +1 -1
  64. package/lib/error.js.map +1 -1
  65. package/lib/errorLogging.d.ts +4 -4
  66. package/lib/errorLogging.d.ts.map +1 -1
  67. package/lib/errorLogging.js +15 -56
  68. package/lib/errorLogging.js.map +1 -1
  69. package/lib/eventEmitterWithErrorHandling.d.ts +1 -1
  70. package/lib/eventEmitterWithErrorHandling.js +1 -1
  71. package/lib/eventEmitterWithErrorHandling.js.map +1 -1
  72. package/lib/events.d.ts +2 -3
  73. package/lib/events.d.ts.map +1 -1
  74. package/lib/events.js.map +1 -1
  75. package/lib/fluidErrorBase.d.ts +4 -3
  76. package/lib/fluidErrorBase.d.ts.map +1 -1
  77. package/lib/fluidErrorBase.js.map +1 -1
  78. package/lib/index.d.ts +12 -12
  79. package/lib/index.d.ts.map +1 -1
  80. package/lib/index.js +11 -11
  81. package/lib/index.js.map +1 -1
  82. package/lib/logger.d.ts +7 -23
  83. package/lib/logger.d.ts.map +1 -1
  84. package/lib/logger.js +3 -19
  85. package/lib/logger.js.map +1 -1
  86. package/lib/mockLogger.d.ts +1 -1
  87. package/lib/mockLogger.d.ts.map +1 -1
  88. package/lib/mockLogger.js +1 -1
  89. package/lib/mockLogger.js.map +1 -1
  90. package/lib/sampledTelemetryHelper.d.ts +4 -4
  91. package/lib/sampledTelemetryHelper.d.ts.map +1 -1
  92. package/lib/sampledTelemetryHelper.js +1 -1
  93. package/lib/sampledTelemetryHelper.js.map +1 -1
  94. package/lib/{telemetry-utils-alpha.d.mts → telemetry-utils-alpha.d.ts} +4 -15
  95. package/lib/{telemetry-utils-beta.d.mts → telemetry-utils-beta.d.ts} +4 -32
  96. package/lib/{telemetry-utils-public.d.mts → telemetry-utils-public.d.ts} +4 -32
  97. package/lib/{telemetry-utils-untrimmed.d.mts → telemetry-utils-untrimmed.d.ts} +11 -50
  98. package/lib/test/EventEmitterWithErrorHandling.spec.js +86 -0
  99. package/lib/test/EventEmitterWithErrorHandling.spec.js.map +1 -0
  100. package/lib/test/childLogger.spec.js +233 -0
  101. package/lib/test/childLogger.spec.js.map +1 -0
  102. package/lib/test/config.spec.js +229 -0
  103. package/lib/test/config.spec.js.map +1 -0
  104. package/lib/test/error.spec.js +161 -0
  105. package/lib/test/error.spec.js.map +1 -0
  106. package/lib/test/errorLogging.spec.js +801 -0
  107. package/lib/test/errorLogging.spec.js.map +1 -0
  108. package/lib/test/errorTypeLoggingTest.spec.js +107 -0
  109. package/lib/test/errorTypeLoggingTest.spec.js.map +1 -0
  110. package/lib/test/mockLogger.spec.js +164 -0
  111. package/lib/test/mockLogger.spec.js.map +1 -0
  112. package/lib/test/multiSinkLogger.spec.js +84 -0
  113. package/lib/test/multiSinkLogger.spec.js.map +1 -0
  114. package/lib/test/performanceEvent.spec.js +86 -0
  115. package/lib/test/performanceEvent.spec.js.map +1 -0
  116. package/lib/test/sampledTelemetryHelper.spec.js +169 -0
  117. package/lib/test/sampledTelemetryHelper.spec.js.map +1 -0
  118. package/lib/test/telemetryLogger.spec.js +357 -0
  119. package/lib/test/telemetryLogger.spec.js.map +1 -0
  120. package/lib/test/thresholdCounter.spec.js +51 -0
  121. package/lib/test/thresholdCounter.spec.js.map +1 -0
  122. package/lib/test/types/validateTelemetryUtilsPrevious.generated.js +132 -0
  123. package/lib/test/types/validateTelemetryUtilsPrevious.generated.js.map +1 -0
  124. package/lib/test/utils.spec.js +284 -0
  125. package/lib/test/utils.spec.js.map +1 -0
  126. package/lib/thresholdCounter.d.ts +1 -1
  127. package/lib/thresholdCounter.d.ts.map +1 -1
  128. package/lib/thresholdCounter.js.map +1 -1
  129. package/lib/utils.d.ts +1 -20
  130. package/lib/utils.d.ts.map +1 -1
  131. package/lib/utils.js +1 -24
  132. package/lib/utils.js.map +1 -1
  133. package/package.json +75 -26
  134. package/src/config.ts +2 -2
  135. package/src/error.ts +2 -2
  136. package/src/errorLogging.ts +27 -68
  137. package/src/eventEmitterWithErrorHandling.ts +1 -1
  138. package/src/events.ts +2 -4
  139. package/src/fluidErrorBase.ts +4 -3
  140. package/src/index.ts +12 -13
  141. package/src/logger.ts +12 -28
  142. package/src/mockLogger.ts +2 -2
  143. package/src/sampledTelemetryHelper.ts +10 -11
  144. package/src/thresholdCounter.ts +1 -1
  145. package/src/utils.ts +3 -36
  146. package/tsconfig.cjs.json +7 -0
  147. package/tsconfig.json +2 -3
  148. package/tsconfig.esnext.json +0 -7
  149. /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -6,7 +6,8 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.NORMALIZED_ERROR_TYPE = exports.LoggingError = exports.getCircularReplacer = exports.isTaggedTelemetryPropertyValue = exports.isExternalError = exports.overwriteStack = exports.wrapErrorAndLog = exports.wrapError = exports.generateStack = exports.generateErrorWithStack = exports.normalizeError = exports.isILoggingError = exports.extractLogSafeErrorProperties = void 0;
8
8
  const uuid_1 = require("uuid");
9
- const fluidErrorBase_1 = require("./fluidErrorBase");
9
+ const fluidErrorBase_js_1 = require("./fluidErrorBase.js");
10
+ const logger_js_1 = require("./logger.js");
10
11
  /**
11
12
  * Determines if the provided value is an object but neither null nor an array.
12
13
  */
@@ -86,10 +87,10 @@ function patchLegacyError(legacyError) {
86
87
  */
87
88
  function normalizeError(error, annotations = {}) {
88
89
  // Back-compat, while IFluidErrorBase is rolled out
89
- if ((0, fluidErrorBase_1.isValidLegacyError)(error)) {
90
+ if ((0, fluidErrorBase_js_1.isValidLegacyError)(error)) {
90
91
  patchLegacyError(error);
91
92
  }
92
- if ((0, fluidErrorBase_1.isFluidError)(error)) {
93
+ if ((0, fluidErrorBase_js_1.isFluidError)(error)) {
93
94
  // We can simply add the telemetry props to the error and return it
94
95
  error.addTelemetryProperties(annotations.props ?? {});
95
96
  return error;
@@ -190,7 +191,7 @@ function wrapError(innerError, newErrorFn) {
190
191
  newError.addTelemetryProperties({ untrustedOrigin: 1 });
191
192
  }
192
193
  // Reuse errorInstanceId
193
- if ((0, fluidErrorBase_1.hasErrorInstanceId)(innerError)) {
194
+ if ((0, fluidErrorBase_js_1.hasErrorInstanceId)(innerError)) {
194
195
  newError.overwriteErrorInstanceId(innerError.errorInstanceId);
195
196
  // For "back-compat" in the logs
196
197
  newError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });
@@ -258,7 +259,7 @@ function isExternalError(error) {
258
259
  }
259
260
  return false;
260
261
  }
261
- return !(0, fluidErrorBase_1.isValidLegacyError)(error);
262
+ return !(0, fluidErrorBase_js_1.isValidLegacyError)(error);
262
263
  }
263
264
  exports.isExternalError = isExternalError;
264
265
  /**
@@ -271,57 +272,6 @@ function isTaggedTelemetryPropertyValue(x) {
271
272
  return typeof x?.tag === "string";
272
273
  }
273
274
  exports.isTaggedTelemetryPropertyValue = isTaggedTelemetryPropertyValue;
274
- /**
275
- * Filter serializable telemetry properties
276
- * @param x - Any telemetry prop
277
- * @returns As-is if x is primitive. returns stringified if x is an array of primitive.
278
- * otherwise returns null since this is what we support at the moment.
279
- */
280
- function filterValidTelemetryProps(x, key) {
281
- if (Array.isArray(x) && x.every((val) => isTelemetryEventPropertyValue(val))) {
282
- return JSON.stringify(x);
283
- }
284
- if (isTelemetryEventPropertyValue(x)) {
285
- return x;
286
- }
287
- // We don't support logging arbitrary objects
288
- console.error(`UnSupported Format of Logging Error Property for key ${key}:`, x);
289
- return "REDACTED (arbitrary object)";
290
- }
291
- // checking type of x, returns false if x is null
292
- function isTelemetryEventPropertyValue(x) {
293
- switch (typeof x) {
294
- case "string":
295
- case "number":
296
- case "boolean":
297
- case "undefined": {
298
- return true;
299
- }
300
- default: {
301
- return false;
302
- }
303
- }
304
- }
305
- /**
306
- * Walk an object's enumerable properties to find those fit for telemetry.
307
- */
308
- function getValidTelemetryProps(obj, keysToOmit) {
309
- const props = {};
310
- for (const key of Object.keys(obj)) {
311
- if (keysToOmit.has(key)) {
312
- continue;
313
- }
314
- const val = obj[key];
315
- // ensure only valid props get logged, since props of logging error could be in any shape
316
- props[key] = isTaggedTelemetryPropertyValue(val)
317
- ? {
318
- value: filterValidTelemetryProps(val.value, key),
319
- tag: val.tag,
320
- }
321
- : filterValidTelemetryProps(val, key);
322
- }
323
- return props;
324
- }
325
275
  /**
326
276
  * Borrowed from
327
277
  * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}
@@ -409,10 +359,19 @@ class LoggingError extends Error {
409
359
  * Get all properties fit to be logged to telemetry for this error
410
360
  */
411
361
  getTelemetryProperties() {
412
- const taggableProps = getValidTelemetryProps(this, this.omitPropsFromLogging);
413
- // Include non-enumerable props that are not returned by getValidTelemetryProps
362
+ // Only pick properties fit for telemetry out of all of this object's enumerable properties.
363
+ const telemetryProps = {};
364
+ for (const key of Object.keys(this)) {
365
+ if (this.omitPropsFromLogging.has(key)) {
366
+ continue;
367
+ }
368
+ const val = this[key];
369
+ // Ensure only valid props get logged, since props of logging error could be in any shape
370
+ telemetryProps[key] = (0, logger_js_1.convertToBasePropertyType)(val);
371
+ }
372
+ // Ensure a few extra props always exist
414
373
  return {
415
- ...taggableProps,
374
+ ...telemetryProps,
416
375
  stack: this.stack,
417
376
  message: this.message,
418
377
  errorInstanceId: this._errorInstanceId,
@@ -435,7 +394,7 @@ class NormalizedLoggingError extends LoggingError {
435
394
  constructor(errorProps) {
436
395
  super(errorProps.message);
437
396
  // errorType "genericError" is used as a default value throughout the code.
438
- // Note that this matches ContainerErrorType/DriverErrorType's genericError
397
+ // Note that this matches ContainerErrorTypes/DriverErrorTypes' genericError
439
398
  this.errorType = exports.NORMALIZED_ERROR_TYPE;
440
399
  if (errorProps.stack !== undefined) {
441
400
  overwriteStack(this, errorProps.stack);
@@ -1 +1 @@
1
- {"version":3,"file":"errorLogging.js","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,+BAAkC;AAClC,qDAK0B;AAG1B;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,KAAc,EAAW,EAAE;IACnD,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC7E,CAAC,CAAC;AAEF;;;;GAIG;AACH,SAAgB,6BAA6B,CAC5C,KAAc,EACd,aAAsB;IAMtB,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,SAAkB,EAAU,EAAE;QAC5E,IAAI,CAAC,aAAa,EAAE;YACnB,OAAO,KAAK,CAAC;SACb;QACD,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,uCAAuC;QAC5D,IAAI,SAAS,KAAK,SAAS,EAAE;YAC5B,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB;SACpD;QACD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC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CAAC,CAAC;QAC9E,+EAA+E;QAC/E,OAAO;YACN,GAAG,aAAa;YAChB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,eAAe,EAAE,IAAI,CAAC,gBAAgB;SACtC,CAAC;IACH,CAAC;CACD;AA7ED,oCA6EC;AAED;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD;;;;GAIG;AACH,MAAM,sBAAuB,SAAQ,YAAY;IAKhD,YAAY,UAAsD;QACjE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAL3B,2EAA2E;QAC3E,2EAA2E;QAC3E,cAAS,GAAG,6BAAqB,CAAC;QAKjC,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YACnC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;SACvC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tILoggingError,\n\tITelemetryBaseProperties,\n\tTelemetryBaseEventPropertyType,\n\tTagged,\n} from \"@fluidframework/core-interfaces\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nimport { ITelemetryLoggerExt, TelemetryEventPropertyTypeExt } from \"./telemetryTypes\";\n\n/**\n * Determines if the provided value is an object but neither null nor an array.\n */\nconst isRegularObject = (value: unknown): boolean => {\n\treturn value !== null && !Array.isArray(value) && typeof value === \"object\";\n};\n\n/**\n * Inspect the given error for common \"safe\" props and return them.\n *\n * @internal\n */\nexport function extractLogSafeErrorProperties(\n\terror: unknown,\n\tsanitizeStack: boolean,\n): {\n\tmessage: string;\n\terrorType?: string | undefined;\n\tstack?: string | undefined;\n} {\n\tconst removeMessageFromStack = (stack: string, errorName?: string): string => {\n\t\tif (!sanitizeStack) {\n\t\t\treturn stack;\n\t\t}\n\t\tconst stackFrames = stack.split(\"\\n\");\n\t\tstackFrames.shift(); // Remove \"[ErrorName]: [ErrorMessage]\"\n\t\tif (errorName !== undefined) {\n\t\t\tstackFrames.unshift(errorName); // Add \"[ErrorName]\"\n\t\t}\n\t\treturn stackFrames.join(\"\\n\");\n\t};\n\n\tconst message =\n\t\ttypeof (error as Partial<Error>)?.message === \"string\"\n\t\t\t? (error as Error).message\n\t\t\t: String(error);\n\n\tconst safeProps: { message: string; errorType?: string; stack?: string } = {\n\t\tmessage,\n\t};\n\n\tif (isRegularObject(error)) {\n\t\tconst { errorType, stack, name } = error as Partial<IFluidErrorBase>;\n\n\t\tif (typeof errorType === \"string\") {\n\t\t\tsafeProps.errorType = errorType;\n\t\t}\n\n\t\tif (typeof stack === \"string\") {\n\t\t\tconst errorName = typeof name === \"string\" ? name : undefined;\n\t\t\tsafeProps.stack = removeMessageFromStack(stack, errorName);\n\t\t}\n\t}\n\n\treturn safeProps;\n}\n\n/**\n * Type-guard for {@link @fluidframework/core-interfaces#ILoggingError}.\n *\n * @internal\n */\nexport const isILoggingError = (x: unknown): x is ILoggingError =>\n\ttypeof (x as Partial<ILoggingError>)?.getTelemetryProperties === \"function\";\n\n/**\n * Copy props from source onto target, but do not overwrite an existing prop that matches\n */\nfunction copyProps(\n\ttarget: ITelemetryBaseProperties | LoggingError,\n\tsource: ITelemetryBaseProperties,\n): void {\n\tfor (const key of Object.keys(source)) {\n\t\tif (target[key] === undefined) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n}\n\n/**\n * Metadata to annotate an error object when annotating or normalizing it\n *\n * @internal\n */\nexport interface IFluidErrorAnnotations {\n\t/**\n\t * Telemetry props to log with the error\n\t */\n\tprops?: ITelemetryBaseProperties;\n}\n\n/**\n * For backwards compatibility with pre-errorInstanceId valid errors\n */\nfunction patchLegacyError(\n\tlegacyError: Omit<IFluidErrorBase, \"errorInstanceId\">,\n): asserts legacyError is IFluidErrorBase {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n\tconst patchMe: { -readonly [P in \"errorInstanceId\"]?: IFluidErrorBase[P] } = legacyError as any;\n\tif (patchMe.errorInstanceId === undefined) {\n\t\tpatchMe.errorInstanceId = uuid();\n\t}\n}\n\n/**\n * Normalize the given error yielding a valid Fluid Error\n * @returns A valid Fluid Error with any provided annotations applied\n * @param error - The error to normalize\n * @param annotations - Annotations to apply to the normalized error\n *\n * @internal\n */\nexport function normalizeError(\n\terror: unknown,\n\tannotations: IFluidErrorAnnotations = {},\n): IFluidErrorBase {\n\t// Back-compat, while IFluidErrorBase is rolled out\n\tif (isValidLegacyError(error)) {\n\t\tpatchLegacyError(error);\n\t}\n\n\tif (isFluidError(error)) {\n\t\t// We can simply add the telemetry props to the error and return it\n\t\terror.addTelemetryProperties(annotations.props ?? {});\n\t\treturn error;\n\t}\n\n\t// We have to construct a new Fluid Error, copying safe properties over\n\tconst { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);\n\tconst fluidError: IFluidErrorBase = new NormalizedLoggingError({\n\t\tmessage,\n\t\tstack,\n\t});\n\n\t// We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)\n\t// Anywhere they are set should be on a valid Fluid Error that would have been returned above,\n\t// but we can't prove it with the types, so adding this defensive measure.\n\tif (typeof error === \"object\" && error !== null) {\n\t\tconst maybeHasRetry: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> = error;\n\t\tlet retryProps: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> | undefined;\n\t\tif (\"canRetry\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.canRetry = maybeHasRetry.canRetry;\n\t\t}\n\t\tif (\"retryAfterSeconds\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.retryAfterSeconds = maybeHasRetry.retryAfterSeconds;\n\t\t}\n\t\tif (retryProps !== undefined) {\n\t\t\tObject.assign(fluidError, retryProps);\n\t\t}\n\t}\n\n\tif (typeof error !== \"object\") {\n\t\t// This is only interesting for non-objects\n\t\tfluidError.addTelemetryProperties({ typeofError: typeof error });\n\t}\n\n\tconst errorTelemetryProps = LoggingError.typeCheck(error)\n\t\t? error.getTelemetryProperties()\n\t\t: { untrustedOrigin: 1 }; // This will let us filter errors that did not originate from our own codebase\n\n\tfluidError.addTelemetryProperties({\n\t\t...errorTelemetryProps,\n\t\t...annotations.props,\n\t});\n\n\treturn fluidError;\n}\n\nlet stackPopulatedOnCreation: boolean | undefined;\n\n/**\n * The purpose of this function is to provide ability to capture stack context quickly.\n * Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.\n * There are scenarios where we generate error with stack, but error is handled in most cases and\n * stack property is not accessed.\n * For such cases it's better to not read stack property right away, but rather delay it until / if it's needed\n * Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.\n * @returns Error object that has stack populated.\n *\n * @internal\n */\nexport function generateErrorWithStack(): Error {\n\tconst err = new Error(\"<<generated stack>>\");\n\n\tif (stackPopulatedOnCreation === undefined) {\n\t\tstackPopulatedOnCreation = err.stack !== undefined;\n\t}\n\n\tif (stackPopulatedOnCreation) {\n\t\treturn err;\n\t}\n\n\ttry {\n\t\tthrow err;\n\t} catch (error) {\n\t\treturn error as Error;\n\t}\n}\n\n/**\n * Generate a stack at this callsite as if an error were thrown from here.\n * @returns the callstack (does not throw)\n *\n * @internal\n */\nexport function generateStack(): string | undefined {\n\treturn generateErrorWithStack().stack;\n}\n\n/**\n * Create a new error using newErrorFn, wrapping and caused by the given unknown error.\n * Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present\n * @param innerError - An error from untrusted/unknown origins\n * @param newErrorFn - callback that will create a new error given the original error's message\n * @returns A new error object \"wrapping\" the given error\n *\n * @internal\n */\nexport function wrapError<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n): T {\n\tconst { message, stack } = extractLogSafeErrorProperties(innerError, false /* sanitizeStack */);\n\n\tconst newError = newErrorFn(message);\n\n\tif (stack !== undefined) {\n\t\toverwriteStack(newError, stack);\n\t}\n\n\t// Mark external errors with untrustedOrigin flag\n\tif (isExternalError(innerError)) {\n\t\tnewError.addTelemetryProperties({ untrustedOrigin: 1 });\n\t}\n\n\t// Reuse errorInstanceId\n\tif (hasErrorInstanceId(innerError)) {\n\t\tnewError.overwriteErrorInstanceId(innerError.errorInstanceId);\n\n\t\t// For \"back-compat\" in the logs\n\t\tnewError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\n\t}\n\n\t// Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties\n\t// This will include the untrustedOrigin property if the inner error itself was created from an external error\n\tif (isILoggingError(innerError)) {\n\t\tnewError.addTelemetryProperties(innerError.getTelemetryProperties());\n\t}\n\n\treturn newError;\n}\n\n/**\n * The same as wrapError, but also logs the innerError, including the wrapping error's instance ID.\n *\n * @typeParam T - The kind of wrapper error to create.\n *\n * @internal\n */\nexport function wrapErrorAndLog<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n\tlogger: ITelemetryLoggerExt,\n): T {\n\tconst newError = wrapError(innerError, newErrorFn);\n\n\t// This will match innerError.errorInstanceId if present (see wrapError)\n\tconst errorInstanceId = newError.errorInstanceId;\n\n\t// For \"back-compat\" in the logs\n\tconst wrappedByErrorInstanceId = errorInstanceId;\n\n\tlogger.sendTelemetryEvent(\n\t\t{\n\t\t\teventName: \"WrapError\",\n\t\t\terrorInstanceId,\n\t\t\twrappedByErrorInstanceId,\n\t\t},\n\t\tinnerError,\n\t);\n\n\treturn newError;\n}\n\n/**\n * Attempts to overwrite the error's stack\n *\n * There have been reports of certain JS environments where overwriting stack will throw.\n * If that happens, this adds the given stack as the telemetry property \"stack2\"\n *\n * @internal\n */\nexport function overwriteStack(error: IFluidErrorBase | LoggingError, stack: string): void {\n\ttry {\n\t\tObject.assign(error, { stack });\n\t} catch {\n\t\terror.addTelemetryProperties({ stack2: stack });\n\t}\n}\n\n/**\n * True for any error object that is an (optionally normalized) external error\n * False for any error we created and raised within the FF codebase via LoggingError base class,\n * or wrapped in a well-known error type\n *\n * @internal\n */\nexport function isExternalError(error: unknown): boolean {\n\t// LoggingErrors are an internal FF error type. However, an external error can be converted\n\t// into a LoggingError if it is normalized. In this case we must use the untrustedOrigin flag to\n\t// determine whether the original error was infact external.\n\tif (LoggingError.typeCheck(error)) {\n\t\tif ((error as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {\n\t\t\treturn error.getTelemetryProperties().untrustedOrigin === 1;\n\t\t}\n\t\treturn false;\n\t}\n\treturn !isValidLegacyError(error);\n}\n\n/**\n * Type guard to identify if a particular telemetry property appears to be a\n * {@link @fluidframework/core-interfaces#Tagged} telemetry property.\n *\n * @internal\n */\nexport function isTaggedTelemetryPropertyValue(\n\tx: Tagged<TelemetryEventPropertyTypeExt> | TelemetryEventPropertyTypeExt,\n): x is Tagged<TelemetryEventPropertyTypeExt> {\n\treturn typeof (x as Partial<Tagged<unknown>>)?.tag === \"string\";\n}\n\n/**\n * Filter serializable telemetry properties\n * @param x - Any telemetry prop\n * @returns As-is if x is primitive. returns stringified if x is an array of primitive.\n * otherwise returns null since this is what we support at the moment.\n */\nfunction filterValidTelemetryProps(x: unknown, key: string): TelemetryBaseEventPropertyType {\n\tif (Array.isArray(x) && x.every((val) => isTelemetryEventPropertyValue(val))) {\n\t\treturn JSON.stringify(x);\n\t}\n\tif (isTelemetryEventPropertyValue(x)) {\n\t\treturn x;\n\t}\n\t// We don't support logging arbitrary objects\n\tconsole.error(`UnSupported Format of Logging Error Property for key ${key}:`, x);\n\treturn \"REDACTED (arbitrary object)\";\n}\n\n// checking type of x, returns false if x is null\nfunction isTelemetryEventPropertyValue(x: unknown): x is TelemetryBaseEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\n/**\n * Walk an object's enumerable properties to find those fit for telemetry.\n */\nfunction getValidTelemetryProps(obj: object, keysToOmit: Set<string>): ITelemetryBaseProperties {\n\tconst props: ITelemetryBaseProperties = {};\n\tfor (const key of Object.keys(obj)) {\n\t\tif (keysToOmit.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst val = obj[key] as\n\t\t\t| TelemetryEventPropertyTypeExt\n\t\t\t| Tagged<TelemetryEventPropertyTypeExt>;\n\n\t\t// ensure only valid props get logged, since props of logging error could be in any shape\n\t\tprops[key] = isTaggedTelemetryPropertyValue(val)\n\t\t\t? {\n\t\t\t\t\tvalue: filterValidTelemetryProps(val.value, key),\n\t\t\t\t\ttag: val.tag,\n\t\t\t }\n\t\t\t: filterValidTelemetryProps(val, key);\n\t}\n\treturn props;\n}\n\n/**\n * Borrowed from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}\n * Avoids runtime errors with circular references.\n * Not ideal, as will cut values that are not necessarily circular references.\n * Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)\n *\n * @internal\n */\n// TODO: Use `unknown` instead (API breaking change)\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getCircularReplacer = (): ((key: string, value: unknown) => any) => {\n\tconst seen = new WeakSet();\n\treturn (key: string, value: unknown): any => {\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\tif (seen.has(value)) {\n\t\t\t\treturn \"<removed/circular>\";\n\t\t\t}\n\t\t\tseen.add(value);\n\t\t}\n\t\treturn value;\n\t};\n};\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n/**\n * Base class for \"trusted\" errors we create, whose properties can generally be logged to telemetry safely.\n * All properties set on the object, or passed in (via the constructor or addTelemetryProperties),\n * will be logged in accordance with their tag, if present.\n *\n * PLEASE take care to avoid setting sensitive data on this object without proper tagging!\n *\n * @internal\n */\nexport class LoggingError\n\textends Error\n\timplements ILoggingError, Omit<IFluidErrorBase, \"errorType\">\n{\n\tprivate _errorInstanceId = uuid();\n\tget errorInstanceId(): string {\n\t\treturn this._errorInstanceId;\n\t}\n\toverwriteErrorInstanceId(id: string): void {\n\t\tthis._errorInstanceId = id;\n\t}\n\n\t/**\n\t * Backwards compatibility to appease {@link isFluidError} in old code that may handle this error.\n\t */\n\t// @ts-expect-error - This field shouldn't be referenced in the current version, but needs to exist at runtime.\n\t// eslint-disable-next-line @typescript-eslint/prefer-as-const\n\tprivate readonly fluidErrorCode: \"-\" = \"-\";\n\n\t/**\n\t * Create a new LoggingError\n\t * @param message - Error message to use for Error base class\n\t * @param props - telemetry props to include on the error for when it's logged\n\t * @param omitPropsFromLogging - properties by name to omit from telemetry props\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\tprops?: ITelemetryBaseProperties,\n\t\tprivate readonly omitPropsFromLogging: Set<string> = new Set(),\n\t) {\n\t\tsuper(message);\n\n\t\t// Don't log this list itself, or the private _errorInstanceId\n\t\tomitPropsFromLogging.add(\"omitPropsFromLogging\");\n\t\tomitPropsFromLogging.add(\"_errorInstanceId\");\n\n\t\tif (props) {\n\t\t\tthis.addTelemetryProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * Determines if a given object is an instance of a LoggingError\n\t * @param object - any object\n\t * @returns true if the object is an instance of a LoggingError, false if not.\n\t */\n\tpublic static typeCheck(object: unknown): object is LoggingError {\n\t\tif (typeof object === \"object\" && object !== null) {\n\t\t\treturn (\n\t\t\t\ttypeof (object as LoggingError).addTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).getTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).errorInstanceId === \"string\"\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Add additional properties to be logged\n\t */\n\tpublic addTelemetryProperties(props: ITelemetryBaseProperties): void {\n\t\tcopyProps(this, props);\n\t}\n\n\t/**\n\t * Get all properties fit to be logged to telemetry for this error\n\t */\n\tpublic getTelemetryProperties(): ITelemetryBaseProperties {\n\t\tconst taggableProps = getValidTelemetryProps(this, this.omitPropsFromLogging);\n\t\t// Include non-enumerable props that are not returned by getValidTelemetryProps\n\t\treturn {\n\t\t\t...taggableProps,\n\t\t\tstack: this.stack,\n\t\t\tmessage: this.message,\n\t\t\terrorInstanceId: this._errorInstanceId,\n\t\t};\n\t}\n}\n\n/**\n * The Error class used when normalizing an external error\n *\n * @internal\n */\nexport const NORMALIZED_ERROR_TYPE = \"genericError\";\n\n/**\n * Subclass of LoggingError returned by normalizeError\n *\n * @internal\n */\nclass NormalizedLoggingError extends LoggingError {\n\t// errorType \"genericError\" is used as a default value throughout the code.\n\t// Note that this matches ContainerErrorType/DriverErrorType's genericError\n\terrorType = NORMALIZED_ERROR_TYPE;\n\n\tconstructor(errorProps: Pick<IFluidErrorBase, \"message\" | \"stack\">) {\n\t\tsuper(errorProps.message);\n\n\t\tif (errorProps.stack !== undefined) {\n\t\t\toverwriteStack(this, errorProps.stack);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"errorLogging.js","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,+BAAkC;AAClC,2DAK6B;AAM7B,2CAAwD;AAExD;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,KAAc,EAAW,EAAE;IACnD,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC7E,CAAC,CAAC;AAEF;;;;GAIG;AACH,SAAgB,6BAA6B,CAC5C,KAAc,EACd,aAAsB;IAMtB,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,SAAkB,EAAU,EAAE;QAC5E,IAAI,CAAC,aAAa,EAAE;YACnB,OAAO,KAAK,CAAC;SACb;QACD,MAAM,WAAW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C,IAAI,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACI,sBAAsB;QAC5B,4FAA4F;QAC5F,MAAM,cAAc,GAA6B,EAAE,CAAC;QACpD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACpC,IAAI,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACvC,SAAS;aACT;YACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAEoB,CAAC;YAEzC,yFAAyF;YACzF,cAAc,CAAC,GAAG,CAAC,GAAG,IAAA,qCAAyB,EAAC,GAAG,CAAC,CAAC;SACrD;QACD,wCAAwC;QACxC,OAAO;YACN,GAAG,cAAc;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,eAAe,EAAE,IAAI,CAAC,gBAAgB;SACtC,CAAC;IACH,CAAC;CACD;AAzFD,oCAyFC;AAED;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD;;;;GAIG;AACH,MAAM,sBAAuB,SAAQ,YAAY;IAKhD,YAAY,UAAsD;QACjE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAL3B,2EAA2E;QAC3E,4EAA4E;QAC5E,cAAS,GAAG,6BAAqB,CAAC;QAKjC,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YACnC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;SACvC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tILoggingError,\n\tITelemetryBaseProperties,\n\tTagged,\n} from \"@fluidframework/core-interfaces\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase.js\";\nimport type {\n\tITelemetryLoggerExt,\n\tTelemetryEventPropertyTypeExt,\n\tITelemetryPropertiesExt,\n} from \"./telemetryTypes.js\";\nimport { convertToBasePropertyType } from \"./logger.js\";\n\n/**\n * Determines if the provided value is an object but neither null nor an array.\n */\nconst isRegularObject = (value: unknown): boolean => {\n\treturn value !== null && !Array.isArray(value) && typeof value === \"object\";\n};\n\n/**\n * Inspect the given error for common \"safe\" props and return them.\n *\n * @internal\n */\nexport function extractLogSafeErrorProperties(\n\terror: unknown,\n\tsanitizeStack: boolean,\n): {\n\tmessage: string;\n\terrorType?: string | undefined;\n\tstack?: string | undefined;\n} {\n\tconst removeMessageFromStack = (stack: string, errorName?: string): string => {\n\t\tif (!sanitizeStack) {\n\t\t\treturn stack;\n\t\t}\n\t\tconst stackFrames = stack.split(\"\\n\");\n\t\tstackFrames.shift(); // Remove \"[ErrorName]: [ErrorMessage]\"\n\t\tif (errorName !== undefined) {\n\t\t\tstackFrames.unshift(errorName); // Add \"[ErrorName]\"\n\t\t}\n\t\treturn stackFrames.join(\"\\n\");\n\t};\n\n\tconst message =\n\t\ttypeof (error as Partial<Error>)?.message === \"string\"\n\t\t\t? (error as Error).message\n\t\t\t: String(error);\n\n\tconst safeProps: { message: string; errorType?: string; stack?: string } = {\n\t\tmessage,\n\t};\n\n\tif (isRegularObject(error)) {\n\t\tconst { errorType, stack, name } = error as Partial<IFluidErrorBase>;\n\n\t\tif (typeof errorType === \"string\") {\n\t\t\tsafeProps.errorType = errorType;\n\t\t}\n\n\t\tif (typeof stack === \"string\") {\n\t\t\tconst errorName = typeof name === \"string\" ? name : undefined;\n\t\t\tsafeProps.stack = removeMessageFromStack(stack, errorName);\n\t\t}\n\t}\n\n\treturn safeProps;\n}\n\n/**\n * Type-guard for {@link @fluidframework/core-interfaces#ILoggingError}.\n *\n * @internal\n */\nexport const isILoggingError = (x: unknown): x is ILoggingError =>\n\ttypeof (x as Partial<ILoggingError>)?.getTelemetryProperties === \"function\";\n\n/**\n * Copy props from source onto target, but do not overwrite an existing prop that matches\n */\nfunction copyProps(\n\ttarget: ITelemetryPropertiesExt | LoggingError,\n\tsource: ITelemetryPropertiesExt,\n): void {\n\tfor (const key of Object.keys(source)) {\n\t\tif (target[key] === undefined) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n}\n\n/**\n * Metadata to annotate an error object when annotating or normalizing it\n *\n * @internal\n */\nexport interface IFluidErrorAnnotations {\n\t/**\n\t * Telemetry props to log with the error\n\t */\n\tprops?: ITelemetryBaseProperties;\n}\n\n/**\n * For backwards compatibility with pre-errorInstanceId valid errors\n */\nfunction patchLegacyError(\n\tlegacyError: Omit<IFluidErrorBase, \"errorInstanceId\">,\n): asserts legacyError is IFluidErrorBase {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n\tconst patchMe: { -readonly [P in \"errorInstanceId\"]?: IFluidErrorBase[P] } = legacyError as any;\n\tif (patchMe.errorInstanceId === undefined) {\n\t\tpatchMe.errorInstanceId = uuid();\n\t}\n}\n\n/**\n * Normalize the given error yielding a valid Fluid Error\n * @returns A valid Fluid Error with any provided annotations applied\n * @param error - The error to normalize\n * @param annotations - Annotations to apply to the normalized error\n *\n * @internal\n */\nexport function normalizeError(\n\terror: unknown,\n\tannotations: IFluidErrorAnnotations = {},\n): IFluidErrorBase {\n\t// Back-compat, while IFluidErrorBase is rolled out\n\tif (isValidLegacyError(error)) {\n\t\tpatchLegacyError(error);\n\t}\n\n\tif (isFluidError(error)) {\n\t\t// We can simply add the telemetry props to the error and return it\n\t\terror.addTelemetryProperties(annotations.props ?? {});\n\t\treturn error;\n\t}\n\n\t// We have to construct a new Fluid Error, copying safe properties over\n\tconst { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);\n\tconst fluidError: IFluidErrorBase = new NormalizedLoggingError({\n\t\tmessage,\n\t\tstack,\n\t});\n\n\t// We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)\n\t// Anywhere they are set should be on a valid Fluid Error that would have been returned above,\n\t// but we can't prove it with the types, so adding this defensive measure.\n\tif (typeof error === \"object\" && error !== null) {\n\t\tconst maybeHasRetry: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> = error;\n\t\tlet retryProps: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> | undefined;\n\t\tif (\"canRetry\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.canRetry = maybeHasRetry.canRetry;\n\t\t}\n\t\tif (\"retryAfterSeconds\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.retryAfterSeconds = maybeHasRetry.retryAfterSeconds;\n\t\t}\n\t\tif (retryProps !== undefined) {\n\t\t\tObject.assign(fluidError, retryProps);\n\t\t}\n\t}\n\n\tif (typeof error !== \"object\") {\n\t\t// This is only interesting for non-objects\n\t\tfluidError.addTelemetryProperties({ typeofError: typeof error });\n\t}\n\n\tconst errorTelemetryProps = LoggingError.typeCheck(error)\n\t\t? error.getTelemetryProperties()\n\t\t: { untrustedOrigin: 1 }; // This will let us filter errors that did not originate from our own codebase\n\n\tfluidError.addTelemetryProperties({\n\t\t...errorTelemetryProps,\n\t\t...annotations.props,\n\t});\n\n\treturn fluidError;\n}\n\nlet stackPopulatedOnCreation: boolean | undefined;\n\n/**\n * The purpose of this function is to provide ability to capture stack context quickly.\n * Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.\n * There are scenarios where we generate error with stack, but error is handled in most cases and\n * stack property is not accessed.\n * For such cases it's better to not read stack property right away, but rather delay it until / if it's needed\n * Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.\n * @returns Error object that has stack populated.\n *\n * @internal\n */\nexport function generateErrorWithStack(): Error {\n\tconst err = new Error(\"<<generated stack>>\");\n\n\tif (stackPopulatedOnCreation === undefined) {\n\t\tstackPopulatedOnCreation = err.stack !== undefined;\n\t}\n\n\tif (stackPopulatedOnCreation) {\n\t\treturn err;\n\t}\n\n\ttry {\n\t\tthrow err;\n\t} catch (error) {\n\t\treturn error as Error;\n\t}\n}\n\n/**\n * Generate a stack at this callsite as if an error were thrown from here.\n * @returns the callstack (does not throw)\n *\n * @internal\n */\nexport function generateStack(): string | undefined {\n\treturn generateErrorWithStack().stack;\n}\n\n/**\n * Create a new error using newErrorFn, wrapping and caused by the given unknown error.\n * Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present\n * @param innerError - An error from untrusted/unknown origins\n * @param newErrorFn - callback that will create a new error given the original error's message\n * @returns A new error object \"wrapping\" the given error\n *\n * @internal\n */\nexport function wrapError<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n): T {\n\tconst { message, stack } = extractLogSafeErrorProperties(innerError, false /* sanitizeStack */);\n\n\tconst newError = newErrorFn(message);\n\n\tif (stack !== undefined) {\n\t\toverwriteStack(newError, stack);\n\t}\n\n\t// Mark external errors with untrustedOrigin flag\n\tif (isExternalError(innerError)) {\n\t\tnewError.addTelemetryProperties({ untrustedOrigin: 1 });\n\t}\n\n\t// Reuse errorInstanceId\n\tif (hasErrorInstanceId(innerError)) {\n\t\tnewError.overwriteErrorInstanceId(innerError.errorInstanceId);\n\n\t\t// For \"back-compat\" in the logs\n\t\tnewError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\n\t}\n\n\t// Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties\n\t// This will include the untrustedOrigin property if the inner error itself was created from an external error\n\tif (isILoggingError(innerError)) {\n\t\tnewError.addTelemetryProperties(innerError.getTelemetryProperties());\n\t}\n\n\treturn newError;\n}\n\n/**\n * The same as wrapError, but also logs the innerError, including the wrapping error's instance ID.\n *\n * @typeParam T - The kind of wrapper error to create.\n *\n * @internal\n */\nexport function wrapErrorAndLog<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n\tlogger: ITelemetryLoggerExt,\n): T {\n\tconst newError = wrapError(innerError, newErrorFn);\n\n\t// This will match innerError.errorInstanceId if present (see wrapError)\n\tconst errorInstanceId = newError.errorInstanceId;\n\n\t// For \"back-compat\" in the logs\n\tconst wrappedByErrorInstanceId = errorInstanceId;\n\n\tlogger.sendTelemetryEvent(\n\t\t{\n\t\t\teventName: \"WrapError\",\n\t\t\terrorInstanceId,\n\t\t\twrappedByErrorInstanceId,\n\t\t},\n\t\tinnerError,\n\t);\n\n\treturn newError;\n}\n\n/**\n * Attempts to overwrite the error's stack\n *\n * There have been reports of certain JS environments where overwriting stack will throw.\n * If that happens, this adds the given stack as the telemetry property \"stack2\"\n *\n * @internal\n */\nexport function overwriteStack(error: IFluidErrorBase | LoggingError, stack: string): void {\n\ttry {\n\t\tObject.assign(error, { stack });\n\t} catch {\n\t\terror.addTelemetryProperties({ stack2: stack });\n\t}\n}\n\n/**\n * True for any error object that is an (optionally normalized) external error\n * False for any error we created and raised within the FF codebase via LoggingError base class,\n * or wrapped in a well-known error type\n *\n * @internal\n */\nexport function isExternalError(error: unknown): boolean {\n\t// LoggingErrors are an internal FF error type. However, an external error can be converted\n\t// into a LoggingError if it is normalized. In this case we must use the untrustedOrigin flag to\n\t// determine whether the original error was infact external.\n\tif (LoggingError.typeCheck(error)) {\n\t\tif ((error as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {\n\t\t\treturn error.getTelemetryProperties().untrustedOrigin === 1;\n\t\t}\n\t\treturn false;\n\t}\n\treturn !isValidLegacyError(error);\n}\n\n/**\n * Type guard to identify if a particular telemetry property appears to be a\n * {@link @fluidframework/core-interfaces#Tagged} telemetry property.\n *\n * @internal\n */\nexport function isTaggedTelemetryPropertyValue(\n\tx: Tagged<TelemetryEventPropertyTypeExt> | TelemetryEventPropertyTypeExt,\n): x is Tagged<TelemetryEventPropertyTypeExt> {\n\treturn typeof (x as Partial<Tagged<unknown>>)?.tag === \"string\";\n}\n\n/**\n * Borrowed from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}\n * Avoids runtime errors with circular references.\n * Not ideal, as will cut values that are not necessarily circular references.\n * Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)\n *\n * @internal\n */\n// TODO: Use `unknown` instead (API breaking change)\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getCircularReplacer = (): ((key: string, value: unknown) => any) => {\n\tconst seen = new WeakSet();\n\treturn (key: string, value: unknown): any => {\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\tif (seen.has(value)) {\n\t\t\t\treturn \"<removed/circular>\";\n\t\t\t}\n\t\t\tseen.add(value);\n\t\t}\n\t\treturn value;\n\t};\n};\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n/**\n * Base class for \"trusted\" errors we create, whose properties can generally be logged to telemetry safely.\n * All properties set on the object, or passed in (via the constructor or addTelemetryProperties),\n * will be logged in accordance with their tag, if present.\n *\n * PLEASE take care to avoid setting sensitive data on this object without proper tagging!\n *\n * @internal\n */\nexport class LoggingError\n\textends Error\n\timplements ILoggingError, Omit<IFluidErrorBase, \"errorType\">\n{\n\tprivate _errorInstanceId = uuid();\n\tget errorInstanceId(): string {\n\t\treturn this._errorInstanceId;\n\t}\n\toverwriteErrorInstanceId(id: string): void {\n\t\tthis._errorInstanceId = id;\n\t}\n\n\t/**\n\t * Backwards compatibility to appease {@link isFluidError} in old code that may handle this error.\n\t */\n\t// @ts-expect-error - This field shouldn't be referenced in the current version, but needs to exist at runtime.\n\t// eslint-disable-next-line @typescript-eslint/prefer-as-const\n\tprivate readonly fluidErrorCode: \"-\" = \"-\";\n\n\t/**\n\t * Create a new LoggingError\n\t * @param message - Error message to use for Error base class\n\t * @param props - telemetry props to include on the error for when it's logged\n\t * @param omitPropsFromLogging - properties by name to omit from telemetry props\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\tprops?: ITelemetryBaseProperties,\n\t\tprivate readonly omitPropsFromLogging: Set<string> = new Set(),\n\t) {\n\t\tsuper(message);\n\n\t\t// Don't log this list itself, or the private _errorInstanceId\n\t\tomitPropsFromLogging.add(\"omitPropsFromLogging\");\n\t\tomitPropsFromLogging.add(\"_errorInstanceId\");\n\n\t\tif (props) {\n\t\t\tthis.addTelemetryProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * Determines if a given object is an instance of a LoggingError\n\t * @param object - any object\n\t * @returns true if the object is an instance of a LoggingError, false if not.\n\t */\n\tpublic static typeCheck(object: unknown): object is LoggingError {\n\t\tif (typeof object === \"object\" && object !== null) {\n\t\t\treturn (\n\t\t\t\ttypeof (object as LoggingError).addTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).getTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).errorInstanceId === \"string\"\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Add additional properties to be logged\n\t */\n\tpublic addTelemetryProperties(props: ITelemetryPropertiesExt): void {\n\t\tcopyProps(this, props);\n\t}\n\n\t/**\n\t * Get all properties fit to be logged to telemetry for this error\n\t */\n\tpublic getTelemetryProperties(): ITelemetryBaseProperties {\n\t\t// Only pick properties fit for telemetry out of all of this object's enumerable properties.\n\t\tconst telemetryProps: ITelemetryBaseProperties = {};\n\t\tfor (const key of Object.keys(this)) {\n\t\t\tif (this.omitPropsFromLogging.has(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst val = this[key] as\n\t\t\t\t| TelemetryEventPropertyTypeExt\n\t\t\t\t| Tagged<TelemetryEventPropertyTypeExt>;\n\n\t\t\t// Ensure only valid props get logged, since props of logging error could be in any shape\n\t\t\ttelemetryProps[key] = convertToBasePropertyType(val);\n\t\t}\n\t\t// Ensure a few extra props always exist\n\t\treturn {\n\t\t\t...telemetryProps,\n\t\t\tstack: this.stack,\n\t\t\tmessage: this.message,\n\t\t\terrorInstanceId: this._errorInstanceId,\n\t\t};\n\t}\n}\n\n/**\n * The Error class used when normalizing an external error\n *\n * @internal\n */\nexport const NORMALIZED_ERROR_TYPE = \"genericError\";\n\n/**\n * Subclass of LoggingError returned by normalizeError\n *\n * @internal\n */\nclass NormalizedLoggingError extends LoggingError {\n\t// errorType \"genericError\" is used as a default value throughout the code.\n\t// Note that this matches ContainerErrorTypes/DriverErrorTypes' genericError\n\terrorType = NORMALIZED_ERROR_TYPE;\n\n\tconstructor(errorProps: Pick<IFluidErrorBase, \"message\" | \"stack\">) {\n\t\tsuper(errorProps.message);\n\n\t\tif (errorProps.stack !== undefined) {\n\t\t\toverwriteStack(this, errorProps.stack);\n\t\t}\n\t}\n}\n"]}
@@ -13,7 +13,7 @@ import { IEvent } from "@fluidframework/core-interfaces";
13
13
  * @privateRemarks
14
14
  * This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.
15
15
  * We should consider moving it to the `core-utils` package.
16
- * @public
16
+ * @alpha
17
17
  */
18
18
  export declare class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> extends TypedEventEmitter<TEvent> {
19
19
  private readonly errorHandler;
@@ -15,7 +15,7 @@ const client_utils_1 = require("@fluid-internal/client-utils");
15
15
  * @privateRemarks
16
16
  * This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.
17
17
  * We should consider moving it to the `core-utils` package.
18
- * @public
18
+ * @alpha
19
19
  */
20
20
  class EventEmitterWithErrorHandling extends client_utils_1.TypedEventEmitter {
21
21
  constructor(
@@ -1 +1 @@
1
- {"version":3,"file":"eventEmitterWithErrorHandling.js","sourceRoot":"","sources":["../src/eventEmitterWithErrorHandling.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAAwF;AAGxF;;;;;;;;;;GAUG;AACH,MAAa,6BAEX,SAAQ,gCAAyB;IAClC;IACC,oDAAoD;IACpD,8DAA8D;IAC7C,YAAoE;QAErF,KAAK,EAAE,CAAC;QAFS,iBAAY,GAAZ,YAAY,CAAwD;IAGtF,CAAC;IAEM,IAAI,CAAC,KAA4B,EAAE,GAAG,IAAe;QAC3D,IAAI;YACH,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;SAClC;QAAC,OAAO,KAAK,EAAE;YACf,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;CACD;AAnBD,sEAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter, EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { IEvent } from \"@fluidframework/core-interfaces\";\n\n/**\n * Event Emitter helper class\n *\n * @remarks\n * Any exceptions thrown by listeners will be caught and raised through \"error\" event.\n * Any exception thrown by \"error\" listeners will propagate to the caller.\n * @privateRemarks\n * This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.\n * We should consider moving it to the `core-utils` package.\n * @public\n */\nexport class EventEmitterWithErrorHandling<\n\tTEvent extends IEvent = IEvent,\n> extends TypedEventEmitter<TEvent> {\n\tconstructor(\n\t\t// TODO: use `unknown` instead (breaking API change)\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tprivate readonly errorHandler: (eventName: EventEmitterEventType, error: any) => void,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic emit(event: EventEmitterEventType, ...args: unknown[]): boolean {\n\t\ttry {\n\t\t\treturn super.emit(event, ...args);\n\t\t} catch (error) {\n\t\t\tthis.errorHandler(event, error);\n\t\t\treturn true;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"eventEmitterWithErrorHandling.js","sourceRoot":"","sources":["../src/eventEmitterWithErrorHandling.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAAwF;AAGxF;;;;;;;;;;GAUG;AACH,MAAa,6BAEX,SAAQ,gCAAyB;IAClC;IACC,oDAAoD;IACpD,8DAA8D;IAC7C,YAAoE;QAErF,KAAK,EAAE,CAAC;QAFS,iBAAY,GAAZ,YAAY,CAAwD;IAGtF,CAAC;IAEM,IAAI,CAAC,KAA4B,EAAE,GAAG,IAAe;QAC3D,IAAI;YACH,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;SAClC;QAAC,OAAO,KAAK,EAAE;YACf,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;CACD;AAnBD,sEAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter, EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { IEvent } from \"@fluidframework/core-interfaces\";\n\n/**\n * Event Emitter helper class\n *\n * @remarks\n * Any exceptions thrown by listeners will be caught and raised through \"error\" event.\n * Any exception thrown by \"error\" listeners will propagate to the caller.\n * @privateRemarks\n * This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.\n * We should consider moving it to the `core-utils` package.\n * @alpha\n */\nexport class EventEmitterWithErrorHandling<\n\tTEvent extends IEvent = IEvent,\n> extends TypedEventEmitter<TEvent> {\n\tconstructor(\n\t\t// TODO: use `unknown` instead (breaking API change)\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tprivate readonly errorHandler: (eventName: EventEmitterEventType, error: any) => void,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic emit(event: EventEmitterEventType, ...args: unknown[]): boolean {\n\t\ttry {\n\t\t\treturn super.emit(event, ...args);\n\t\t} catch (error) {\n\t\t\tthis.errorHandler(event, error);\n\t\t\treturn true;\n\t\t}\n\t}\n}\n"]}
package/dist/events.d.ts CHANGED
@@ -2,9 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- /// <reference types="node" />
6
- import { EventEmitter } from "events";
7
- import { ITelemetryLoggerExt } from "./telemetryTypes";
5
+ import type { EventEmitter } from "@fluid-internal/client-utils";
6
+ import { ITelemetryLoggerExt } from "./telemetryTypes.js";
8
7
  /**
9
8
  * Note: The contents of this file really don't belong in this package, as they are only intended for internal use.
10
9
  * They should be moved into the `core-utils` package in the future.
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAGpD;;GAEG;AACH,wBAAgB,cAAc,CAC7B,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,MAAM,EACb,GAAG,IAAI,EAAE,OAAO,EAAE,GAChB,IAAI,CAMN;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,MAAM,GACzB,IAAI,CAUN"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAGpD;;GAEG;AACH,wBAAgB,cAAc,CAC7B,OAAO,EAAE,YAAY,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E,EAAE,KAAK,CAAC,CAAC;KACxE;AACF,CAAC;AAhBD,kDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// False positive: this is an import from the `events` package, not from Node.\n// eslint-disable-next-line unicorn/prefer-node-protocol\nimport { EventEmitter } from \"events\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * Note: The contents of this file really don't belong in this package, as they are only intended for internal use.\n * They should be moved into the `core-utils` package in the future.\n */\n\n/**\n * @internal\n */\nexport const connectedEventName = \"connected\";\n\n/**\n * @internal\n */\nexport const disconnectedEventName = \"disconnected\";\n\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function safeRaiseEvent(\n\temitter: EventEmitter,\n\tlogger: ITelemetryLoggerExt,\n\tevent: string,\n\t...args: unknown[]\n): void {\n\ttry {\n\t\temitter.emit(event, ...args);\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseEventError\", event }, error);\n\t}\n}\n\n/**\n * Raises events pertaining to the connection\n * @param logger - The logger to log telemetry\n * @param emitter - The event emitter instance\n * @param connected - A boolean tracking whether the connection was in a connected state or not\n * @param clientId - The connected/disconnected clientId\n * @param disconnectedReason - The reason for the connection to be disconnected (Used for telemetry purposes only)\n *\n * @internal\n */\nexport function raiseConnectedEvent(\n\tlogger: ITelemetryLoggerExt,\n\temitter: EventEmitter,\n\tconnected: boolean,\n\tclientId?: string,\n\tdisconnectedReason?: string,\n): void {\n\ttry {\n\t\tif (connected) {\n\t\t\temitter.emit(connectedEventName, clientId);\n\t\t} else {\n\t\t\temitter.emit(disconnectedEventName, disconnectedReason);\n\t\t}\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseConnectedEventError\" }, error);\n\t}\n}\n"]}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;;GAGG;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,WAAW,CAAC;AAE9C;;GAEG;AACU,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD,qDAAqD;AACrD;;GAEG;AACH,SAAgB,cAAc,CAC7B,OAAqB,EACrB,MAA2B,EAC3B,KAAa,EACb,GAAG,IAAe;IAElB,IAAI;QACH,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;KAC7B;IAAC,OAAO,KAAK,EAAE;QACf,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;KACtE;AACF,CAAC;AAXD,wCAWC;AAED;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CAClC,MAA2B,EAC3B,OAAqB,EACrB,SAAkB,EAClB,QAAiB,EACjB,kBAA2B;IAE3B,IAAI;QACH,IAAI,SAAS,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,0BAAkB,EAAE,QAAQ,CAAC,CAAC;SAC3C;aAAM;YACN,OAAO,CAAC,IAAI,CAAC,6BAAqB,EAAE,kBAAkB,CAAC,CAAC;SACxD;KACD;IAAC,OAAO,KAAK,EAAE;QACf,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,EAAE,KAAK,CAAC,CAAC;KACxE;AACF,CAAC;AAhBD,kDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Note: The contents of this file really don't belong in this package, as they are only intended for internal use.\n * They should be moved into the `core-utils` package in the future.\n */\n\n/**\n * @internal\n */\nexport const connectedEventName = \"connected\";\n\n/**\n * @internal\n */\nexport const disconnectedEventName = \"disconnected\";\n\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function safeRaiseEvent(\n\temitter: EventEmitter,\n\tlogger: ITelemetryLoggerExt,\n\tevent: string,\n\t...args: unknown[]\n): void {\n\ttry {\n\t\temitter.emit(event, ...args);\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseEventError\", event }, error);\n\t}\n}\n\n/**\n * Raises events pertaining to the connection\n * @param logger - The logger to log telemetry\n * @param emitter - The event emitter instance\n * @param connected - A boolean tracking whether the connection was in a connected state or not\n * @param clientId - The connected/disconnected clientId\n * @param disconnectedReason - The reason for the connection to be disconnected (Used for telemetry purposes only)\n *\n * @internal\n */\nexport function raiseConnectedEvent(\n\tlogger: ITelemetryLoggerExt,\n\temitter: EventEmitter,\n\tconnected: boolean,\n\tclientId?: string,\n\tdisconnectedReason?: string,\n): void {\n\ttry {\n\t\tif (connected) {\n\t\t\temitter.emit(connectedEventName, clientId);\n\t\t} else {\n\t\t\temitter.emit(disconnectedEventName, disconnectedReason);\n\t\t}\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseConnectedEventError\" }, error);\n\t}\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryProperties } from "@fluidframework/core-interfaces";
5
+ import type { ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
6
+ import type { ITelemetryPropertiesExt } from "./telemetryTypes.js";
6
7
  /**
7
8
  * An error emitted by the Fluid Framework.
8
9
  *
@@ -54,11 +55,11 @@ export interface IFluidErrorBase extends Error {
54
55
  /**
55
56
  * Get the telemetry properties stashed on this error for logging.
56
57
  */
57
- getTelemetryProperties(): ITelemetryProperties;
58
+ getTelemetryProperties(): ITelemetryBaseProperties;
58
59
  /**
59
60
  * Add telemetry properties to this error which will be logged with the error
60
61
  */
61
- addTelemetryProperties: (props: ITelemetryProperties) => void;
62
+ addTelemetryProperties: (props: ITelemetryPropertiesExt) => void;
62
63
  }
63
64
  /**
64
65
  * Type guard for error data containing the {@link IFluidErrorBase.errorInstanceId} property.
@@ -1 +1 @@
1
- {"version":3,"file":"fluidErrorBase.d.ts","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAgB,SAAQ,KAAK;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;;;OAOG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,sBAAsB,IAAI,oBAAoB,CAAC;IAE/C;;OAEG;IACH,sBAAsB,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC9D;AAMD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,MAAO,OAAO;qBAA2B,MAAM;CACG,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAMnD"}
1
+ {"version":3,"file":"fluidErrorBase.d.ts","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AA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,CAAC,KAAc;IAC1C,OAAO,CACN,OAAQ,KAAkC,EAAE,SAAS,KAAK,QAAQ;QAClE,OAAQ,KAAkC,EAAE,OAAO,KAAK,QAAQ;QAChE,IAAA,0BAAkB,EAAC,KAAK,CAAC;QACzB,yBAAyB,CAAC,KAAK,CAAC,CAChC,CAAC;AACH,CAAC;AAPD,oCAOC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CACjC,KAAc;IAEd,OAAO,CACN,OAAQ,KAAkC,EAAE,SAAS,KAAK,QAAQ;QAClE,OAAQ,KAAkC,EAAE,OAAO,KAAK,QAAQ;QAChE,yBAAyB,CAAC,KAAK,CAAC,CAChC,CAAC;AACH,CAAC;AARD,gDAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\n\n/**\n * An error emitted by the Fluid Framework.\n *\n * @remarks\n *\n * All normalized errors flowing through the Fluid Framework adhere to this readonly interface.\n *\n * It features the members of {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error}\n * made readonly, as well as {@link IFluidErrorBase.errorType} and {@link IFluidErrorBase.errorInstanceId}.\n * It also features getters and setters for telemetry props to be included when the error is logged.\n *\n * @internal\n */\nexport interface IFluidErrorBase extends Error {\n\t/**\n\t * Classification of what type of error this is.\n\t *\n\t * @remarks Used programmatically by consumers to interpret the error.\n\t */\n\treadonly errorType: string;\n\n\t/**\n\t * Error's message property, made readonly.\n\t *\n\t * @remarks\n\t *\n\t * Recommendations:\n\t *\n\t * Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry.\n\t * Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead.\n\t */\n\treadonly message: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack}.\n\t */\n\treadonly stack?: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name}.\n\t */\n\treadonly name: string;\n\n\t/**\n\t * A Guid identifying this error instance.\n\t *\n\t * @remarks\n\t *\n\t * Useful in telemetry for deduplicating multiple logging events arising from the same error,\n\t * or correlating an error with an inner error that caused it, in case of error wrapping.\n\t */\n\treadonly errorInstanceId: string;\n\n\t/**\n\t * Get the telemetry properties stashed on this error for logging.\n\t */\n\tgetTelemetryProperties(): ITelemetryProperties;\n\n\t/**\n\t * Add telemetry properties to this error which will be logged with the error\n\t */\n\taddTelemetryProperties: (props: ITelemetryProperties) => void;\n}\n\nconst hasTelemetryPropFunctions = (x: unknown): boolean =>\n\ttypeof (x as Partial<IFluidErrorBase>)?.getTelemetryProperties === \"function\" &&\n\ttypeof (x as Partial<IFluidErrorBase>)?.addTelemetryProperties === \"function\";\n\n/**\n * Type guard for error data containing the {@link IFluidErrorBase.errorInstanceId} property.\n *\n * @internal\n */\nexport const hasErrorInstanceId = (x: unknown): x is { errorInstanceId: string } =>\n\ttypeof (x as Partial<{ errorInstanceId: string }>)?.errorInstanceId === \"string\";\n\n/**\n * Type guard for {@link IFluidErrorBase}.\n *\n * @internal\n */\nexport function isFluidError(error: unknown): error is IFluidErrorBase {\n\treturn (\n\t\ttypeof (error as Partial<IFluidErrorBase>)?.errorType === \"string\" &&\n\t\ttypeof (error as Partial<IFluidErrorBase>)?.message === \"string\" &&\n\t\thasErrorInstanceId(error) &&\n\t\thasTelemetryPropFunctions(error)\n\t);\n}\n\n/**\n * Type guard for old standard of valid/known errors.\n *\n * @internal\n */\nexport function isValidLegacyError(\n\terror: unknown,\n): error is Omit<IFluidErrorBase, \"errorInstanceId\"> {\n\treturn (\n\t\ttypeof (error as Partial<IFluidErrorBase>)?.errorType === \"string\" &&\n\t\ttypeof (error as Partial<IFluidErrorBase>)?.message === \"string\" &&\n\t\thasTelemetryPropFunctions(error)\n\t);\n}\n"]}
1
+ {"version":3,"file":"fluidErrorBase.js","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAqEH,MAAM,yBAAyB,GAAG,CAAC,CAAU,EAAW,EAAE,CACzD,OAAQ,CAA8B,EAAE,sBAAsB,KAAK,UAAU;IAC7E,OAAQ,CAA8B,EAAE,sBAAsB,KAAK,UAAU,CAAC;AAE/E;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,CAAU,EAAoC,EAAE,CAClF,OAAQ,CAA0C,EAAE,eAAe,KAAK,QAAQ,CAAC;AADrE,QAAA,kBAAkB,sBACmD;AAElF;;;;GAIG;AACH,SAAgB,YAAY,CAAC,KAAc;IAC1C,OAAO,CACN,OAAQ,KAAkC,EAAE,SAAS,KAAK,QAAQ;QAClE,OAAQ,KAAkC,EAAE,OAAO,KAAK,QAAQ;QAChE,IAAA,0BAAkB,EAAC,KAAK,CAAC;QACzB,yBAAyB,CAAC,KAAK,CAAC,CAChC,CAAC;AACH,CAAC;AAPD,oCAOC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CACjC,KAAc;IAEd,OAAO,CACN,OAAQ,KAAkC,EAAE,SAAS,KAAK,QAAQ;QAClE,OAAQ,KAAkC,EAAE,OAAO,KAAK,QAAQ;QAChE,yBAAyB,CAAC,KAAK,CAAC,CAChC,CAAC;AACH,CAAC;AARD,gDAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport type { ITelemetryPropertiesExt } from \"./telemetryTypes.js\";\n\n/**\n * An error emitted by the Fluid Framework.\n *\n * @remarks\n *\n * All normalized errors flowing through the Fluid Framework adhere to this readonly interface.\n *\n * It features the members of {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error}\n * made readonly, as well as {@link IFluidErrorBase.errorType} and {@link IFluidErrorBase.errorInstanceId}.\n * It also features getters and setters for telemetry props to be included when the error is logged.\n *\n * @internal\n */\nexport interface IFluidErrorBase extends Error {\n\t/**\n\t * Classification of what type of error this is.\n\t *\n\t * @remarks Used programmatically by consumers to interpret the error.\n\t */\n\treadonly errorType: string;\n\n\t/**\n\t * Error's message property, made readonly.\n\t *\n\t * @remarks\n\t *\n\t * Recommendations:\n\t *\n\t * Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry.\n\t * Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead.\n\t */\n\treadonly message: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack}.\n\t */\n\treadonly stack?: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name}.\n\t */\n\treadonly name: string;\n\n\t/**\n\t * A Guid identifying this error instance.\n\t *\n\t * @remarks\n\t *\n\t * Useful in telemetry for deduplicating multiple logging events arising from the same error,\n\t * or correlating an error with an inner error that caused it, in case of error wrapping.\n\t */\n\treadonly errorInstanceId: string;\n\n\t/**\n\t * Get the telemetry properties stashed on this error for logging.\n\t */\n\tgetTelemetryProperties(): ITelemetryBaseProperties;\n\n\t/**\n\t * Add telemetry properties to this error which will be logged with the error\n\t */\n\taddTelemetryProperties: (props: ITelemetryPropertiesExt) => void;\n}\n\nconst hasTelemetryPropFunctions = (x: unknown): boolean =>\n\ttypeof (x as Partial<IFluidErrorBase>)?.getTelemetryProperties === \"function\" &&\n\ttypeof (x as Partial<IFluidErrorBase>)?.addTelemetryProperties === \"function\";\n\n/**\n * Type guard for error data containing the {@link IFluidErrorBase.errorInstanceId} property.\n *\n * @internal\n */\nexport const hasErrorInstanceId = (x: unknown): x is { errorInstanceId: string } =>\n\ttypeof (x as Partial<{ errorInstanceId: string }>)?.errorInstanceId === \"string\";\n\n/**\n * Type guard for {@link IFluidErrorBase}.\n *\n * @internal\n */\nexport function isFluidError(error: unknown): error is IFluidErrorBase {\n\treturn (\n\t\ttypeof (error as Partial<IFluidErrorBase>)?.errorType === \"string\" &&\n\t\ttypeof (error as Partial<IFluidErrorBase>)?.message === \"string\" &&\n\t\thasErrorInstanceId(error) &&\n\t\thasTelemetryPropFunctions(error)\n\t);\n}\n\n/**\n * Type guard for old standard of valid/known errors.\n *\n * @internal\n */\nexport function isValidLegacyError(\n\terror: unknown,\n): error is Omit<IFluidErrorBase, \"errorInstanceId\"> {\n\treturn (\n\t\ttypeof (error as Partial<IFluidErrorBase>)?.errorType === \"string\" &&\n\t\ttypeof (error as Partial<IFluidErrorBase>)?.message === \"string\" &&\n\t\thasTelemetryPropFunctions(error)\n\t);\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -2,16 +2,16 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { createChildMonitoringContext, MonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, IConfigProvider, loggerToMonitoringContext, wrapConfigProviderWithDefaults, } from "./config";
6
- export { DataCorruptionError, DataProcessingError, extractSafePropertiesFromMessage, GenericError, UsageError, validatePrecondition, } from "./error";
7
- export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, IFluidErrorAnnotations, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, overwriteStack, wrapError, wrapErrorAndLog, } from "./errorLogging";
8
- export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling";
9
- export { connectedEventName, disconnectedEventName, raiseConnectedEvent, safeRaiseEvent, } from "./events";
10
- export { hasErrorInstanceId, IFluidErrorBase, isFluidError, isValidLegacyError, } from "./fluidErrorBase";
11
- export { eventNamespaceSeparator, createChildLogger, createMultiSinkLogger, formatTick, IPerformanceEventMarkers, ITelemetryLoggerPropertyBag, ITelemetryLoggerPropertyBags, MultiSinkLoggerProperties, numberFromString, PerformanceEvent, TaggedLoggerAdapter, tagData, tagCodeArtifacts, TelemetryDataTag, TelemetryEventPropertyTypes, TelemetryNullLogger, } from "./logger";
12
- export { MockLogger } from "./mockLogger";
13
- export { ThresholdCounter } from "./thresholdCounter";
14
- export { SampledTelemetryHelper } from "./sampledTelemetryHelper";
15
- export { logIfFalse, createSampledLogger, IEventSampler, ISampledTelemetryLogger } from "./utils";
16
- export { TelemetryEventPropertyTypeExt, ITelemetryEventExt, ITelemetryGenericEventExt, ITelemetryErrorEventExt, ITelemetryPerformanceEventExt, ITelemetryLoggerExt, ITaggedTelemetryPropertyTypeExt, ITelemetryPropertiesExt, TelemetryEventCategory, } from "./telemetryTypes";
5
+ export { createChildMonitoringContext, MonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, IConfigProvider, loggerToMonitoringContext, wrapConfigProviderWithDefaults, } from "./config.js";
6
+ export { DataCorruptionError, DataProcessingError, extractSafePropertiesFromMessage, GenericError, UsageError, validatePrecondition, } from "./error.js";
7
+ export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, IFluidErrorAnnotations, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, overwriteStack, wrapError, wrapErrorAndLog, } from "./errorLogging.js";
8
+ export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling.js";
9
+ export { connectedEventName, disconnectedEventName, raiseConnectedEvent, safeRaiseEvent, } from "./events.js";
10
+ export { hasErrorInstanceId, IFluidErrorBase, isFluidError, isValidLegacyError, } from "./fluidErrorBase.js";
11
+ export { eventNamespaceSeparator, createChildLogger, createMultiSinkLogger, formatTick, IPerformanceEventMarkers, ITelemetryLoggerPropertyBag, ITelemetryLoggerPropertyBags, MultiSinkLoggerProperties, numberFromString, PerformanceEvent, TaggedLoggerAdapter, tagData, tagCodeArtifacts, TelemetryDataTag, TelemetryEventPropertyTypes, } from "./logger.js";
12
+ export { MockLogger } from "./mockLogger.js";
13
+ export { ThresholdCounter } from "./thresholdCounter.js";
14
+ export { SampledTelemetryHelper } from "./sampledTelemetryHelper.js";
15
+ export { createSampledLogger, IEventSampler, ISampledTelemetryLogger } from "./utils.js";
16
+ export { TelemetryEventPropertyTypeExt, ITelemetryEventExt, ITelemetryGenericEventExt, ITelemetryErrorEventExt, ITelemetryPerformanceEventExt, ITelemetryLoggerExt, ITaggedTelemetryPropertyTypeExt, ITelemetryPropertiesExt, TelemetryEventCategory, } from "./telemetryTypes.js";
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAC5B,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EACzB,8BAA8B,GAC9B,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,gCAAgC,EAChC,YAAY,EACZ,UAAU,EACV,oBAAoB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,SAAS,EACT,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,EACzB,gBAAgB,EAChB,gB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ACN,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,GAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EACN,6BAA6B,EAC7B,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,EACvB,sBAAsB,GACtB,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,67 +1,65 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSampledLogger = exports.logIfFalse = exports.SampledTelemetryHelper = exports.ThresholdCounter = exports.MockLogger = exports.TelemetryNullLogger = exports.TelemetryDataTag = exports.tagCodeArtifacts = exports.tagData = exports.TaggedLoggerAdapter = exports.PerformanceEvent = exports.numberFromString = exports.formatTick = exports.createMultiSinkLogger = exports.createChildLogger = exports.eventNamespaceSeparator = exports.isValidLegacyError = exports.isFluidError = exports.hasErrorInstanceId = exports.safeRaiseEvent = exports.raiseConnectedEvent = exports.disconnectedEventName = exports.connectedEventName = exports.EventEmitterWithErrorHandling = exports.wrapErrorAndLog = exports.wrapError = exports.overwriteStack = exports.normalizeError = exports.NORMALIZED_ERROR_TYPE = exports.LoggingError = exports.isTaggedTelemetryPropertyValue = exports.isILoggingError = exports.isExternalError = exports.getCircularReplacer = exports.generateStack = exports.generateErrorWithStack = exports.extractLogSafeErrorProperties = exports.validatePrecondition = exports.UsageError = exports.GenericError = exports.extractSafePropertiesFromMessage = exports.DataProcessingError = exports.DataCorruptionError = exports.wrapConfigProviderWithDefaults = exports.loggerToMonitoringContext = exports.mixinMonitoringContext = exports.sessionStorageConfigProvider = exports.createChildMonitoringContext = void 0;
3
+ exports.createSampledLogger = exports.SampledTelemetryHelper = exports.ThresholdCounter = exports.MockLogger = exports.TelemetryDataTag = exports.tagCodeArtifacts = exports.tagData = exports.TaggedLoggerAdapter = exports.PerformanceEvent = exports.numberFromString = exports.formatTick = exports.createMultiSinkLogger = exports.createChildLogger = exports.eventNamespaceSeparator = exports.isValidLegacyError = exports.isFluidError = exports.hasErrorInstanceId = exports.safeRaiseEvent = exports.raiseConnectedEvent = exports.disconnectedEventName = exports.connectedEventName = exports.EventEmitterWithErrorHandling = exports.wrapErrorAndLog = exports.wrapError = exports.overwriteStack = exports.normalizeError = exports.NORMALIZED_ERROR_TYPE = exports.LoggingError = exports.isTaggedTelemetryPropertyValue = exports.isILoggingError = exports.isExternalError = exports.getCircularReplacer = exports.generateStack = exports.generateErrorWithStack = exports.extractLogSafeErrorProperties = exports.validatePrecondition = exports.UsageError = exports.GenericError = exports.extractSafePropertiesFromMessage = exports.DataProcessingError = exports.DataCorruptionError = exports.wrapConfigProviderWithDefaults = exports.loggerToMonitoringContext = exports.mixinMonitoringContext = exports.sessionStorageConfigProvider = exports.createChildMonitoringContext = void 0;
4
4
  /*!
5
5
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
6
6
  * Licensed under the MIT License.
7
7
  */
8
- var config_1 = require("./config");
9
- Object.defineProperty(exports, "createChildMonitoringContext", { enumerable: true, get: function () { return config_1.createChildMonitoringContext; } });
10
- Object.defineProperty(exports, "sessionStorageConfigProvider", { enumerable: true, get: function () { return config_1.sessionStorageConfigProvider; } });
11
- Object.defineProperty(exports, "mixinMonitoringContext", { enumerable: true, get: function () { return config_1.mixinMonitoringContext; } });
12
- Object.defineProperty(exports, "loggerToMonitoringContext", { enumerable: true, get: function () { return config_1.loggerToMonitoringContext; } });
13
- Object.defineProperty(exports, "wrapConfigProviderWithDefaults", { enumerable: true, get: function () { return config_1.wrapConfigProviderWithDefaults; } });
14
- var error_1 = require("./error");
15
- Object.defineProperty(exports, "DataCorruptionError", { enumerable: true, get: function () { return error_1.DataCorruptionError; } });
16
- Object.defineProperty(exports, "DataProcessingError", { enumerable: true, get: function () { return error_1.DataProcessingError; } });
17
- Object.defineProperty(exports, "extractSafePropertiesFromMessage", { enumerable: true, get: function () { return error_1.extractSafePropertiesFromMessage; } });
18
- Object.defineProperty(exports, "GenericError", { enumerable: true, get: function () { return error_1.GenericError; } });
19
- Object.defineProperty(exports, "UsageError", { enumerable: true, get: function () { return error_1.UsageError; } });
20
- Object.defineProperty(exports, "validatePrecondition", { enumerable: true, get: function () { return error_1.validatePrecondition; } });
21
- var errorLogging_1 = require("./errorLogging");
22
- Object.defineProperty(exports, "extractLogSafeErrorProperties", { enumerable: true, get: function () { return errorLogging_1.extractLogSafeErrorProperties; } });
23
- Object.defineProperty(exports, "generateErrorWithStack", { enumerable: true, get: function () { return errorLogging_1.generateErrorWithStack; } });
24
- Object.defineProperty(exports, "generateStack", { enumerable: true, get: function () { return errorLogging_1.generateStack; } });
25
- Object.defineProperty(exports, "getCircularReplacer", { enumerable: true, get: function () { return errorLogging_1.getCircularReplacer; } });
26
- Object.defineProperty(exports, "isExternalError", { enumerable: true, get: function () { return errorLogging_1.isExternalError; } });
27
- Object.defineProperty(exports, "isILoggingError", { enumerable: true, get: function () { return errorLogging_1.isILoggingError; } });
28
- Object.defineProperty(exports, "isTaggedTelemetryPropertyValue", { enumerable: true, get: function () { return errorLogging_1.isTaggedTelemetryPropertyValue; } });
29
- Object.defineProperty(exports, "LoggingError", { enumerable: true, get: function () { return errorLogging_1.LoggingError; } });
30
- Object.defineProperty(exports, "NORMALIZED_ERROR_TYPE", { enumerable: true, get: function () { return errorLogging_1.NORMALIZED_ERROR_TYPE; } });
31
- Object.defineProperty(exports, "normalizeError", { enumerable: true, get: function () { return errorLogging_1.normalizeError; } });
32
- Object.defineProperty(exports, "overwriteStack", { enumerable: true, get: function () { return errorLogging_1.overwriteStack; } });
33
- Object.defineProperty(exports, "wrapError", { enumerable: true, get: function () { return errorLogging_1.wrapError; } });
34
- Object.defineProperty(exports, "wrapErrorAndLog", { enumerable: true, get: function () { return errorLogging_1.wrapErrorAndLog; } });
35
- var eventEmitterWithErrorHandling_1 = require("./eventEmitterWithErrorHandling");
36
- Object.defineProperty(exports, "EventEmitterWithErrorHandling", { enumerable: true, get: function () { return eventEmitterWithErrorHandling_1.EventEmitterWithErrorHandling; } });
37
- var events_1 = require("./events");
38
- Object.defineProperty(exports, "connectedEventName", { enumerable: true, get: function () { return events_1.connectedEventName; } });
39
- Object.defineProperty(exports, "disconnectedEventName", { enumerable: true, get: function () { return events_1.disconnectedEventName; } });
40
- Object.defineProperty(exports, "raiseConnectedEvent", { enumerable: true, get: function () { return events_1.raiseConnectedEvent; } });
41
- Object.defineProperty(exports, "safeRaiseEvent", { enumerable: true, get: function () { return events_1.safeRaiseEvent; } });
42
- var fluidErrorBase_1 = require("./fluidErrorBase");
43
- Object.defineProperty(exports, "hasErrorInstanceId", { enumerable: true, get: function () { return fluidErrorBase_1.hasErrorInstanceId; } });
44
- Object.defineProperty(exports, "isFluidError", { enumerable: true, get: function () { return fluidErrorBase_1.isFluidError; } });
45
- Object.defineProperty(exports, "isValidLegacyError", { enumerable: true, get: function () { return fluidErrorBase_1.isValidLegacyError; } });
46
- var logger_1 = require("./logger");
47
- Object.defineProperty(exports, "eventNamespaceSeparator", { enumerable: true, get: function () { return logger_1.eventNamespaceSeparator; } });
48
- Object.defineProperty(exports, "createChildLogger", { enumerable: true, get: function () { return logger_1.createChildLogger; } });
49
- Object.defineProperty(exports, "createMultiSinkLogger", { enumerable: true, get: function () { return logger_1.createMultiSinkLogger; } });
50
- Object.defineProperty(exports, "formatTick", { enumerable: true, get: function () { return logger_1.formatTick; } });
51
- Object.defineProperty(exports, "numberFromString", { enumerable: true, get: function () { return logger_1.numberFromString; } });
52
- Object.defineProperty(exports, "PerformanceEvent", { enumerable: true, get: function () { return logger_1.PerformanceEvent; } });
53
- Object.defineProperty(exports, "TaggedLoggerAdapter", { enumerable: true, get: function () { return logger_1.TaggedLoggerAdapter; } });
54
- Object.defineProperty(exports, "tagData", { enumerable: true, get: function () { return logger_1.tagData; } });
55
- Object.defineProperty(exports, "tagCodeArtifacts", { enumerable: true, get: function () { return logger_1.tagCodeArtifacts; } });
56
- Object.defineProperty(exports, "TelemetryDataTag", { enumerable: true, get: function () { return logger_1.TelemetryDataTag; } });
57
- Object.defineProperty(exports, "TelemetryNullLogger", { enumerable: true, get: function () { return logger_1.TelemetryNullLogger; } });
58
- var mockLogger_1 = require("./mockLogger");
59
- Object.defineProperty(exports, "MockLogger", { enumerable: true, get: function () { return mockLogger_1.MockLogger; } });
60
- var thresholdCounter_1 = require("./thresholdCounter");
61
- Object.defineProperty(exports, "ThresholdCounter", { enumerable: true, get: function () { return thresholdCounter_1.ThresholdCounter; } });
62
- var sampledTelemetryHelper_1 = require("./sampledTelemetryHelper");
63
- Object.defineProperty(exports, "SampledTelemetryHelper", { enumerable: true, get: function () { return sampledTelemetryHelper_1.SampledTelemetryHelper; } });
64
- var utils_1 = require("./utils");
65
- Object.defineProperty(exports, "logIfFalse", { enumerable: true, get: function () { return utils_1.logIfFalse; } });
66
- Object.defineProperty(exports, "createSampledLogger", { enumerable: true, get: function () { return utils_1.createSampledLogger; } });
8
+ var config_js_1 = require("./config.js");
9
+ Object.defineProperty(exports, "createChildMonitoringContext", { enumerable: true, get: function () { return config_js_1.createChildMonitoringContext; } });
10
+ Object.defineProperty(exports, "sessionStorageConfigProvider", { enumerable: true, get: function () { return config_js_1.sessionStorageConfigProvider; } });
11
+ Object.defineProperty(exports, "mixinMonitoringContext", { enumerable: true, get: function () { return config_js_1.mixinMonitoringContext; } });
12
+ Object.defineProperty(exports, "loggerToMonitoringContext", { enumerable: true, get: function () { return config_js_1.loggerToMonitoringContext; } });
13
+ Object.defineProperty(exports, "wrapConfigProviderWithDefaults", { enumerable: true, get: function () { return config_js_1.wrapConfigProviderWithDefaults; } });
14
+ var error_js_1 = require("./error.js");
15
+ Object.defineProperty(exports, "DataCorruptionError", { enumerable: true, get: function () { return error_js_1.DataCorruptionError; } });
16
+ Object.defineProperty(exports, "DataProcessingError", { enumerable: true, get: function () { return error_js_1.DataProcessingError; } });
17
+ Object.defineProperty(exports, "extractSafePropertiesFromMessage", { enumerable: true, get: function () { return error_js_1.extractSafePropertiesFromMessage; } });
18
+ Object.defineProperty(exports, "GenericError", { enumerable: true, get: function () { return error_js_1.GenericError; } });
19
+ Object.defineProperty(exports, "UsageError", { enumerable: true, get: function () { return error_js_1.UsageError; } });
20
+ Object.defineProperty(exports, "validatePrecondition", { enumerable: true, get: function () { return error_js_1.validatePrecondition; } });
21
+ var errorLogging_js_1 = require("./errorLogging.js");
22
+ Object.defineProperty(exports, "extractLogSafeErrorProperties", { enumerable: true, get: function () { return errorLogging_js_1.extractLogSafeErrorProperties; } });
23
+ Object.defineProperty(exports, "generateErrorWithStack", { enumerable: true, get: function () { return errorLogging_js_1.generateErrorWithStack; } });
24
+ Object.defineProperty(exports, "generateStack", { enumerable: true, get: function () { return errorLogging_js_1.generateStack; } });
25
+ Object.defineProperty(exports, "getCircularReplacer", { enumerable: true, get: function () { return errorLogging_js_1.getCircularReplacer; } });
26
+ Object.defineProperty(exports, "isExternalError", { enumerable: true, get: function () { return errorLogging_js_1.isExternalError; } });
27
+ Object.defineProperty(exports, "isILoggingError", { enumerable: true, get: function () { return errorLogging_js_1.isILoggingError; } });
28
+ Object.defineProperty(exports, "isTaggedTelemetryPropertyValue", { enumerable: true, get: function () { return errorLogging_js_1.isTaggedTelemetryPropertyValue; } });
29
+ Object.defineProperty(exports, "LoggingError", { enumerable: true, get: function () { return errorLogging_js_1.LoggingError; } });
30
+ Object.defineProperty(exports, "NORMALIZED_ERROR_TYPE", { enumerable: true, get: function () { return errorLogging_js_1.NORMALIZED_ERROR_TYPE; } });
31
+ Object.defineProperty(exports, "normalizeError", { enumerable: true, get: function () { return errorLogging_js_1.normalizeError; } });
32
+ Object.defineProperty(exports, "overwriteStack", { enumerable: true, get: function () { return errorLogging_js_1.overwriteStack; } });
33
+ Object.defineProperty(exports, "wrapError", { enumerable: true, get: function () { return errorLogging_js_1.wrapError; } });
34
+ Object.defineProperty(exports, "wrapErrorAndLog", { enumerable: true, get: function () { return errorLogging_js_1.wrapErrorAndLog; } });
35
+ var eventEmitterWithErrorHandling_js_1 = require("./eventEmitterWithErrorHandling.js");
36
+ Object.defineProperty(exports, "EventEmitterWithErrorHandling", { enumerable: true, get: function () { return eventEmitterWithErrorHandling_js_1.EventEmitterWithErrorHandling; } });
37
+ var events_js_1 = require("./events.js");
38
+ Object.defineProperty(exports, "connectedEventName", { enumerable: true, get: function () { return events_js_1.connectedEventName; } });
39
+ Object.defineProperty(exports, "disconnectedEventName", { enumerable: true, get: function () { return events_js_1.disconnectedEventName; } });
40
+ Object.defineProperty(exports, "raiseConnectedEvent", { enumerable: true, get: function () { return events_js_1.raiseConnectedEvent; } });
41
+ Object.defineProperty(exports, "safeRaiseEvent", { enumerable: true, get: function () { return events_js_1.safeRaiseEvent; } });
42
+ var fluidErrorBase_js_1 = require("./fluidErrorBase.js");
43
+ Object.defineProperty(exports, "hasErrorInstanceId", { enumerable: true, get: function () { return fluidErrorBase_js_1.hasErrorInstanceId; } });
44
+ Object.defineProperty(exports, "isFluidError", { enumerable: true, get: function () { return fluidErrorBase_js_1.isFluidError; } });
45
+ Object.defineProperty(exports, "isValidLegacyError", { enumerable: true, get: function () { return fluidErrorBase_js_1.isValidLegacyError; } });
46
+ var logger_js_1 = require("./logger.js");
47
+ Object.defineProperty(exports, "eventNamespaceSeparator", { enumerable: true, get: function () { return logger_js_1.eventNamespaceSeparator; } });
48
+ Object.defineProperty(exports, "createChildLogger", { enumerable: true, get: function () { return logger_js_1.createChildLogger; } });
49
+ Object.defineProperty(exports, "createMultiSinkLogger", { enumerable: true, get: function () { return logger_js_1.createMultiSinkLogger; } });
50
+ Object.defineProperty(exports, "formatTick", { enumerable: true, get: function () { return logger_js_1.formatTick; } });
51
+ Object.defineProperty(exports, "numberFromString", { enumerable: true, get: function () { return logger_js_1.numberFromString; } });
52
+ Object.defineProperty(exports, "PerformanceEvent", { enumerable: true, get: function () { return logger_js_1.PerformanceEvent; } });
53
+ Object.defineProperty(exports, "TaggedLoggerAdapter", { enumerable: true, get: function () { return logger_js_1.TaggedLoggerAdapter; } });
54
+ Object.defineProperty(exports, "tagData", { enumerable: true, get: function () { return logger_js_1.tagData; } });
55
+ Object.defineProperty(exports, "tagCodeArtifacts", { enumerable: true, get: function () { return logger_js_1.tagCodeArtifacts; } });
56
+ Object.defineProperty(exports, "TelemetryDataTag", { enumerable: true, get: function () { return logger_js_1.TelemetryDataTag; } });
57
+ var mockLogger_js_1 = require("./mockLogger.js");
58
+ Object.defineProperty(exports, "MockLogger", { enumerable: true, get: function () { return mockLogger_js_1.MockLogger; } });
59
+ var thresholdCounter_js_1 = require("./thresholdCounter.js");
60
+ Object.defineProperty(exports, "ThresholdCounter", { enumerable: true, get: function () { return thresholdCounter_js_1.ThresholdCounter; } });
61
+ var sampledTelemetryHelper_js_1 = require("./sampledTelemetryHelper.js");
62
+ Object.defineProperty(exports, "SampledTelemetryHelper", { enumerable: true, get: function () { return sampledTelemetryHelper_js_1.SampledTelemetryHelper; } });
63
+ var utils_js_1 = require("./utils.js");
64
+ Object.defineProperty(exports, "createSampledLogger", { enumerable: true, get: function () { return utils_js_1.createSampledLogger; } });
67
65
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"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AAA,OAAO,OAAA;AACP,0GAAA,gBAAgB,OAAA;AAChB,0GAAA,gBAAgB,OAAA;AAEhB,6GAAA,mBAAmB,OAAA;AAEpB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,iCAAkG;AAAzF,mGAAA,UAAU,OAAA;AAAE,4GAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport {\n\tcreateChildMonitoringContext,\n\tMonitoringContext,\n\tsessionStorageConfigProvider,\n\tmixinMonitoringContext,\n\tIConfigProvider,\n\tloggerToMonitoringContext,\n\twrapConfigProviderWithDefaults,\n} from \"./config\";\nexport {\n\tDataCorruptionError,\n\tDataProcessingError,\n\textractSafePropertiesFromMessage,\n\tGenericError,\n\tUsageError,\n\tvalidatePrecondition,\n} from \"./error\";\nexport {\n\textractLogSafeErrorProperties,\n\tgenerateErrorWithStack,\n\tgenerateStack,\n\tgetCircularReplacer,\n\tIFluidErrorAnnotations,\n\tisExternalError,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n\tLoggingError,\n\tNORMALIZED_ERROR_TYPE,\n\tnormalizeError,\n\toverwriteStack,\n\twrapError,\n\twrapErrorAndLog,\n} from \"./errorLogging\";\nexport { EventEmitterWithErrorHandling } from \"./eventEmitterWithErrorHandling\";\nexport {\n\tconnectedEventName,\n\tdisconnectedEventName,\n\traiseConnectedEvent,\n\tsafeRaiseEvent,\n} from \"./events\";\nexport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nexport {\n\teventNamespaceSeparator,\n\tcreateChildLogger,\n\tcreateMultiSinkLogger,\n\tformatTick,\n\tIPerformanceEventMarkers,\n\tITelemetryLoggerPropertyBag,\n\tITelemetryLoggerPropertyBags,\n\tMultiSinkLoggerProperties,\n\tnumberFromString,\n\tPerformanceEvent,\n\tTaggedLoggerAdapter,\n\ttagData,\n\ttagCodeArtifacts,\n\tTelemetryDataTag,\n\tTelemetryEventPropertyTypes,\n\tTelemetryNullLogger,\n} from \"./logger\";\nexport { MockLogger } from \"./mockLogger\";\nexport { ThresholdCounter } from \"./thresholdCounter\";\nexport { SampledTelemetryHelper } from \"./sampledTelemetryHelper\";\nexport { logIfFalse, createSampledLogger, IEventSampler, ISampledTelemetryLogger } from \"./utils\";\nexport {\n\tTelemetryEventPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryErrorEventExt,\n\tITelemetryPerformanceEventExt,\n\tITelemetryLoggerExt,\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryPropertiesExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypes\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,yCAQqB;AAPpB,yHAAA,4BAA4B,OAAA;AAE5B,yHAAA,4BAA4B,OAAA;AAC5B,mHAAA,sBAAsB,OAAA;AAEtB,sHAAA,yBAAyB,OAAA;AACzB,2HAAA,8BAA8B,OAAA;AAE/B,uCAOoB;AANnB,+GAAA,mBAAmB,OAAA;AACnB,+GAAA,mBAAmB,OAAA;AACnB,4HAAA,gCAAgC,OAAA;AAChC,wGAAA,YAAY,OAAA;AACZ,sGAAA,UAAU,OAAA;AACV,gHAAA,oBAAoB,OAAA;AAErB,qDAe2B;AAd1B,gIAAA,6BAA6B,OAAA;AAC7B,yHAAA,sBAAsB,OAAA;AACtB,gHAAA,aAAa,OAAA;AACb,sHAAA,mBAAmB,OAAA;AAEnB,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,iIAAA,8BAA8B,OAAA;AAC9B,+GAAA,YAAY,OAAA;AACZ,wHAAA,qBAAqB,OAAA;AACrB,iHAAA,cAAc,OAAA;AACd,iHAAA,cAAc,OAAA;AACd,4GAAA,SAAS,OAAA;AACT,kHAAA,eAAe,OAAA;AAEhB,uFAAmF;AAA1E,iJAAA,6BAA6B,OAAA;AACtC,yCAKqB;AAJpB,+GAAA,kBAAkB,OAAA;AAClB,kHAAA,qBAAqB,OAAA;AACrB,gHAAA,mBAAmB,OAAA;AACnB,2GAAA,cAAc,OAAA;AAEf,yDAK6B;AAJ5B,uHAAA,kBAAkB,OAAA;AAElB,iHAAA,YAAY,OAAA;AACZ,uHAAA,kBAAkB,OAAA;AAEnB,yCAgBqB;AAfpB,oHAAA,uBAAuB,OAAA;AACvB,8GAAA,iBAAiB,OAAA;AACjB,kHAAA,qBAAqB,OAAA;AACrB,uGAAA,UAAU,OAAA;AAKV,6GAAA,gBAAgB,OAAA;AAChB,6GAAA,gBAAgB,OAAA;AAChB,gHAAA,mBAAmB,OAAA;AACnB,oGAAA,OAAO,OAAA;AACP,6GAAA,gBAAgB,OAAA;AAChB,6GAAA,gBAAgB,OAAA;AAGjB,iDAA6C;AAApC,2GAAA,UAAU,OAAA;AACnB,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AACzB,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,uCAAyF;AAAhF,+GAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport {\n\tcreateChildMonitoringContext,\n\tMonitoringContext,\n\tsessionStorageConfigProvider,\n\tmixinMonitoringContext,\n\tIConfigProvider,\n\tloggerToMonitoringContext,\n\twrapConfigProviderWithDefaults,\n} from \"./config.js\";\nexport {\n\tDataCorruptionError,\n\tDataProcessingError,\n\textractSafePropertiesFromMessage,\n\tGenericError,\n\tUsageError,\n\tvalidatePrecondition,\n} from \"./error.js\";\nexport {\n\textractLogSafeErrorProperties,\n\tgenerateErrorWithStack,\n\tgenerateStack,\n\tgetCircularReplacer,\n\tIFluidErrorAnnotations,\n\tisExternalError,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n\tLoggingError,\n\tNORMALIZED_ERROR_TYPE,\n\tnormalizeError,\n\toverwriteStack,\n\twrapError,\n\twrapErrorAndLog,\n} from \"./errorLogging.js\";\nexport { EventEmitterWithErrorHandling } from \"./eventEmitterWithErrorHandling.js\";\nexport {\n\tconnectedEventName,\n\tdisconnectedEventName,\n\traiseConnectedEvent,\n\tsafeRaiseEvent,\n} from \"./events.js\";\nexport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase.js\";\nexport {\n\teventNamespaceSeparator,\n\tcreateChildLogger,\n\tcreateMultiSinkLogger,\n\tformatTick,\n\tIPerformanceEventMarkers,\n\tITelemetryLoggerPropertyBag,\n\tITelemetryLoggerPropertyBags,\n\tMultiSinkLoggerProperties,\n\tnumberFromString,\n\tPerformanceEvent,\n\tTaggedLoggerAdapter,\n\ttagData,\n\ttagCodeArtifacts,\n\tTelemetryDataTag,\n\tTelemetryEventPropertyTypes,\n} from \"./logger.js\";\nexport { MockLogger } from \"./mockLogger.js\";\nexport { ThresholdCounter } from \"./thresholdCounter.js\";\nexport { SampledTelemetryHelper } from \"./sampledTelemetryHelper.js\";\nexport { createSampledLogger, IEventSampler, ISampledTelemetryLogger } from \"./utils.js\";\nexport {\n\tTelemetryEventPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryErrorEventExt,\n\tITelemetryPerformanceEventExt,\n\tITelemetryLoggerExt,\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryPropertiesExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypes.js\";\n"]}