@fluidframework/telemetry-utils 2.0.0-dev-rc.5.0.0.271717 → 2.0.0-dev-rc.5.0.0.272251

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 (94) hide show
  1. package/.eslintrc.cjs +1 -1
  2. package/api-extractor/api-extractor-lint-bundle.json +5 -0
  3. package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
  4. package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
  5. package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
  6. package/api-extractor/api-extractor-lint-public.esm.json +5 -0
  7. package/api-report/telemetry-utils.alpha.api.md +13 -28
  8. package/api-report/telemetry-utils.beta.api.md +7 -7
  9. package/api-report/telemetry-utils.public.api.md +7 -7
  10. package/dist/config.d.ts +2 -2
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/config.js.map +1 -1
  13. package/dist/error.d.ts +5 -5
  14. package/dist/error.d.ts.map +1 -1
  15. package/dist/error.js.map +1 -1
  16. package/dist/errorLogging.d.ts +1 -1
  17. package/dist/errorLogging.d.ts.map +1 -1
  18. package/dist/errorLogging.js +21 -8
  19. package/dist/errorLogging.js.map +1 -1
  20. package/dist/eventEmitterWithErrorHandling.d.ts +2 -2
  21. package/dist/eventEmitterWithErrorHandling.d.ts.map +1 -1
  22. package/dist/eventEmitterWithErrorHandling.js.map +1 -1
  23. package/dist/index.d.ts +6 -6
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/logger.d.ts +3 -5
  27. package/dist/logger.d.ts.map +1 -1
  28. package/dist/logger.js.map +1 -1
  29. package/dist/mockLogger.d.ts +15 -7
  30. package/dist/mockLogger.d.ts.map +1 -1
  31. package/dist/mockLogger.js +16 -9
  32. package/dist/mockLogger.js.map +1 -1
  33. package/dist/sampledTelemetryHelper.d.ts +6 -2
  34. package/dist/sampledTelemetryHelper.d.ts.map +1 -1
  35. package/dist/sampledTelemetryHelper.js +10 -2
  36. package/dist/sampledTelemetryHelper.js.map +1 -1
  37. package/dist/telemetryTypes.d.ts +32 -18
  38. package/dist/telemetryTypes.d.ts.map +1 -1
  39. package/dist/telemetryTypes.js.map +1 -1
  40. package/dist/thresholdCounter.d.ts +1 -1
  41. package/dist/thresholdCounter.d.ts.map +1 -1
  42. package/dist/thresholdCounter.js.map +1 -1
  43. package/dist/utils.d.ts +1 -1
  44. package/dist/utils.d.ts.map +1 -1
  45. package/dist/utils.js.map +1 -1
  46. package/lib/config.d.ts +2 -2
  47. package/lib/config.d.ts.map +1 -1
  48. package/lib/config.js.map +1 -1
  49. package/lib/error.d.ts +5 -5
  50. package/lib/error.d.ts.map +1 -1
  51. package/lib/error.js.map +1 -1
  52. package/lib/errorLogging.d.ts +1 -1
  53. package/lib/errorLogging.d.ts.map +1 -1
  54. package/lib/errorLogging.js +21 -8
  55. package/lib/errorLogging.js.map +1 -1
  56. package/lib/eventEmitterWithErrorHandling.d.ts +2 -2
  57. package/lib/eventEmitterWithErrorHandling.d.ts.map +1 -1
  58. package/lib/eventEmitterWithErrorHandling.js.map +1 -1
  59. package/lib/index.d.ts +6 -6
  60. package/lib/index.d.ts.map +1 -1
  61. package/lib/index.js.map +1 -1
  62. package/lib/logger.d.ts +3 -5
  63. package/lib/logger.d.ts.map +1 -1
  64. package/lib/logger.js.map +1 -1
  65. package/lib/mockLogger.d.ts +15 -7
  66. package/lib/mockLogger.d.ts.map +1 -1
  67. package/lib/mockLogger.js +16 -9
  68. package/lib/mockLogger.js.map +1 -1
  69. package/lib/sampledTelemetryHelper.d.ts +6 -2
  70. package/lib/sampledTelemetryHelper.d.ts.map +1 -1
  71. package/lib/sampledTelemetryHelper.js +10 -2
  72. package/lib/sampledTelemetryHelper.js.map +1 -1
  73. package/lib/telemetryTypes.d.ts +32 -18
  74. package/lib/telemetryTypes.d.ts.map +1 -1
  75. package/lib/telemetryTypes.js.map +1 -1
  76. package/lib/thresholdCounter.d.ts +1 -1
  77. package/lib/thresholdCounter.d.ts.map +1 -1
  78. package/lib/thresholdCounter.js.map +1 -1
  79. package/lib/utils.d.ts +1 -1
  80. package/lib/utils.d.ts.map +1 -1
  81. package/lib/utils.js.map +1 -1
  82. package/package.json +16 -7
  83. package/src/config.ts +10 -10
  84. package/src/error.ts +13 -13
  85. package/src/errorLogging.ts +27 -14
  86. package/src/eventEmitterWithErrorHandling.ts +3 -3
  87. package/src/index.ts +11 -11
  88. package/src/logger.ts +11 -10
  89. package/src/mockLogger.ts +34 -20
  90. package/src/sampledTelemetryHelper.ts +15 -5
  91. package/src/telemetryTypes.ts +38 -19
  92. package/src/thresholdCounter.ts +1 -1
  93. package/src/utils.ts +2 -2
  94. package/tsdoc.json +4 -0
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryBaseLogger, LogLevel, Tagged } from "@fluidframework/core-interfaces";
5
+ import type { ITelemetryBaseLogger, LogLevel, Tagged } from "@fluidframework/core-interfaces";
6
6
  /**
7
7
  * The categories FF uses when instrumenting the code.
8
8
  *
@@ -22,10 +22,7 @@ export type TelemetryEventCategory = "generic" | "error" | "performance";
22
22
  * converted before sending to a base logger.
23
23
  * @alpha
24
24
  */
25
- export type TelemetryEventPropertyTypeExt = string | number | boolean | undefined | (string | number | boolean)[] | {
26
- [key: string]: // Flat objects can have the same properties as the event itself
27
- string | number | boolean | undefined | (string | number | boolean)[];
28
- };
25
+ export type TelemetryEventPropertyTypeExt = string | number | boolean | undefined | (string | number | boolean)[] | Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;
29
26
  /**
30
27
  * A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used
31
28
  * to mark pieces of information that should be organized or handled differently by loggers in various first or third
@@ -42,9 +39,7 @@ export interface ITaggedTelemetryPropertyTypeExt {
42
39
  * JSON-serializable properties, which will be logged with telemetry.
43
40
  * @alpha
44
41
  */
45
- export interface ITelemetryPropertiesExt {
46
- [index: string]: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>;
47
- }
42
+ export type ITelemetryPropertiesExt = Record<string, TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>>;
48
43
  /**
49
44
  * Interface for logging telemetry statements.
50
45
  * @remarks May contain any number of properties that get serialized as json payload.
@@ -54,7 +49,13 @@ export interface ITelemetryPropertiesExt {
54
49
  * @internal
55
50
  */
56
51
  export interface ITelemetryEventExt extends ITelemetryPropertiesExt {
52
+ /**
53
+ * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}
54
+ */
57
55
  category: string;
56
+ /**
57
+ * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}
58
+ */
58
59
  eventName: string;
59
60
  }
60
61
  /**
@@ -63,7 +64,14 @@ export interface ITelemetryEventExt extends ITelemetryPropertiesExt {
63
64
  * @alpha
64
65
  */
65
66
  export interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
67
+ /**
68
+ * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}
69
+ */
66
70
  eventName: string;
71
+ /**
72
+ * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.
73
+ * @defaultValue "generic"
74
+ */
67
75
  category?: TelemetryEventCategory;
68
76
  }
69
77
  /**
@@ -72,6 +80,9 @@ export interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
72
80
  * @alpha
73
81
  */
74
82
  export interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
83
+ /**
84
+ * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}
85
+ */
75
86
  eventName: string;
76
87
  }
77
88
  /**
@@ -80,6 +91,9 @@ export interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
80
91
  * @alpha
81
92
  */
82
93
  export interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {
94
+ /**
95
+ * Duration of event (optional)
96
+ */
83
97
  duration?: number;
84
98
  }
85
99
  /**
@@ -92,23 +106,23 @@ export interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt
92
106
  */
93
107
  export interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
94
108
  /**
95
- * Send information telemetry event
96
- * @param event - Event to send
97
- * @param error - optional error object to log
98
- * @param logLevel - optional level of the log.
109
+ * Send an information telemetry event.
110
+ * @param event - Event to send.
111
+ * @param error - Optional error object to log.
112
+ * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.
99
113
  */
100
114
  sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
101
115
  /**
102
- * Send error telemetry event
103
- * @param event - Event to send
104
- * @param error - optional error object to log
116
+ * Send an error telemetry event.
117
+ * @param event - Event to send.
118
+ * @param error - Optional error object to log.
105
119
  */
106
120
  sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;
107
121
  /**
108
- * Send performance telemetry event
122
+ * Send a performance telemetry event.
109
123
  * @param event - Event to send
110
- * @param error - optional error object to log
111
- * @param logLevel - optional level of the log.
124
+ * @param error - Optional error object to log.
125
+ * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.
112
126
  */
113
127
  sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
114
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzF;;;;;;;;;GASG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GACtC,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAC7B;IACA,CAAC,GAAG,EAAE,MAAM,GACZ,AADe,gEAAgE;IAC/E,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;CACrE,CAAC;AAEL;;;;;;;GAOG;AACH,MAAM,WAAW,+BAA+B;IAC/C,KAAK,EAAE,6BAA6B,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACvC,CAAC,KAAK,EAAE,MAAM,GAAG,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;CACvF;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACvE,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAChE;;;;;OAKG;IACH,kBAAkB,CACjB,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,GAC1D,IAAI,CAAC;IAER;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtE;;;;;OAKG;IACH,oBAAoB,CACnB,KAAK,EAAE,6BAA6B,EACpC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,GAC1D,IAAI,CAAC;CACR"}
1
+ {"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9F;;;;;;;;;GASG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GACtC,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;AAEzF;;;;;;;GAOG;AACH,MAAM,WAAW,+BAA+B;IAC/C,KAAK,EAAE,6BAA6B,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC3C,MAAM,EACN,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CACrE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IAClE;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACzE;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACvE;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC/E;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAChE;;;;;OAKG;IACH,kBAAkB,CACjB,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,GAC1D,IAAI,CAAC;IAER;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtE;;;;;OAKG;IACH,oBAAoB,CACnB,KAAK,EAAE,6BAA6B,EACpC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,GAC1D,IAAI,CAAC;CACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @alpha\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @alpha\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| {\n\t\t\t[key: string]: // Flat objects can have the same properties as the event itself\n\t\t\tstring | number | boolean | undefined | (string | number | boolean)[];\n\t };\n\n/**\n * A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used\n * to mark pieces of information that should be organized or handled differently by loggers in various first or third\n * party scenarios. For example, tags are used to mark personal information that should not be stored in logs.\n *\n * @deprecated Use {@link @fluidframework/core-interfaces#Tagged}\\<{@link TelemetryEventPropertyTypeExt}\\>\n * @internal\n */\nexport interface ITaggedTelemetryPropertyTypeExt {\n\tvalue: TelemetryEventPropertyTypeExt;\n\ttag: string;\n}\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @alpha\n */\nexport interface ITelemetryPropertiesExt {\n\t[index: string]: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>;\n}\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\tcategory: string;\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @alpha\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\teventName: string;\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @alpha\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @alpha\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\tduration?: number; // Duration of event (optional)\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\n * This interface is meant to be used internally within the Fluid Framework,\n * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.\n * @alpha\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send information telemetry event\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n\n\t/**\n\t * Send error telemetry event\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send performance telemetry event\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n}\n"]}
1
+ {"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @alpha\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @alpha\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used\n * to mark pieces of information that should be organized or handled differently by loggers in various first or third\n * party scenarios. For example, tags are used to mark personal information that should not be stored in logs.\n *\n * @deprecated Use {@link @fluidframework/core-interfaces#Tagged}\\<{@link TelemetryEventPropertyTypeExt}\\>\n * @internal\n */\nexport interface ITaggedTelemetryPropertyTypeExt {\n\tvalue: TelemetryEventPropertyTypeExt;\n\ttag: string;\n}\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @alpha\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>\n>;\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @alpha\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @alpha\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @alpha\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\n * This interface is meant to be used internally within the Fluid Framework,\n * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.\n * @alpha\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\n\t * @param event - Event to send\n\t * @param error - Optional error object to log.\n\t * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryLoggerExt } from "./telemetryTypes.js";
5
+ import type { ITelemetryLoggerExt } from "./telemetryTypes.js";
6
6
  /**
7
7
  * Utility counter which will send event only if the provided value is above a configured threshold.
8
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;GAIG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,iBAAiB;gBAFR,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EACpC,iBAAiB,SAAY;IAGtC;;OAEG;IACI,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAUnD;;;;;;OAMG;IACI,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAU7D"}
1
+ {"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;GAIG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,iBAAiB;gBAFR,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EACpC,iBAAiB,SAAY;IAGtC;;OAEG;IACI,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAUnD;;;;;;OAMG;IACI,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAU7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAC5B,YACkB,SAAiB,EACjB,MAA2B,EACpC,oBAAoB,SAAS;QAFpB,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAqB;QACpC,sBAAiB,GAAjB,iBAAiB,CAAY;IACnC,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,SAAiB,EAAE,KAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC5B,OAAO;QACR,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAChC,SAAS;YACT,KAAK;SACL,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,SAAiB,EAAE,KAAa;QACrD,IAAI,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,KAAK;aACL,CAAC,CAAC;YACH,sCAAsC;YACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QACrD,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Utility counter which will send event only if the provided value is above a configured threshold.\n *\n * @internal\n */\nexport class ThresholdCounter {\n\tpublic constructor(\n\t\tprivate readonly threshold: number,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate thresholdMultiple = threshold,\n\t) {}\n\n\t/**\n\t * Sends the value if it's above the treshold.\n\t */\n\tpublic send(eventName: string, value: number): void {\n\t\tif (value < this.threshold) {\n\t\t\treturn;\n\t\t}\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName,\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t/**\n\t * Sends the value if it's above the threshold\n\t * and a multiple of the threshold.\n\t *\n\t * To be used in scenarios where we'd like to record a\n\t * threshold violation while reducing telemetry noise.\n\t */\n\tpublic sendIfMultiple(eventName: string, value: number): void {\n\t\tif (value === this.thresholdMultiple) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t\t// reduce number of \"multiple\" events.\n\t\t\tthis.thresholdMultiple = this.thresholdMultiple * 2;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAC5B,YACkB,SAAiB,EACjB,MAA2B,EACpC,oBAAoB,SAAS;QAFpB,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAqB;QACpC,sBAAiB,GAAjB,iBAAiB,CAAY;IACnC,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,SAAiB,EAAE,KAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC5B,OAAO;QACR,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAChC,SAAS;YACT,KAAK;SACL,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,SAAiB,EAAE,KAAa;QACrD,IAAI,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,KAAK;aACL,CAAC,CAAC;YACH,sCAAsC;YACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QACrD,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Utility counter which will send event only if the provided value is above a configured threshold.\n *\n * @internal\n */\nexport class ThresholdCounter {\n\tpublic constructor(\n\t\tprivate readonly threshold: number,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate thresholdMultiple = threshold,\n\t) {}\n\n\t/**\n\t * Sends the value if it's above the treshold.\n\t */\n\tpublic send(eventName: string, value: number): void {\n\t\tif (value < this.threshold) {\n\t\t\treturn;\n\t\t}\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName,\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t/**\n\t * Sends the value if it's above the threshold\n\t * and a multiple of the threshold.\n\t *\n\t * To be used in scenarios where we'd like to record a\n\t * threshold violation while reducing telemetry noise.\n\t */\n\tpublic sendIfMultiple(eventName: string, value: number): void {\n\t\tif (value === this.thresholdMultiple) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t\t// reduce number of \"multiple\" events.\n\t\t\tthis.thresholdMultiple = this.thresholdMultiple * 2;\n\t\t}\n\t}\n}\n"]}
package/lib/utils.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryLoggerExt } from "./telemetryTypes.js";
5
+ import type { ITelemetryLoggerExt } from "./telemetryTypes.js";
6
6
  /**
7
7
  * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.
8
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAA6B,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAErF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IACnE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,EAC3B,YAAY,CAAC,EAAE,aAAa,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CA8CzB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAA6B,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1F;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IACnE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,EAC3B,YAAY,CAAC,EAAE,aAAa,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CA8CzB"}
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAgCxD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA2B,EAC3B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GACvB,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC,IAAI,KAAK,CAAC;IAEjF,MAAM,aAAa,GAAG;QACrB,IAAI,EAAE,CAAC,KAA0B,EAAQ,EAAE;YAC1C,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,0EAA0E;YAC1E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,iCAAiC,EAAE,CAAC;oBAC7D,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACF,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC9D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,iCAAiC,EAAE,CAAC;oBAC7D,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC1D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,iCAAiC,EAAE,CAAC;oBAC7D,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,iCAAiC,EAAE,CAAC;oBAC7D,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport { ITelemetryGenericEventExt, ITelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean | undefined;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends ITelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link ITelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an ${@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: ITelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n\tskipLoggingWhenSamplingIsDisabled?: boolean,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && skipLoggingWhenSamplingIsDisabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.send(event);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && skipLoggingWhenSamplingIsDisabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && skipLoggingWhenSamplingIsDisabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && skipLoggingWhenSamplingIsDisabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendPerformanceEvent(event);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAgCxD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA2B,EAC3B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GACvB,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC,IAAI,KAAK,CAAC;IAEjF,MAAM,aAAa,GAAG;QACrB,IAAI,EAAE,CAAC,KAA0B,EAAQ,EAAE;YAC1C,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,0EAA0E;YAC1E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,iCAAiC,EAAE,CAAC;oBAC7D,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACF,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC9D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,iCAAiC,EAAE,CAAC;oBAC7D,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC1D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,iCAAiC,EAAE,CAAC;oBAC7D,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,iCAAiC,EAAE,CAAC;oBAC7D,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport type { ITelemetryGenericEventExt, ITelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean | undefined;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends ITelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link ITelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an ${@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: ITelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n\tskipLoggingWhenSamplingIsDisabled?: boolean,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && skipLoggingWhenSamplingIsDisabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.send(event);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && skipLoggingWhenSamplingIsDisabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && skipLoggingWhenSamplingIsDisabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && skipLoggingWhenSamplingIsDisabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendPerformanceEvent(event);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/telemetry-utils",
3
- "version": "2.0.0-dev-rc.5.0.0.271717",
3
+ "version": "2.0.0-dev-rc.5.0.0.272251",
4
4
  "description": "Collection of telemetry relates utilities for Fluid",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -67,17 +67,17 @@
67
67
  "temp-directory": "nyc/.nyc_output"
68
68
  },
69
69
  "dependencies": {
70
- "@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.271717",
71
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.271717",
72
- "@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.271717",
73
- "@fluidframework/driver-definitions": "2.0.0-dev-rc.5.0.0.271717",
70
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.272251",
71
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.272251",
72
+ "@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.272251",
73
+ "@fluidframework/driver-definitions": "2.0.0-dev-rc.5.0.0.272251",
74
74
  "debug": "^4.3.4",
75
75
  "uuid": "^9.0.0"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@arethetypeswrong/cli": "^0.15.2",
79
79
  "@biomejs/biome": "^1.7.3",
80
- "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.271717",
80
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.272251",
81
81
  "@fluid-tools/build-cli": "^0.39.0",
82
82
  "@fluidframework/build-common": "^2.0.3",
83
83
  "@fluidframework/build-tools": "^0.39.0",
@@ -90,6 +90,7 @@
90
90
  "@types/sinon": "^17.0.3",
91
91
  "@types/uuid": "^9.0.2",
92
92
  "c8": "^8.0.1",
93
+ "concurrently": "^8.2.1",
93
94
  "copyfiles": "^2.4.1",
94
95
  "cross-env": "^7.0.3",
95
96
  "eslint": "~8.55.0",
@@ -104,6 +105,9 @@
104
105
  },
105
106
  "typeValidation": {
106
107
  "broken": {
108
+ "ClassDeclaration_MockLogger": {
109
+ "forwardCompat": false
110
+ },
107
111
  "RemovedFunctionDeclaration_isValidLegacyError": {
108
112
  "forwardCompat": false,
109
113
  "backCompat": false
@@ -125,9 +129,14 @@
125
129
  "bump-version": "npm version minor --no-push --no-git-tag-version && npm run build:genver",
126
130
  "check:are-the-types-wrong": "attw --pack .",
127
131
  "check:biome": "biome check . --formatter-enabled=true",
132
+ "check:exports": "concurrently \"npm:check:exports:*\"",
133
+ "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
134
+ "check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
135
+ "check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
136
+ "check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
137
+ "check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
128
138
  "check:format": "npm run check:prettier",
129
139
  "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
130
- "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
131
140
  "ci:build:docs": "api-extractor run",
132
141
  "clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
133
142
  "eslint": "eslint --format stylish src",
package/src/config.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import {
6
+ import type {
7
7
  ConfigTypes,
8
8
  IConfigProviderBase,
9
9
  ITelemetryBaseLogger,
@@ -11,7 +11,7 @@ import {
11
11
  import { Lazy } from "@fluidframework/core-utils/internal";
12
12
 
13
13
  import { createChildLogger, tagCodeArtifacts } from "./logger.js";
14
- import { ITelemetryLoggerExt } from "./telemetryTypes.js";
14
+ import type { ITelemetryLoggerExt } from "./telemetryTypes.js";
15
15
 
16
16
  /**
17
17
  * Explicitly typed interface for reading configurations.
@@ -193,7 +193,7 @@ export class CachedConfigProvider implements IConfigProvider {
193
193
  private readonly configCache = new Map<string, StronglyTypedValue>();
194
194
  private readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];
195
195
 
196
- constructor(
196
+ public constructor(
197
197
  private readonly logger?: ITelemetryBaseLogger,
198
198
  ...orderedBaseProviders: (IConfigProviderBase | undefined)[]
199
199
  ) {
@@ -216,26 +216,26 @@ export class CachedConfigProvider implements IConfigProvider {
216
216
  }
217
217
  }
218
218
  }
219
- getBoolean(name: string): boolean | undefined {
219
+ public getBoolean(name: string): boolean | undefined {
220
220
  return this.getCacheEntry(name)?.boolean;
221
221
  }
222
- getNumber(name: string): number | undefined {
222
+ public getNumber(name: string): number | undefined {
223
223
  return this.getCacheEntry(name)?.number;
224
224
  }
225
- getString(name: string): string | undefined {
225
+ public getString(name: string): string | undefined {
226
226
  return this.getCacheEntry(name)?.string;
227
227
  }
228
- getBooleanArray(name: string): boolean[] | undefined {
228
+ public getBooleanArray(name: string): boolean[] | undefined {
229
229
  return this.getCacheEntry(name)?.["boolean[]"];
230
230
  }
231
- getNumberArray(name: string): number[] | undefined {
231
+ public getNumberArray(name: string): number[] | undefined {
232
232
  return this.getCacheEntry(name)?.["number[]"];
233
233
  }
234
- getStringArray(name: string): string[] | undefined {
234
+ public getStringArray(name: string): string[] | undefined {
235
235
  return this.getCacheEntry(name)?.["string[]"];
236
236
  }
237
237
 
238
- getRawConfig(name: string): ConfigTypes {
238
+ public getRawConfig(name: string): ConfigTypes {
239
239
  return this.getCacheEntry(name)?.raw;
240
240
  }
241
241
 
package/src/error.ts CHANGED
@@ -3,13 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IErrorBase, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
6
+ import type { IErrorBase, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
7
7
  import {
8
8
  FluidErrorTypes,
9
- IGenericError,
10
- IUsageError,
9
+ type IGenericError,
10
+ type IUsageError,
11
11
  } from "@fluidframework/core-interfaces/internal";
12
- import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
12
+ import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
13
13
 
14
14
  import {
15
15
  LoggingError,
@@ -18,8 +18,8 @@ import {
18
18
  normalizeError,
19
19
  wrapError,
20
20
  } from "./errorLogging.js";
21
- import { IFluidErrorBase } from "./fluidErrorBase.js";
22
- import { ITelemetryPropertiesExt } from "./telemetryTypes.js";
21
+ import type { IFluidErrorBase } from "./fluidErrorBase.js";
22
+ import type { ITelemetryPropertiesExt } from "./telemetryTypes.js";
23
23
 
24
24
  /**
25
25
  * Throws a UsageError with the given message if the condition is not met.
@@ -46,7 +46,7 @@ export function validatePrecondition(
46
46
  * @internal
47
47
  */
48
48
  export class GenericError extends LoggingError implements IGenericError, IFluidErrorBase {
49
- readonly errorType = FluidErrorTypes.genericError;
49
+ public readonly errorType = FluidErrorTypes.genericError;
50
50
 
51
51
  /**
52
52
  * Create a new GenericError
@@ -54,7 +54,7 @@ export class GenericError extends LoggingError implements IGenericError, IFluidE
54
54
  * @param error - inner error object
55
55
  * @param props - Telemetry props to include when the error is logged
56
56
  */
57
- constructor(
57
+ public constructor(
58
58
  message: string,
59
59
  // TODO: Use `unknown` instead (API breaking change because error is not just an input parameter, but a public member of the class)
60
60
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
@@ -72,9 +72,9 @@ export class GenericError extends LoggingError implements IGenericError, IFluidE
72
72
  * @internal
73
73
  */
74
74
  export class UsageError extends LoggingError implements IUsageError, IFluidErrorBase {
75
- readonly errorType = FluidErrorTypes.usageError;
75
+ public readonly errorType = FluidErrorTypes.usageError;
76
76
 
77
- constructor(message: string, props?: ITelemetryBaseProperties) {
77
+ public constructor(message: string, props?: ITelemetryBaseProperties) {
78
78
  super(message, { ...props, usageError: true });
79
79
  }
80
80
  }
@@ -86,10 +86,10 @@ export class UsageError extends LoggingError implements IUsageError, IFluidError
86
86
  * @internal
87
87
  */
88
88
  export class DataCorruptionError extends LoggingError implements IErrorBase, IFluidErrorBase {
89
- readonly errorType = FluidErrorTypes.dataCorruptionError;
90
- readonly canRetry = false;
89
+ public readonly errorType = FluidErrorTypes.dataCorruptionError;
90
+ public readonly canRetry = false;
91
91
 
92
- constructor(message: string, props: ITelemetryBaseProperties) {
92
+ public constructor(message: string, props: ITelemetryBaseProperties) {
93
93
  super(message, { ...props, dataProcessingError: 1 });
94
94
  }
95
95
  }
@@ -7,7 +7,7 @@ import type { ITelemetryBaseProperties, Tagged } from "@fluidframework/core-inte
7
7
  import type { ILoggingError } from "@fluidframework/core-interfaces/internal";
8
8
  import { v4 as uuid } from "uuid";
9
9
 
10
- import { IFluidErrorBase, hasErrorInstanceId, isFluidError } from "./fluidErrorBase.js";
10
+ import { type IFluidErrorBase, hasErrorInstanceId, isFluidError } from "./fluidErrorBase.js";
11
11
  import { convertToBasePropertyType } from "./logger.js";
12
12
  import type {
13
13
  ITelemetryLoggerExt,
@@ -157,7 +157,12 @@ export function normalizeError(
157
157
 
158
158
  const errorTelemetryProps = LoggingError.typeCheck(error)
159
159
  ? error.getTelemetryProperties()
160
- : { untrustedOrigin: 1 }; // This will let us filter errors that did not originate from our own codebase
160
+ : {
161
+ untrustedOrigin: 1, // This will let us filter errors that did not originate from our own codebase
162
+ // FUTURE: Once 2.0 becomes LTS, switch to this more explicit property name
163
+ // Consider using a string to distinguish cases like "dependency" v. "callback"
164
+ // errorRunningExternalCode: 1,
165
+ };
161
166
 
162
167
  fluidError.addTelemetryProperties({
163
168
  ...errorTelemetryProps,
@@ -231,7 +236,12 @@ export function wrapError<T extends LoggingError>(
231
236
 
232
237
  // Mark external errors with untrustedOrigin flag
233
238
  if (isExternalError(innerError)) {
234
- newError.addTelemetryProperties({ untrustedOrigin: 1 });
239
+ newError.addTelemetryProperties({
240
+ untrustedOrigin: 1,
241
+ // FUTURE: Once 2.0 becomes LTS, switch to this more explicit property name
242
+ // Consider using a string to distinguish cases like "dependency" v. "callback"
243
+ // errorRunningExternalCode: 1,
244
+ });
235
245
  }
236
246
 
237
247
  // Reuse errorInstanceId
@@ -243,7 +253,7 @@ export function wrapError<T extends LoggingError>(
243
253
  }
244
254
 
245
255
  // Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties
246
- // This will include the untrustedOrigin property if the inner error itself was created from an external error
256
+ // This will include the untrustedOrigin/errorRunningExternalCode info if the inner error itself was created from an external error
247
257
  if (isILoggingError(innerError)) {
248
258
  newError.addTelemetryProperties(innerError.getTelemetryProperties());
249
259
  }
@@ -308,11 +318,14 @@ export function overwriteStack(error: IFluidErrorBase | LoggingError, stack: str
308
318
  */
309
319
  export function isExternalError(error: unknown): boolean {
310
320
  // LoggingErrors are an internal FF error type. However, an external error can be converted
311
- // into a LoggingError if it is normalized. In this case we must use the untrustedOrigin flag to
312
- // determine whether the original error was infact external.
321
+ // into a LoggingError if it is normalized. In this case we must use the untrustedOrigin/errorRunningExternalCode flag to
322
+ // determine whether the original error was in fact external.
313
323
  if (LoggingError.typeCheck(error)) {
314
324
  if ((error as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {
315
- return error.getTelemetryProperties().untrustedOrigin === 1;
325
+ const props = error.getTelemetryProperties();
326
+ // NOTE: errorRunningExternalCode is not currently used - once this "read" code reaches LTS,
327
+ // we can switch to writing this more explicit property
328
+ return props.untrustedOrigin === 1 || !!props.errorRunningExternalCode;
316
329
  }
317
330
  return false;
318
331
  }
@@ -331,6 +344,8 @@ export function isTaggedTelemetryPropertyValue(
331
344
  return typeof (x as Partial<Tagged<unknown>>)?.tag === "string";
332
345
  }
333
346
 
347
+ // TODO: Use `unknown` instead (API breaking change)
348
+ /* eslint-disable @typescript-eslint/no-explicit-any */
334
349
  /**
335
350
  * Borrowed from
336
351
  * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}
@@ -340,8 +355,6 @@ export function isTaggedTelemetryPropertyValue(
340
355
  *
341
356
  * @internal
342
357
  */
343
- // TODO: Use `unknown` instead (API breaking change)
344
- /* eslint-disable @typescript-eslint/no-explicit-any */
345
358
  export const getCircularReplacer = (): ((key: string, value: unknown) => any) => {
346
359
  const seen = new WeakSet();
347
360
  return (key: string, value: unknown): any => {
@@ -370,10 +383,10 @@ export class LoggingError
370
383
  implements ILoggingError, Omit<IFluidErrorBase, "errorType">
371
384
  {
372
385
  private _errorInstanceId = uuid();
373
- get errorInstanceId(): string {
386
+ public get errorInstanceId(): string {
374
387
  return this._errorInstanceId;
375
388
  }
376
- overwriteErrorInstanceId(id: string): void {
389
+ public overwriteErrorInstanceId(id: string): void {
377
390
  this._errorInstanceId = id;
378
391
  }
379
392
 
@@ -383,7 +396,7 @@ export class LoggingError
383
396
  * @param props - telemetry props to include on the error for when it's logged
384
397
  * @param omitPropsFromLogging - properties by name to omit from telemetry props
385
398
  */
386
- constructor(
399
+ public constructor(
387
400
  message: string,
388
401
  props?: ITelemetryBaseProperties,
389
402
  private readonly omitPropsFromLogging: Set<string> = new Set(),
@@ -464,9 +477,9 @@ export const NORMALIZED_ERROR_TYPE = "genericError";
464
477
  class NormalizedLoggingError extends LoggingError {
465
478
  // errorType "genericError" is used as a default value throughout the code.
466
479
  // Note that this matches ContainerErrorTypes/DriverErrorTypes' genericError
467
- errorType = NORMALIZED_ERROR_TYPE;
480
+ public readonly errorType = NORMALIZED_ERROR_TYPE;
468
481
 
469
- constructor(errorProps: Pick<IFluidErrorBase, "message" | "stack">) {
482
+ public constructor(errorProps: Pick<IFluidErrorBase, "message" | "stack">) {
470
483
  super(errorProps.message);
471
484
 
472
485
  if (errorProps.stack !== undefined) {
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { EventEmitterEventType, TypedEventEmitter } from "@fluid-internal/client-utils";
7
- import { IEvent } from "@fluidframework/core-interfaces";
6
+ import { type EventEmitterEventType, TypedEventEmitter } from "@fluid-internal/client-utils";
7
+ import type { IEvent } from "@fluidframework/core-interfaces";
8
8
 
9
9
  /**
10
10
  * Event Emitter helper class
@@ -20,7 +20,7 @@ import { IEvent } from "@fluidframework/core-interfaces";
20
20
  export class EventEmitterWithErrorHandling<
21
21
  TEvent extends IEvent = IEvent,
22
22
  > extends TypedEventEmitter<TEvent> {
23
- constructor(
23
+ public constructor(
24
24
  // TODO: use `unknown` instead (breaking API change)
25
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
26
  private readonly errorHandler: (eventName: EventEmitterEventType, error: any) => void,
package/src/index.ts CHANGED
@@ -5,10 +5,10 @@
5
5
 
6
6
  export {
7
7
  createChildMonitoringContext,
8
- MonitoringContext,
8
+ type MonitoringContext,
9
9
  sessionStorageConfigProvider,
10
10
  mixinMonitoringContext,
11
- IConfigProvider,
11
+ type IConfigProvider,
12
12
  loggerToMonitoringContext,
13
13
  wrapConfigProviderWithDefaults,
14
14
  } from "./config.js";
@@ -25,7 +25,7 @@ export {
25
25
  generateErrorWithStack,
26
26
  generateStack,
27
27
  getCircularReplacer,
28
- IFluidErrorAnnotations,
28
+ type IFluidErrorAnnotations,
29
29
  isExternalError,
30
30
  isILoggingError,
31
31
  isTaggedTelemetryPropertyValue,
@@ -43,29 +43,29 @@ export {
43
43
  raiseConnectedEvent,
44
44
  safeRaiseEvent,
45
45
  } from "./events.js";
46
- export { hasErrorInstanceId, IFluidErrorBase, isFluidError } from "./fluidErrorBase.js";
46
+ export { hasErrorInstanceId, type IFluidErrorBase, isFluidError } from "./fluidErrorBase.js";
47
47
  export {
48
48
  eventNamespaceSeparator,
49
49
  createChildLogger,
50
50
  createMultiSinkLogger,
51
51
  formatTick,
52
- IPerformanceEventMarkers,
53
- ITelemetryLoggerPropertyBag,
54
- ITelemetryLoggerPropertyBags,
55
- MultiSinkLoggerProperties,
52
+ type IPerformanceEventMarkers,
53
+ type ITelemetryLoggerPropertyBag,
54
+ type ITelemetryLoggerPropertyBags,
55
+ type MultiSinkLoggerProperties,
56
56
  numberFromString,
57
57
  PerformanceEvent,
58
58
  TaggedLoggerAdapter,
59
59
  tagData,
60
60
  tagCodeArtifacts,
61
61
  TelemetryDataTag,
62
- TelemetryEventPropertyTypes,
62
+ type TelemetryEventPropertyTypes,
63
63
  } from "./logger.js";
64
64
  export { MockLogger } from "./mockLogger.js";
65
65
  export { ThresholdCounter } from "./thresholdCounter.js";
66
66
  export { SampledTelemetryHelper } from "./sampledTelemetryHelper.js";
67
- export { createSampledLogger, IEventSampler, ISampledTelemetryLogger } from "./utils.js";
68
- export {
67
+ export { createSampledLogger, type IEventSampler, type ISampledTelemetryLogger } from "./utils.js";
68
+ export type {
69
69
  TelemetryEventPropertyTypeExt,
70
70
  ITelemetryEventExt,
71
71
  ITelemetryGenericEventExt,