@fluidframework/telemetry-utils 2.0.0-dev-rc.2.0.0.246488 → 2.0.0-dev-rc.3.0.0.250606

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 (61) hide show
  1. package/dist/config.d.ts +1 -1
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js.map +1 -1
  4. package/dist/error.d.ts +1 -1
  5. package/dist/error.d.ts.map +1 -1
  6. package/dist/error.js.map +1 -1
  7. package/dist/errorLogging.d.ts +1 -1
  8. package/dist/errorLogging.d.ts.map +1 -1
  9. package/dist/errorLogging.js.map +1 -1
  10. package/dist/eventEmitterWithErrorHandling.d.ts +1 -1
  11. package/dist/eventEmitterWithErrorHandling.d.ts.map +1 -1
  12. package/dist/eventEmitterWithErrorHandling.js.map +1 -1
  13. package/dist/logger.d.ts +2 -2
  14. package/dist/logger.d.ts.map +1 -1
  15. package/dist/logger.js +1 -1
  16. package/dist/logger.js.map +1 -1
  17. package/dist/mockLogger.d.ts.map +1 -1
  18. package/dist/mockLogger.js.map +1 -1
  19. package/dist/sampledTelemetryHelper.d.ts +2 -2
  20. package/dist/sampledTelemetryHelper.d.ts.map +1 -1
  21. package/dist/sampledTelemetryHelper.js.map +1 -1
  22. package/lib/config.d.ts +1 -1
  23. package/lib/config.d.ts.map +1 -1
  24. package/lib/config.js.map +1 -1
  25. package/lib/error.d.ts +1 -1
  26. package/lib/error.d.ts.map +1 -1
  27. package/lib/error.js.map +1 -1
  28. package/lib/errorLogging.d.ts +1 -1
  29. package/lib/errorLogging.d.ts.map +1 -1
  30. package/lib/errorLogging.js.map +1 -1
  31. package/lib/eventEmitterWithErrorHandling.d.ts +1 -1
  32. package/lib/eventEmitterWithErrorHandling.d.ts.map +1 -1
  33. package/lib/eventEmitterWithErrorHandling.js.map +1 -1
  34. package/lib/logger.d.ts +2 -2
  35. package/lib/logger.d.ts.map +1 -1
  36. package/lib/logger.js +2 -2
  37. package/lib/logger.js.map +1 -1
  38. package/lib/mockLogger.d.ts.map +1 -1
  39. package/lib/mockLogger.js.map +1 -1
  40. package/lib/sampledTelemetryHelper.d.ts +2 -2
  41. package/lib/sampledTelemetryHelper.d.ts.map +1 -1
  42. package/lib/sampledTelemetryHelper.js.map +1 -1
  43. package/lib/test/errorLogging.spec.js +2 -2
  44. package/lib/test/errorLogging.spec.js.map +1 -1
  45. package/lib/test/errorTypeLoggingTest.spec.js +2 -2
  46. package/lib/test/errorTypeLoggingTest.spec.js.map +1 -1
  47. package/lib/test/performanceEvent.spec.js +1 -1
  48. package/lib/test/performanceEvent.spec.js.map +1 -1
  49. package/lib/test/sampledTelemetryHelper.spec.js.map +1 -1
  50. package/lib/test/telemetryLogger.spec.js.map +1 -1
  51. package/lib/test/thresholdCounter.spec.js.map +1 -1
  52. package/lib/test/utils.spec.js +2 -2
  53. package/lib/test/utils.spec.js.map +1 -1
  54. package/package.json +13 -10
  55. package/src/config.ts +2 -2
  56. package/src/error.ts +1 -1
  57. package/src/errorLogging.ts +3 -3
  58. package/src/eventEmitterWithErrorHandling.ts +1 -1
  59. package/src/logger.ts +6 -6
  60. package/src/mockLogger.ts +1 -1
  61. package/src/sampledTelemetryHelper.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"performanceEvent.spec.js","sourceRoot":"","sources":["../../src/test/performanceEvent.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGjE,MAAM,UAAW,SAAQ,eAAe;IAIvC;QACC,KAAK,EAAE,CAAC;QAJF,iBAAY,GAAW,CAAC,CAAC;QACzB,iBAAY,GAAW,CAAC,CAAC;IAIhC,CAAC;IAED,IAAI,CAAC,KAA0B;QAC9B,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC/B,EAAE,IAAI,CAA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*/\n\nimport { strict as assert } from \"node:assert\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { TelemetryLogger, PerformanceEvent } from \"../logger.js\";\nimport { ITelemetryLoggerExt } from \"../telemetryTypes.js\";\n\nclass MockLogger extends TelemetryLogger implements ITelemetryLoggerExt {\n\tpublic errorsLogged: number = 0;\n\tpublic eventsLogged: number = 0;\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tsend(event: ITelemetryBaseEvent): void {\n\t\tif (event.category === \"error\") {\n\t\t\t++this.errorsLogged;\n\t\t}\n\n\t\t++this.eventsLogged;\n\t}\n}\n\ndescribe(\"PerformanceEvent\", () => {\n\tlet logger: MockLogger;\n\tlet callbackCalls = 0;\n\n\tconst callback = (): void => {\n\t\tcallbackCalls++;\n\t};\n\tconst asyncCallback = async (event: PerformanceEvent): Promise<string | void> => {\n\t\tconst outerPromise: Promise<string> = new Promise((resolve, reject) => {\n\t\t\tPromise.resolve(\"A\")\n\t\t\t\t.finally(() => {\n\t\t\t\t\treject(new Error(\"B\"));\n\t\t\t\t})\n\t\t\t\t.then((val) => {\n\t\t\t\t\tevent.end({ val });\n\t\t\t\t\tresolve(\"C\");\n\t\t\t\t})\n\t\t\t\t.catch(() => {});\n\t\t});\n\n\t\tcallbackCalls++;\n\t\treturn outerPromise.catch(() => {});\n\t};\n\n\tbeforeEach(() => {\n\t\tcallbackCalls = 0;\n\t\tlogger = new MockLogger();\n\t});\n\n\tit(\"Cancel then End\", async () => {\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"Testing\" },\n\t\t\tasyncCallback,\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\ttrue,\n\t\t);\n\t\tassert.equal(logger.errorsLogged, 0, \"Shouldn't have logged any errors\");\n\t});\n\n\tdescribe(\"Event sampling\", () => {\n\t\tit(\"Events are logged at least once\", async () => {\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{ eventName: \"TestingAsyncOnce\" },\n\t\t\t\tasyncCallback,\n\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\ttrue,\n\t\t\t\t100, // sampleThreshold\n\t\t\t);\n\n\t\t\tPerformanceEvent.timedExec(\n\t\t\t\tlogger,\n\t\t\t\t{ eventName: \"TestingSyncOnce\" },\n\t\t\t\tcallback,\n\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t100, // sampleThreshold\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 2);\n\t\t\tassert.equal(logger.eventsLogged, 4);\n\t\t});\n\n\t\tit(\"No sampling by default\", async () => {\n\t\t\tawait Promise.all(\n\t\t\t\tArray.from({ length: 100 }).map(async (_) =>\n\t\t\t\t\tPerformanceEvent.timedExecAsync(\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t{ eventName: \"TestingAsync\" },\n\t\t\t\t\t\tasyncCallback,\n\t\t\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tArray.from({ length: 100 }).map((_) =>\n\t\t\t\tPerformanceEvent.timedExec(logger, { eventName: \"TestingSync\" }, callback, {\n\t\t\t\t\tstart: true,\n\t\t\t\t\tend: true,\n\t\t\t\t\tcancel: \"generic\",\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 200);\n\t\t\tassert.equal(logger.eventsLogged, 200 * 2);\n\t\t});\n\n\t\tit(\"Sampling for async\", async () => {\n\t\t\tawait Promise.all(\n\t\t\t\tArray.from({ length: 100 }).map(async (_) =>\n\t\t\t\t\tPerformanceEvent.timedExecAsync(\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t{ eventName: \"TestingAsync\" },\n\t\t\t\t\t\tasyncCallback,\n\t\t\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t20, // sampleThreshold\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 100);\n\t\t\tassert.equal(\n\t\t\t\tlogger.eventsLogged,\n\t\t\t\t10,\n\t\t\t\t\"With sampling threshold of 20, expecting 100 calls to produce 10 events (5 start, 5 cancel)\",\n\t\t\t);\n\n\t\t\t// Event with a different category gets logged\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{ eventName: \"TestingAsync\", category: \"error\" },\n\t\t\t\tasyncCallback,\n\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\ttrue,\n\t\t\t\t20, // sampleThreshold\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 101);\n\t\t\tassert.equal(logger.eventsLogged, 12, \"Expecting two extra events\");\n\t\t});\n\n\t\tit(\"Sampling for sync\", async () => {\n\t\t\tArray.from({ length: 100 }).map((_) =>\n\t\t\t\tPerformanceEvent.timedExec(\n\t\t\t\t\tlogger,\n\t\t\t\t\t{ eventName: \"TestingSync\" },\n\t\t\t\t\tcallback,\n\t\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t\t20, // sampleThreshold\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 100);\n\t\t\tassert.equal(\n\t\t\t\tlogger.eventsLogged,\n\t\t\t\t10,\n\t\t\t\t\"With sampling threshold of 20, expecting 100 calls to produce 10 events (5 start, 5 cancel)\",\n\t\t\t);\n\n\t\t\t// Event with a different category gets logged\n\t\t\tPerformanceEvent.timedExec(\n\t\t\t\tlogger,\n\t\t\t\t{ eventName: \"TestingSync\", category: \"error\" },\n\t\t\t\tcallback,\n\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t20, // sampleThreshold\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 101);\n\t\t\tassert.equal(logger.eventsLogged, 12, \"Expecting two extra events\");\n\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zB,MAAM,EACN,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,EAC/C,QAAQ,EACR,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,EAC7C,EAAE,CACF,CAAC;YAEF,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;YACjC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,EAAE,4BAA4B,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { PerformanceEvent, TelemetryLogger } from \"../logger.js\";\nimport { ITelemetryLoggerExt } from \"../telemetryTypes.js\";\n\nclass MockLogger extends TelemetryLogger implements ITelemetryLoggerExt {\n\tpublic errorsLogged: number = 0;\n\tpublic eventsLogged: number = 0;\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tsend(event: ITelemetryBaseEvent): void {\n\t\tif (event.category === \"error\") {\n\t\t\t++this.errorsLogged;\n\t\t}\n\n\t\t++this.eventsLogged;\n\t}\n}\n\ndescribe(\"PerformanceEvent\", () => {\n\tlet logger: MockLogger;\n\tlet callbackCalls = 0;\n\n\tconst callback = (): void => {\n\t\tcallbackCalls++;\n\t};\n\tconst asyncCallback = async (event: PerformanceEvent): Promise<string | void> => {\n\t\tconst outerPromise: Promise<string> = new Promise((resolve, reject) => {\n\t\t\tPromise.resolve(\"A\")\n\t\t\t\t.finally(() => {\n\t\t\t\t\treject(new Error(\"B\"));\n\t\t\t\t})\n\t\t\t\t.then((val) => {\n\t\t\t\t\tevent.end({ val });\n\t\t\t\t\tresolve(\"C\");\n\t\t\t\t})\n\t\t\t\t.catch(() => {});\n\t\t});\n\n\t\tcallbackCalls++;\n\t\treturn outerPromise.catch(() => {});\n\t};\n\n\tbeforeEach(() => {\n\t\tcallbackCalls = 0;\n\t\tlogger = new MockLogger();\n\t});\n\n\tit(\"Cancel then End\", async () => {\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"Testing\" },\n\t\t\tasyncCallback,\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\ttrue,\n\t\t);\n\t\tassert.equal(logger.errorsLogged, 0, \"Shouldn't have logged any errors\");\n\t});\n\n\tdescribe(\"Event sampling\", () => {\n\t\tit(\"Events are logged at least once\", async () => {\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{ eventName: \"TestingAsyncOnce\" },\n\t\t\t\tasyncCallback,\n\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\ttrue,\n\t\t\t\t100, // sampleThreshold\n\t\t\t);\n\n\t\t\tPerformanceEvent.timedExec(\n\t\t\t\tlogger,\n\t\t\t\t{ eventName: \"TestingSyncOnce\" },\n\t\t\t\tcallback,\n\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t100, // sampleThreshold\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 2);\n\t\t\tassert.equal(logger.eventsLogged, 4);\n\t\t});\n\n\t\tit(\"No sampling by default\", async () => {\n\t\t\tawait Promise.all(\n\t\t\t\tArray.from({ length: 100 }).map(async (_) =>\n\t\t\t\t\tPerformanceEvent.timedExecAsync(\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t{ eventName: \"TestingAsync\" },\n\t\t\t\t\t\tasyncCallback,\n\t\t\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tArray.from({ length: 100 }).map((_) =>\n\t\t\t\tPerformanceEvent.timedExec(logger, { eventName: \"TestingSync\" }, callback, {\n\t\t\t\t\tstart: true,\n\t\t\t\t\tend: true,\n\t\t\t\t\tcancel: \"generic\",\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 200);\n\t\t\tassert.equal(logger.eventsLogged, 200 * 2);\n\t\t});\n\n\t\tit(\"Sampling for async\", async () => {\n\t\t\tawait Promise.all(\n\t\t\t\tArray.from({ length: 100 }).map(async (_) =>\n\t\t\t\t\tPerformanceEvent.timedExecAsync(\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t{ eventName: \"TestingAsync\" },\n\t\t\t\t\t\tasyncCallback,\n\t\t\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t20, // sampleThreshold\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 100);\n\t\t\tassert.equal(\n\t\t\t\tlogger.eventsLogged,\n\t\t\t\t10,\n\t\t\t\t\"With sampling threshold of 20, expecting 100 calls to produce 10 events (5 start, 5 cancel)\",\n\t\t\t);\n\n\t\t\t// Event with a different category gets logged\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{ eventName: \"TestingAsync\", category: \"error\" },\n\t\t\t\tasyncCallback,\n\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\ttrue,\n\t\t\t\t20, // sampleThreshold\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 101);\n\t\t\tassert.equal(logger.eventsLogged, 12, \"Expecting two extra events\");\n\t\t});\n\n\t\tit(\"Sampling for sync\", async () => {\n\t\t\tArray.from({ length: 100 }).map((_) =>\n\t\t\t\tPerformanceEvent.timedExec(\n\t\t\t\t\tlogger,\n\t\t\t\t\t{ eventName: \"TestingSync\" },\n\t\t\t\t\tcallback,\n\t\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t\t20, // sampleThreshold\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 100);\n\t\t\tassert.equal(\n\t\t\t\tlogger.eventsLogged,\n\t\t\t\t10,\n\t\t\t\t\"With sampling threshold of 20, expecting 100 calls to produce 10 events (5 start, 5 cancel)\",\n\t\t\t);\n\n\t\t\t// Event with a different category gets logged\n\t\t\tPerformanceEvent.timedExec(\n\t\t\t\tlogger,\n\t\t\t\t{ eventName: \"TestingSync\", category: \"error\" },\n\t\t\t\tcallback,\n\t\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t\t\t20, // sampleThreshold\n\t\t\t);\n\n\t\t\tassert.equal(callbackCalls, 101);\n\t\t\tassert.equal(logger.eventsLogged, 12, \"Expecting two extra events\");\n\t\t});\n\t});\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sampledTelemetryHelper.spec.js","sourceRoot":"","sources":["../../src/test/sampledTelemetryHelper.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AAMjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAQtE;;;GAGG;AACH,MAAM,UAAU;IAAhB;QACQ,WAAM,GAAoC,EAAE,CAAC;IAgBrD,CAAC;IAdA,oBAAoB,CAAC,KAAoC,EAAE,KAAe;QACzE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,KAA0B;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,kBAAkB,CAAC,KAAgC,EAAE,KAAe;QACnE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,cAAc,CAAC,KAA8B,EAAE,KAAe;QAC7D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;CAED;AAED,MAAM,uBAAuB,GA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MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAE5C,6CAA6C;QAC7C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAE5C,wDAAwD;QACxD,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,qBAAqB,CAC7B,MAAqC,EACrC,SAAmB,EACnB,oBAA6B,KAAK;IAElC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC7B,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,IAAI,CAAC,CAAC;KACrD;IAED,IAAI,iBAAiB,EAAE;QACtB,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QACvD,MAAM,qBAAqB,GAAG,SAAS,CAAC,MAAM,CAAC;QAC/C,IAAI,mBAAmB,KAAK,qBAAqB,EAAE;YAClD,MAAM,CAAC,IAAI,CACV,wCAAwC;gBACvC,IAAI,mBAAmB,WAAW,qBAAqB,aAAa,CACrE,CAAC;SACF;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"node:assert\";\nimport type {\n\tITelemetryBaseEvent,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\n\nimport { SampledTelemetryHelper } from \"../sampledTelemetryHelper.js\";\nimport {\n\tITelemetryLoggerExt,\n\ttype ITelemetryErrorEventExt,\n\ttype ITelemetryPerformanceEventExt,\n\ttype ITelemetryGenericEventExt,\n} from \"../telemetryTypes.js\";\n\n/**\n * Test logger with only the necessary functionality used by the SampledTelemetryHelper\n * so we can test it.\n */\nclass TestLogger implements ITelemetryLoggerExt {\n\tpublic events: ITelemetryPerformanceEventExt[] = [];\n\n\tsendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown): void {\n\t\tthis.events.push(event);\n\t}\n\n\tsend(event: ITelemetryBaseEvent): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tsendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tsupportsTags?: true | undefined;\n}\n\nconst standardEventProperties = [\"eventName\", \"duration\", \"count\"];\nconst aggregateProperties = [\"totalDuration\", \"minDuration\", \"maxDuration\"];\n\ndescribe(\"SampledTelemetryHelper\", () => {\n\tlet logger: TestLogger;\n\n\tbeforeEach(() => {\n\t\tlogger = new TestLogger();\n\t});\n\n\tit(\"only writes event after correct number of samples\", () => {\n\t\tconst sampling = 10;\n\t\tconst helper = new SampledTelemetryHelper({ eventName: \"testEvent\" }, logger, sampling);\n\t\tfor (let i = 0; i < sampling - 1; i++) {\n\t\t\thelper.measure(() => {});\n\t\t}\n\t\tassert.strictEqual(logger.events.length, 0);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\n\t\t// Again to make sure the internal counter is reset correctly\n\t\tfor (let i = 0; i < sampling - 1; i++) {\n\t\t\thelper.measure(() => {});\n\t\t}\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 2);\n\t});\n\n\tit(\"does not include aggregate properties when it shouldn't\", () => {\n\t\tconst helper = new SampledTelemetryHelper({ eventName: \"testEvent\" }, logger, 1, false);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tensurePropertiesExist(event, standardEventProperties, true);\n\t\tassert.strictEqual(event.count, 1);\n\t});\n\n\tit(\"includes aggregate properties when it should\", () => {\n\t\tconst helper = new SampledTelemetryHelper({ eventName: \"testEvent\" }, logger, 1, true);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tensurePropertiesExist(event, [...standardEventProperties, ...aggregateProperties], true);\n\t\tassert.strictEqual(event.count, 1);\n\t});\n\n\tit(\"includes properties from base event when no aggregate properties are included\", () => {\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\", myProp: \"myValue\" },\n\t\t\tlogger,\n\t\t\t1,\n\t\t\tfalse,\n\t\t);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tensurePropertiesExist(event, [...standardEventProperties, \"myProp\"], true);\n\t\tassert.strictEqual(event.count, 1);\n\t\tassert.strictEqual(event.myProp, \"myValue\");\n\t});\n\n\tit(\"includes properties from base event when aggregate properties are included\", () => {\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\", myProp: \"myValue\" },\n\t\t\tlogger,\n\t\t\t1,\n\t\t\ttrue,\n\t\t);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tensurePropertiesExist(\n\t\t\tevent,\n\t\t\t[...standardEventProperties, ...aggregateProperties, \"myProp\"],\n\t\t\ttrue,\n\t\t);\n\t\tassert.strictEqual(event.count, 1);\n\t\tassert.strictEqual(event.myProp, \"myValue\");\n\t});\n\n\tit(\"tracks buckets separately and includes per-bucket properties\", () => {\n\t\tconst bucket1 = \"bucket1\";\n\t\tconst bucket2 = \"bucket2\";\n\t\tconst bucketProperties: Map<string, ITelemetryBaseProperties> = new Map<\n\t\t\tstring,\n\t\t\tITelemetryBaseProperties\n\t\t>([\n\t\t\t[bucket1, { prop1: \"value1\" }],\n\t\t\t[bucket2, { prop2: \"value2\" }],\n\t\t]);\n\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\" },\n\t\t\tlogger,\n\t\t\t3,\n\t\t\tfalse,\n\t\t\tbucketProperties,\n\t\t);\n\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\thelper.measure(() => {}, bucket1);\n\t\t}\n\t\tfor (let i = 0; i < 7; i++) {\n\t\t\thelper.measure(() => {}, bucket2);\n\t\t}\n\n\t\tassert.strictEqual(logger.events.filter((x) => x.prop1 === \"value1\").length, 3);\n\t\tassert.strictEqual(logger.events.filter((x) => x.prop2 === \"value2\").length, 2);\n\t});\n\n\tit(\"bucket properties do not override measurement properties\", () => {\n\t\t// If the names of the properties specified by the consumers for a bucket overlap with the names\n\t\t// of the standard properties we put in the telemetry events, our values should not be overwritten\n\t\t// by the custom properties.\n\n\t\tconst bucket1 = \"bucket1\";\n\t\tconst bucketProperties: Map<string, ITelemetryBaseProperties> = new Map<\n\t\t\tstring,\n\t\t\tITelemetryBaseProperties\n\t\t>([\n\t\t\t// Here just using a duration value that we can be sure will not be the actual value, to make sure the\n\t\t\t// actuals is different from this one (since it's much harder to guarantee an exact duration\n\t\t\t// value to test for equality).\n\t\t\t[bucket1, { duration: 1000, count: 1000 }],\n\t\t]);\n\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\" },\n\t\t\tlogger,\n\t\t\t1,\n\t\t\tfalse,\n\t\t\tbucketProperties,\n\t\t);\n\t\thelper.measure(() => {}, bucket1);\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tassert.strictEqual(event.count, 1);\n\t\tassert(event.duration !== bucketProperties.get(\"bucket1\")!.duration);\n\t});\n\n\tit(\"generates telemetry event from buffered data when disposed\", () => {\n\t\t// Logging several buckets to make sure they are all flushed. We can only distingush the events based on the\n\t\t// custom properties added to the event for each bucket\n\t\tconst bucket1 = \"bucket1\";\n\t\tconst bucket2 = \"bucket2\";\n\t\tconst bucketProperties: Map<string, ITelemetryBaseProperties> = new Map<\n\t\t\tstring,\n\t\t\tITelemetryBaseProperties\n\t\t>([\n\t\t\t[bucket1, { prop1: \"value1\" }],\n\t\t\t[bucket2, { prop2: \"value2\" }],\n\t\t]);\n\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\" },\n\t\t\tlogger,\n\t\t\t5,\n\t\t\tfalse,\n\t\t\tbucketProperties,\n\t\t);\n\n\t\t// Only measure 4 times when we need 5 samples before writing the telemetry event\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\thelper.measure(() => {}, bucket1);\n\t\t\thelper.measure(() => {}, bucket2);\n\t\t}\n\n\t\t// Nothing should have been logged yet\n\t\tassert.strictEqual(logger.events.length, 0);\n\n\t\t// After disposing, there should be one event for each bucket\n\t\thelper.dispose();\n\t\tassert.strictEqual(logger.events.filter((x) => x.prop1 === \"value1\").length, 1);\n\t\tassert.strictEqual(logger.events.filter((x) => x.prop2 === \"value2\").length, 1);\n\t});\n\n\tit(\"no event is generated on dispose if there's no pending 'buffered' data\", () => {\n\t\tconst helper = new SampledTelemetryHelper({ eventName: \"testEvent\" }, logger, 2);\n\n\t\t// Nothing should have been logged after the first call\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 0);\n\n\t\t// On the second call, we should have 1 event\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\n\t\t// After disposing, there should still be just one event\n\t\thelper.dispose();\n\t\tassert.strictEqual(logger.events.length, 1);\n\t});\n});\n\nfunction ensurePropertiesExist(\n\tobject: ITelemetryPerformanceEventExt,\n\tpropNames: string[],\n\tnoExtraProperties: boolean = false,\n): void {\n\tfor (const name of propNames) {\n\t\tassert.strictEqual(object[name] !== undefined, true);\n\t}\n\n\tif (noExtraProperties) {\n\t\tconst actualNumberOfProps = Object.keys(object).length;\n\t\tconst expectedNumberOfProps = propNames.length;\n\t\tif (actualNumberOfProps !== expectedNumberOfProps) {\n\t\t\tassert.fail(\n\t\t\t\t`Object contains unexpected properties ` +\n\t\t\t\t\t`(${actualNumberOfProps} found, ${expectedNumberOfProps}) expected)`,\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"sampledTelemetryHelper.spec.js","sourceRoot":"","sources":["../../src/test/sampledTelemetryHelper.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AAMjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAQtE;;;GAGG;AACH,MAAM,UAAU;IAAhB;QACQ,WAAM,GAAoC,EAAE,CAAC;IAgBrD,CAAC;IAdA,oBAAoB,CAAC,KAAoC,EAAE,KAAe;QACzE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,KAA0B;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,kBAAkB,CAAC,KAAgC,EAAE,KAAe;QACnE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,cAAc,CAAC,KAA8B,EAAE,KAAe;QAC7D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;CAED;AAED,MAAM,uBAAuB,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACnE,MAAM,mBAAmB,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;AAE5E,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACvC,IAAI,MAAkB,CAAC;IAEvB,UAAU,CAAC,GAAG,EAAE;QACf,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,C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CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,qBAAqB,CAC7B,MAAqC,EACrC,SAAmB,EACnB,oBAA6B,KAAK;IAElC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC7B,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,IAAI,CAAC,CAAC;KACrD;IAED,IAAI,iBAAiB,EAAE;QACtB,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QACvD,MAAM,qBAAqB,GAAG,SAAS,CAAC,MAAM,CAAC;QAC/C,IAAI,mBAAmB,KAAK,qBAAqB,EAAE;YAClD,MAAM,CAAC,IAAI,CACV,wCAAwC;gBACvC,IAAI,mBAAmB,WAAW,qBAAqB,aAAa,CACrE,CAAC;SACF;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"node:assert\";\nimport type {\n\tITelemetryBaseEvent,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\n\nimport { SampledTelemetryHelper } from \"../sampledTelemetryHelper.js\";\nimport {\n\ttype ITelemetryErrorEventExt,\n\ttype ITelemetryGenericEventExt,\n\tITelemetryLoggerExt,\n\ttype ITelemetryPerformanceEventExt,\n} from \"../telemetryTypes.js\";\n\n/**\n * Test logger with only the necessary functionality used by the SampledTelemetryHelper\n * so we can test it.\n */\nclass TestLogger implements ITelemetryLoggerExt {\n\tpublic events: ITelemetryPerformanceEventExt[] = [];\n\n\tsendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown): void {\n\t\tthis.events.push(event);\n\t}\n\n\tsend(event: ITelemetryBaseEvent): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tsendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tsupportsTags?: true | undefined;\n}\n\nconst standardEventProperties = [\"eventName\", \"duration\", \"count\"];\nconst aggregateProperties = [\"totalDuration\", \"minDuration\", \"maxDuration\"];\n\ndescribe(\"SampledTelemetryHelper\", () => {\n\tlet logger: TestLogger;\n\n\tbeforeEach(() => {\n\t\tlogger = new TestLogger();\n\t});\n\n\tit(\"only writes event after correct number of samples\", () => {\n\t\tconst sampling = 10;\n\t\tconst helper = new SampledTelemetryHelper({ eventName: \"testEvent\" }, logger, sampling);\n\t\tfor (let i = 0; i < sampling - 1; i++) {\n\t\t\thelper.measure(() => {});\n\t\t}\n\t\tassert.strictEqual(logger.events.length, 0);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\n\t\t// Again to make sure the internal counter is reset correctly\n\t\tfor (let i = 0; i < sampling - 1; i++) {\n\t\t\thelper.measure(() => {});\n\t\t}\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 2);\n\t});\n\n\tit(\"does not include aggregate properties when it shouldn't\", () => {\n\t\tconst helper = new SampledTelemetryHelper({ eventName: \"testEvent\" }, logger, 1, false);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tensurePropertiesExist(event, standardEventProperties, true);\n\t\tassert.strictEqual(event.count, 1);\n\t});\n\n\tit(\"includes aggregate properties when it should\", () => {\n\t\tconst helper = new SampledTelemetryHelper({ eventName: \"testEvent\" }, logger, 1, true);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tensurePropertiesExist(event, [...standardEventProperties, ...aggregateProperties], true);\n\t\tassert.strictEqual(event.count, 1);\n\t});\n\n\tit(\"includes properties from base event when no aggregate properties are included\", () => {\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\", myProp: \"myValue\" },\n\t\t\tlogger,\n\t\t\t1,\n\t\t\tfalse,\n\t\t);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tensurePropertiesExist(event, [...standardEventProperties, \"myProp\"], true);\n\t\tassert.strictEqual(event.count, 1);\n\t\tassert.strictEqual(event.myProp, \"myValue\");\n\t});\n\n\tit(\"includes properties from base event when aggregate properties are included\", () => {\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\", myProp: \"myValue\" },\n\t\t\tlogger,\n\t\t\t1,\n\t\t\ttrue,\n\t\t);\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tensurePropertiesExist(\n\t\t\tevent,\n\t\t\t[...standardEventProperties, ...aggregateProperties, \"myProp\"],\n\t\t\ttrue,\n\t\t);\n\t\tassert.strictEqual(event.count, 1);\n\t\tassert.strictEqual(event.myProp, \"myValue\");\n\t});\n\n\tit(\"tracks buckets separately and includes per-bucket properties\", () => {\n\t\tconst bucket1 = \"bucket1\";\n\t\tconst bucket2 = \"bucket2\";\n\t\tconst bucketProperties: Map<string, ITelemetryBaseProperties> = new Map<\n\t\t\tstring,\n\t\t\tITelemetryBaseProperties\n\t\t>([\n\t\t\t[bucket1, { prop1: \"value1\" }],\n\t\t\t[bucket2, { prop2: \"value2\" }],\n\t\t]);\n\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\" },\n\t\t\tlogger,\n\t\t\t3,\n\t\t\tfalse,\n\t\t\tbucketProperties,\n\t\t);\n\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\thelper.measure(() => {}, bucket1);\n\t\t}\n\t\tfor (let i = 0; i < 7; i++) {\n\t\t\thelper.measure(() => {}, bucket2);\n\t\t}\n\n\t\tassert.strictEqual(logger.events.filter((x) => x.prop1 === \"value1\").length, 3);\n\t\tassert.strictEqual(logger.events.filter((x) => x.prop2 === \"value2\").length, 2);\n\t});\n\n\tit(\"bucket properties do not override measurement properties\", () => {\n\t\t// If the names of the properties specified by the consumers for a bucket overlap with the names\n\t\t// of the standard properties we put in the telemetry events, our values should not be overwritten\n\t\t// by the custom properties.\n\n\t\tconst bucket1 = \"bucket1\";\n\t\tconst bucketProperties: Map<string, ITelemetryBaseProperties> = new Map<\n\t\t\tstring,\n\t\t\tITelemetryBaseProperties\n\t\t>([\n\t\t\t// Here just using a duration value that we can be sure will not be the actual value, to make sure the\n\t\t\t// actuals is different from this one (since it's much harder to guarantee an exact duration\n\t\t\t// value to test for equality).\n\t\t\t[bucket1, { duration: 1000, count: 1000 }],\n\t\t]);\n\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\" },\n\t\t\tlogger,\n\t\t\t1,\n\t\t\tfalse,\n\t\t\tbucketProperties,\n\t\t);\n\t\thelper.measure(() => {}, bucket1);\n\t\tassert.strictEqual(logger.events.length, 1);\n\t\tconst event = logger.events[0];\n\t\tassert.strictEqual(event.count, 1);\n\t\tassert(event.duration !== bucketProperties.get(\"bucket1\")!.duration);\n\t});\n\n\tit(\"generates telemetry event from buffered data when disposed\", () => {\n\t\t// Logging several buckets to make sure they are all flushed. We can only distingush the events based on the\n\t\t// custom properties added to the event for each bucket\n\t\tconst bucket1 = \"bucket1\";\n\t\tconst bucket2 = \"bucket2\";\n\t\tconst bucketProperties: Map<string, ITelemetryBaseProperties> = new Map<\n\t\t\tstring,\n\t\t\tITelemetryBaseProperties\n\t\t>([\n\t\t\t[bucket1, { prop1: \"value1\" }],\n\t\t\t[bucket2, { prop2: \"value2\" }],\n\t\t]);\n\n\t\tconst helper = new SampledTelemetryHelper(\n\t\t\t{ eventName: \"testEvent\" },\n\t\t\tlogger,\n\t\t\t5,\n\t\t\tfalse,\n\t\t\tbucketProperties,\n\t\t);\n\n\t\t// Only measure 4 times when we need 5 samples before writing the telemetry event\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\thelper.measure(() => {}, bucket1);\n\t\t\thelper.measure(() => {}, bucket2);\n\t\t}\n\n\t\t// Nothing should have been logged yet\n\t\tassert.strictEqual(logger.events.length, 0);\n\n\t\t// After disposing, there should be one event for each bucket\n\t\thelper.dispose();\n\t\tassert.strictEqual(logger.events.filter((x) => x.prop1 === \"value1\").length, 1);\n\t\tassert.strictEqual(logger.events.filter((x) => x.prop2 === \"value2\").length, 1);\n\t});\n\n\tit(\"no event is generated on dispose if there's no pending 'buffered' data\", () => {\n\t\tconst helper = new SampledTelemetryHelper({ eventName: \"testEvent\" }, logger, 2);\n\n\t\t// Nothing should have been logged after the first call\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 0);\n\n\t\t// On the second call, we should have 1 event\n\t\thelper.measure(() => {});\n\t\tassert.strictEqual(logger.events.length, 1);\n\n\t\t// After disposing, there should still be just one event\n\t\thelper.dispose();\n\t\tassert.strictEqual(logger.events.length, 1);\n\t});\n});\n\nfunction ensurePropertiesExist(\n\tobject: ITelemetryPerformanceEventExt,\n\tpropNames: string[],\n\tnoExtraProperties: boolean = false,\n): void {\n\tfor (const name of propNames) {\n\t\tassert.strictEqual(object[name] !== undefined, true);\n\t}\n\n\tif (noExtraProperties) {\n\t\tconst actualNumberOfProps = Object.keys(object).length;\n\t\tconst expectedNumberOfProps = propNames.length;\n\t\tif (actualNumberOfProps !== expectedNumberOfProps) {\n\t\t\tassert.fail(\n\t\t\t\t`Object contains unexpected properties ` +\n\t\t\t\t\t`(${actualNumberOfProps} found, ${expectedNumberOfProps}) expected)`,\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryLogger.spec.js","sourceRoot":"","sources":["../../src/test/telemetryLogger.spec.ts"],"names":[],"mappings":"AAA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EAAE,MAAM,EAAE;gBAChC,IAAI,EAAE,MAAM;aACZ,CAAC;YACF,MAAM,SAAS,GAAG,yBAAyB,CAC1C,YAEkC,CAClC,CAAC;YACF,MAAM,QAAQ,GAAG,kDAAkD,CAAC;YACpE,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;YACnB,MAAM,SAAS,GAAG,yBAAyB,CAAC,SAAS,CAAC;gBACrD,OAAO,EAAE,CAAC;YACX,CAA+E,CAAC,CAAC;YACjF,MAAM,QAAQ,GAAG,sCAAsC,CAAC;YACxD,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACf,MAAM,SAAS,GAAG,yBAAyB;YAC1C,2CAA2C;YAC3C,IAAkF,CAClF,CAAC;YACF,MAAM,QAAQ,GAAG,MAAM,CAAC;YACxB,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACjB,MAAM,SAAS,GAAG,yBAAyB,CAC1C,MAAM,CAAC,MAAM,CAEqB,CAClC,CAAC;YACF,MAAM,QAAQ,GAAG,oCAAoC,CAAC;YACtD,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"node:assert\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerPropertyBags,\n\tITelemetryLoggerPropertyBag,\n\tTelemetryLogger,\n\tconvertToBasePropertyType,\n} from \"../logger.js\";\nimport {\n\tITaggedTelemetryPropertyTypeExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"../telemetryTypes.js\";\n\nclass TestTelemetryLogger extends TelemetryLogger {\n\tpublic events: ITelemetryBaseEvent[] = [];\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tthis.events.push(this.prepareEvent(event));\n\t}\n}\n\nconst allCases: ITelemetryLoggerPropertyBag[] = [\n\t{},\n\t{ allProp: 1 },\n\t{ allGetter: (): number => 1 },\n\t{ allProp: 1, allGetter: (): number => 1 },\n];\nconst errorCases: ITelemetryLoggerPropertyBag[] = [\n\t{},\n\t{ errorProp: 2 },\n\t{ errorGetter: (): number => 2 },\n\t{ errorProp: 2, errorGetter: (): number => 2 },\n];\n\n// eslint-disable-next-line unicorn/no-array-reduce\nconst propertyCases: (ITelemetryLoggerPropertyBags | undefined)[] = allCases.reduce<\n\tITelemetryLoggerPropertyBags[]\n>((pv, all) => {\n\tpv.push(...errorCases.map((error) => ({ all, error })));\n\treturn pv;\n}, []);\npropertyCases.push(\n\t...allCases.map((all) => ({ all, error: all })),\n\t...allCases,\n\t...errorCases,\n\tundefined,\n);\n\ndescribe(\"TelemetryLogger\", () => {\n\tdescribe(\"Properties\", () => {\n\t\tit(\"send\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tlogger.send({ category: \"anything\", eventName: \"whatever\" });\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"anything\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\tconst propsKeys = Object.keys(props?.all ?? {});\n\t\t\t\t// +2 for category and event name\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 2,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit(\"sendErrorEvent\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tlogger.sendErrorEvent({ eventName: \"whatever\" });\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"error\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\t// should include error props too\n\t\t\t\tconst expected = { error: \"whatever\", ...props?.all, ...props?.error };\n\t\t\t\tconst propsKeys = Object.keys(expected);\n\t\t\t\tfor (const k of propsKeys) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n\t\t\t\t\tconst e = typeof expected[k] === \"function\" ? expected[k]() : expected[k];\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\tevent[k],\n\t\t\t\t\t\te,\n\t\t\t\t\t\t`${k} value does not match.\n actual: ${JSON.stringify(event[k])} expected: ${JSON.stringify(e)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// +2 for category and event name\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 2,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit(\"sendErrorEvent with error field\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tlogger.sendErrorEvent({ eventName: \"whatever\", error: \"bad\" });\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"error\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\t// should include error props too\n\t\t\t\tconst expected = { error: \"bad\", ...props?.all, ...props?.error };\n\t\t\t\tconst propsKeys = Object.keys(expected);\n\t\t\t\tfor (const k of propsKeys) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n\t\t\t\t\tconst e = typeof expected[k] === \"function\" ? expected[k]() : expected[k];\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\tevent[k],\n\t\t\t\t\t\te,\n\t\t\t\t\t\t`${k} value does not match.\n actual: ${JSON.stringify(event[k])} expected: ${JSON.stringify(e)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// +2 for category and event name\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 2,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit(\"sendErrorEvent with error object\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tconst error = new Error(\"badMessage\");\n\t\t\t\tlogger.sendErrorEvent({ eventName: \"whatever\" }, error);\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"error\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\t// should include error props too\n\t\t\t\tconst expected = {\n\t\t\t\t\terror: error.message,\n\t\t\t\t\t...props?.all,\n\t\t\t\t\t...props?.error,\n\t\t\t\t};\n\t\t\t\tconst propsKeys = Object.keys(expected);\n\t\t\t\tfor (const k of propsKeys) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n\t\t\t\t\tconst e = typeof expected[k] === \"function\" ? expected[k]() : expected[k];\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\tevent[k],\n\t\t\t\t\t\te,\n\t\t\t\t\t\t`${k} value does not match.\n actual: ${JSON.stringify(event[k])} expected: ${JSON.stringify(e)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// +4 for category, event name, message and stack\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 4,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit(\"sendTelemetryEvent\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tlogger.sendTelemetryEvent({ eventName: \"whatever\" });\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"generic\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\tconst propsKeys = Object.keys(props?.all ?? {});\n\t\t\t\t// +2 for category and event name\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 2,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t});\n});\n\ndescribe(\"convertToBasePropertyType\", () => {\n\tdescribe(\"tagged properties\", () => {\n\t\tit(\"tagged number\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: 123,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: 123,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged string\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"test\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"test\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged boolean\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: true,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: true,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged array\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: [true, \"test\"],\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: JSON.stringify([true, \"test\"]),\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged flat object\", () => {\n\t\t\tconst value: TelemetryEventPropertyTypeExt = {\n\t\t\t\ta: 1,\n\t\t\t\tb: \"two\",\n\t\t\t\tc: true,\n\t\t\t\td: [false, \"okay\"],\n\t\t\t};\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: JSON.stringify(value),\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t});\n\tdescribe(\"untagged properties\", () => {\n\t\tit(\"number\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = 123;\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = 123;\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"string\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = \"test\";\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = \"test\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"boolean\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = true;\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = true;\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"undefined\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = undefined;\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = undefined;\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"array\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = [true, \"test\"];\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = JSON.stringify([true, \"test\"]);\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"flat object\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = {\n\t\t\t\ta: 1,\n\t\t\t\tb: \"two\",\n\t\t\t\tc: true,\n\t\t\t\td: [false, \"okay\"],\n\t\t\t\te: undefined,\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = JSON.stringify(property);\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"flat object with only undefined\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = {\n\t\t\t\te: undefined,\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = \"{}\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t});\n\t// Note the \"as any\" required in each of these cases.\n\t// These are unexpected, but it's good to have coverage to ensure they behave \"well enough\"\n\t// (e.g. they shouldn't crash)\n\tdescribe(\"Check various invalid (per typings) cases\", () => {\n\t\tit(\"nested ITaggedTelemetryPropertyTypeExt\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tvalue: { value: true, tag: \"tag\" } as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: '{\"value\":true,\"tag\":\"tag\"}',\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"nested non ITaggedTelemetryPropertyTypeExt\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tvalue: { foo: 3, bar: { x: 5 } as unknown } as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: '{\"foo\":3,\"bar\":{\"x\":5}}',\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged function\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: function x() {\n\t\t\t\t\treturn 54;\n\t\t\t\t} as unknown as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"INVALID PROPERTY (typed as function)\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged null value\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\tvalue: null as unknown as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"null\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged symbol\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: Symbol(\"Test\") as unknown as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"INVALID PROPERTY (typed as symbol)\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"nested object\", () => {\n\t\t\tconst nestedObject = {\n\t\t\t\tfoo: { foo: true, test: \"test\" },\n\t\t\t\ttest: \"test\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(\n\t\t\t\tnestedObject as unknown as\n\t\t\t\t\t| TelemetryEventPropertyTypeExt\n\t\t\t\t\t| ITaggedTelemetryPropertyTypeExt,\n\t\t\t);\n\t\t\tconst expected = '{\"foo\":{\"foo\":true,\"test\":\"test\"},\"test\":\"test\"}';\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"function\", () => {\n\t\t\tconst converted = convertToBasePropertyType(function x() {\n\t\t\t\treturn 54;\n\t\t\t} as unknown as TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt);\n\t\t\tconst expected = \"INVALID PROPERTY (typed as function)\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"null\", () => {\n\t\t\tconst converted = convertToBasePropertyType(\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\tnull as unknown as TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt,\n\t\t\t);\n\t\t\tconst expected = \"null\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"symbol\", () => {\n\t\t\tconst converted = convertToBasePropertyType(\n\t\t\t\tSymbol(\"Test\") as unknown as\n\t\t\t\t\t| TelemetryEventPropertyTypeExt\n\t\t\t\t\t| ITaggedTelemetryPropertyTypeExt,\n\t\t\t);\n\t\t\tconst expected = \"INVALID PROPERTY (typed as symbol)\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t});\n});\n"]}
1
+ {"version":3,"file":"telemetryLogger.spec.js","sourceRoot":"","sources":["../../src/test/telemetryLogger.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAGN,eAAe,EACf,yBAAyB,GACzB,MAAM,cAAc,CAAC;AAMtB,MAAM,mBAAoB,SAAQ,eAAe;IAAjD;;QACQ,WAAM,GAA0B,EAAE,CAAC;IAI3C,CAAC;IAHO,IAAI,CAAC,KAA0B;QACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5C,CAAC;CACD;AAED,MAAM,QAAQ,GAAkC;IAC/C,EAAE;IACF,EAAE,OAAO,EAAE,CAAC,EAAE;IACd,EAAE,SAAS,EAAE,GAAW,EAAE,CAAC,CAAC,EAAE;IAC9B,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,GAAW,EAAE,CAAC,CAAC,EAAE;CAC1C,CAAC;AACF,MAAM,UAAU,GAAkC;IACjD,EAAE;IACF,EAAE,SAAS,EAAE,CAAC,EAAE;IAChB,EAAE,WAAW,EAAE,GAAW,EAAE,CAAC,CAAC,EAAE;IAChC,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,GAAW,EAAE,CAAC,CAAC,EAAE;CAC9C,CAAC;AAEF,mDAAmD;AACnD,MAAM,aAAa,GAAiD,QAAQ,CAAC,MAAM,CAEjF,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;IACb,EAAE,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,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ACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"node:assert\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerPropertyBag,\n\tITelemetryLoggerPropertyBags,\n\tTelemetryLogger,\n\tconvertToBasePropertyType,\n} from \"../logger.js\";\nimport {\n\tITaggedTelemetryPropertyTypeExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"../telemetryTypes.js\";\n\nclass TestTelemetryLogger extends TelemetryLogger {\n\tpublic events: ITelemetryBaseEvent[] = [];\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tthis.events.push(this.prepareEvent(event));\n\t}\n}\n\nconst allCases: ITelemetryLoggerPropertyBag[] = [\n\t{},\n\t{ allProp: 1 },\n\t{ allGetter: (): number => 1 },\n\t{ allProp: 1, allGetter: (): number => 1 },\n];\nconst errorCases: ITelemetryLoggerPropertyBag[] = [\n\t{},\n\t{ errorProp: 2 },\n\t{ errorGetter: (): number => 2 },\n\t{ errorProp: 2, errorGetter: (): number => 2 },\n];\n\n// eslint-disable-next-line unicorn/no-array-reduce\nconst propertyCases: (ITelemetryLoggerPropertyBags | undefined)[] = allCases.reduce<\n\tITelemetryLoggerPropertyBags[]\n>((pv, all) => {\n\tpv.push(...errorCases.map((error) => ({ all, error })));\n\treturn pv;\n}, []);\npropertyCases.push(\n\t...allCases.map((all) => ({ all, error: all })),\n\t...allCases,\n\t...errorCases,\n\tundefined,\n);\n\ndescribe(\"TelemetryLogger\", () => {\n\tdescribe(\"Properties\", () => {\n\t\tit(\"send\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tlogger.send({ category: \"anything\", eventName: \"whatever\" });\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"anything\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\tconst propsKeys = Object.keys(props?.all ?? {});\n\t\t\t\t// +2 for category and event name\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 2,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit(\"sendErrorEvent\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tlogger.sendErrorEvent({ eventName: \"whatever\" });\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"error\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\t// should include error props too\n\t\t\t\tconst expected = { error: \"whatever\", ...props?.all, ...props?.error };\n\t\t\t\tconst propsKeys = Object.keys(expected);\n\t\t\t\tfor (const k of propsKeys) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n\t\t\t\t\tconst e = typeof expected[k] === \"function\" ? expected[k]() : expected[k];\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\tevent[k],\n\t\t\t\t\t\te,\n\t\t\t\t\t\t`${k} value does not match.\n actual: ${JSON.stringify(event[k])} expected: ${JSON.stringify(e)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// +2 for category and event name\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 2,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit(\"sendErrorEvent with error field\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tlogger.sendErrorEvent({ eventName: \"whatever\", error: \"bad\" });\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"error\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\t// should include error props too\n\t\t\t\tconst expected = { error: \"bad\", ...props?.all, ...props?.error };\n\t\t\t\tconst propsKeys = Object.keys(expected);\n\t\t\t\tfor (const k of propsKeys) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n\t\t\t\t\tconst e = typeof expected[k] === \"function\" ? expected[k]() : expected[k];\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\tevent[k],\n\t\t\t\t\t\te,\n\t\t\t\t\t\t`${k} value does not match.\n actual: ${JSON.stringify(event[k])} expected: ${JSON.stringify(e)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// +2 for category and event name\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 2,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit(\"sendErrorEvent with error object\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tconst error = new Error(\"badMessage\");\n\t\t\t\tlogger.sendErrorEvent({ eventName: \"whatever\" }, error);\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"error\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\t// should include error props too\n\t\t\t\tconst expected = {\n\t\t\t\t\terror: error.message,\n\t\t\t\t\t...props?.all,\n\t\t\t\t\t...props?.error,\n\t\t\t\t};\n\t\t\t\tconst propsKeys = Object.keys(expected);\n\t\t\t\tfor (const k of propsKeys) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n\t\t\t\t\tconst e = typeof expected[k] === \"function\" ? expected[k]() : expected[k];\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\tevent[k],\n\t\t\t\t\t\te,\n\t\t\t\t\t\t`${k} value does not match.\n actual: ${JSON.stringify(event[k])} expected: ${JSON.stringify(e)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// +4 for category, event name, message and stack\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 4,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit(\"sendTelemetryEvent\", () => {\n\t\t\tfor (const props of propertyCases) {\n\t\t\t\tconst logger = new TestTelemetryLogger(\"namespace\", props);\n\t\t\t\tlogger.sendTelemetryEvent({ eventName: \"whatever\" });\n\t\t\t\tassert.strictEqual(logger.events.length, 1);\n\t\t\t\tconst event = logger.events[0];\n\t\t\t\tassert.strictEqual(event.category, \"generic\");\n\t\t\t\tassert.strictEqual(event.eventName, \"namespace:whatever\");\n\t\t\t\tconst eventKeys = Object.keys(event);\n\t\t\t\tconst propsKeys = Object.keys(props?.all ?? {});\n\t\t\t\t// +2 for category and event name\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\teventKeys.length,\n\t\t\t\t\tpropsKeys.length + 2,\n\t\t\t\t\t`actual:\\n${JSON.stringify(event)}\\nexpected:${\n\t\t\t\t\t\tprops ? JSON.stringify(props) : \"undefined\"\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t});\n});\n\ndescribe(\"convertToBasePropertyType\", () => {\n\tdescribe(\"tagged properties\", () => {\n\t\tit(\"tagged number\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: 123,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: 123,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged string\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"test\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"test\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged boolean\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: true,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: true,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged array\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: [true, \"test\"],\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: JSON.stringify([true, \"test\"]),\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged flat object\", () => {\n\t\t\tconst value: TelemetryEventPropertyTypeExt = {\n\t\t\t\ta: 1,\n\t\t\t\tb: \"two\",\n\t\t\t\tc: true,\n\t\t\t\td: [false, \"okay\"],\n\t\t\t};\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: JSON.stringify(value),\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t});\n\tdescribe(\"untagged properties\", () => {\n\t\tit(\"number\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = 123;\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = 123;\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"string\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = \"test\";\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = \"test\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"boolean\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = true;\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = true;\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"undefined\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = undefined;\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = undefined;\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"array\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = [true, \"test\"];\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = JSON.stringify([true, \"test\"]);\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"flat object\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = {\n\t\t\t\ta: 1,\n\t\t\t\tb: \"two\",\n\t\t\t\tc: true,\n\t\t\t\td: [false, \"okay\"],\n\t\t\t\te: undefined,\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = JSON.stringify(property);\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"flat object with only undefined\", () => {\n\t\t\tconst property: TelemetryEventPropertyTypeExt = {\n\t\t\t\te: undefined,\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(property);\n\t\t\tconst expected: TelemetryEventPropertyTypeExt = \"{}\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t});\n\t// Note the \"as any\" required in each of these cases.\n\t// These are unexpected, but it's good to have coverage to ensure they behave \"well enough\"\n\t// (e.g. they shouldn't crash)\n\tdescribe(\"Check various invalid (per typings) cases\", () => {\n\t\tit(\"nested ITaggedTelemetryPropertyTypeExt\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tvalue: { value: true, tag: \"tag\" } as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: '{\"value\":true,\"tag\":\"tag\"}',\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"nested non ITaggedTelemetryPropertyTypeExt\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tvalue: { foo: 3, bar: { x: 5 } as unknown } as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: '{\"foo\":3,\"bar\":{\"x\":5}}',\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged function\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: function x() {\n\t\t\t\t\treturn 54;\n\t\t\t\t} as unknown as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"INVALID PROPERTY (typed as function)\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged null value\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\tvalue: null as unknown as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"null\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"tagged symbol\", () => {\n\t\t\tconst taggedProperty: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: Symbol(\"Test\") as unknown as TelemetryEventPropertyTypeExt,\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(taggedProperty);\n\t\t\tconst expected: ITaggedTelemetryPropertyTypeExt = {\n\t\t\t\tvalue: \"INVALID PROPERTY (typed as symbol)\",\n\t\t\t\ttag: \"tag\",\n\t\t\t};\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"nested object\", () => {\n\t\t\tconst nestedObject = {\n\t\t\t\tfoo: { foo: true, test: \"test\" },\n\t\t\t\ttest: \"test\",\n\t\t\t};\n\t\t\tconst converted = convertToBasePropertyType(\n\t\t\t\tnestedObject as unknown as\n\t\t\t\t\t| TelemetryEventPropertyTypeExt\n\t\t\t\t\t| ITaggedTelemetryPropertyTypeExt,\n\t\t\t);\n\t\t\tconst expected = '{\"foo\":{\"foo\":true,\"test\":\"test\"},\"test\":\"test\"}';\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"function\", () => {\n\t\t\tconst converted = convertToBasePropertyType(function x() {\n\t\t\t\treturn 54;\n\t\t\t} as unknown as TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt);\n\t\t\tconst expected = \"INVALID PROPERTY (typed as function)\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"null\", () => {\n\t\t\tconst converted = convertToBasePropertyType(\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\tnull as unknown as TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt,\n\t\t\t);\n\t\t\tconst expected = \"null\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t\tit(\"symbol\", () => {\n\t\t\tconst converted = convertToBasePropertyType(\n\t\t\t\tSymbol(\"Test\") as unknown as\n\t\t\t\t\t| TelemetryEventPropertyTypeExt\n\t\t\t\t\t| ITaggedTelemetryPropertyTypeExt,\n\t\t\t);\n\t\t\tconst expected = \"INVALID PROPERTY (typed as symbol)\";\n\t\t\tassert.deepStrictEqual(converted, expected);\n\t\t});\n\t});\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdCounter.spec.js","sourceRoot":"","sources":["../../src/test/thresholdCounter.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAQ1D,MAAM,mBAAmB;IAAzB;QACQ,WAAM,GAAgC,EAAE,CAAC;IAiBjD,CAAC;IAfO,IAAI,CAAC,MAA2B;QACtC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACrC,CAAC;IAEM,kBAAkB,CAAC,MAAiC,EAAE,MAAgB;QAC5E,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACrC,CAAC;IAEM,cAAc,CAAC,MAA+B,EAAE,MAAgB;QACtE,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACrC,CAAC;IAEM,oBAAoB,CAAC,KAAoC,EAAE,MAAgB;QACjF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACD;AAED,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IACjC,IAAI,MAA2B,CAAC;IAChC,IAAI,MAAwB,CAAC;IAC7B,MAAM,SAAS,GAAG,GAAG,CAAC;IAEtB,UAAU,CAAC,GAAG,EAAE;QACf,MAAM,GAAG,IAAI,mBA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AC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACrF,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"node:assert\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { ThresholdCounter } from \"../thresholdCounter.js\";\nimport {\n\tITelemetryLoggerExt,\n\ttype ITelemetryGenericEventExt,\n\ttype ITelemetryErrorEventExt,\n\ttype ITelemetryPerformanceEventExt,\n} from \"../telemetryTypes.js\";\n\nclass FakeTelemetryLogger implements ITelemetryLoggerExt {\n\tpublic events: ITelemetryGenericEventExt[] = [];\n\n\tpublic send(_event: ITelemetryBaseEvent): void {\n\t\tassert.fail(\"Should not be called\");\n\t}\n\n\tpublic sendTelemetryEvent(_event: ITelemetryGenericEventExt, _error?: unknown): void {\n\t\tassert.fail(\"Should not be called\");\n\t}\n\n\tpublic sendErrorEvent(_event: ITelemetryErrorEventExt, _error?: unknown): void {\n\t\tassert.fail(\"Should not be called\");\n\t}\n\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEventExt, _error?: unknown): void {\n\t\tthis.events.push(event);\n\t}\n}\n\ndescribe(\"ThresholdCounter\", () => {\n\tlet logger: FakeTelemetryLogger;\n\tlet sender: ThresholdCounter;\n\tconst threshold = 100;\n\n\tbeforeEach(() => {\n\t\tlogger = new FakeTelemetryLogger();\n\t\tsender = new ThresholdCounter(threshold, logger);\n\t});\n\n\tit(\"Send only if it passes threshold\", () => {\n\t\tsender.send(\"event_1\", threshold);\n\t\tsender.send(\"event_2\", threshold + 1);\n\t\tsender.send(\"event_3\", threshold - 1);\n\t\tsender.send(\"event_4\", 0);\n\n\t\tassert.strictEqual(logger.events.length, 2);\n\t\tassert.deepStrictEqual(logger.events[0], { eventName: \"event_1\", value: threshold });\n\t\tassert.deepStrictEqual(logger.events[1], { eventName: \"event_2\", value: threshold + 1 });\n\t});\n\n\tit(\"Send only if value is multiple\", () => {\n\t\tsender.sendIfMultiple(\"event_1\", threshold);\n\t\tsender.sendIfMultiple(\"event_2\", threshold * 2);\n\t\tsender.sendIfMultiple(\"event_3\", threshold - 1);\n\t\tsender.sendIfMultiple(\"event_4\", 0);\n\n\t\tassert.strictEqual(logger.events.length, 2);\n\t\tassert.deepStrictEqual(logger.events[0], { eventName: \"event_1\", value: threshold });\n\t\tassert.deepStrictEqual(logger.events[1], { eventName: \"event_2\", value: threshold * 2 });\n\t});\n});\n"]}
1
+ {"version":3,"file":"thresholdCounter.spec.js","sourceRoot":"","sources":["../../src/test/thresholdCounter.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AAQjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,mBAAmB;IAAzB;QACQ,WAAM,GAAgC,EAAE,CAAC;IAiBjD,CAAC;IAfO,IAAI,CAAC,MAA2B;QACtC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACrC,CAAC;IAEM,kBAAkB,CAAC,MAAiC,EAAE,MAAgB;QAC5E,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACrC,CAAC;IAEM,cAAc,CAAC,MAA+B,EAAE,MAAgB;QACtE,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACrC,CAAC;IAEM,oBAAoB,CAAC,KAAoC,EAAE,MAAgB;QACjF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CA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,CAAC,SAAS,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;QAChD,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAEpC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC5C,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACrF,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"node:assert\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype ITelemetryErrorEventExt,\n\ttype ITelemetryGenericEventExt,\n\tITelemetryLoggerExt,\n\ttype ITelemetryPerformanceEventExt,\n} from \"../telemetryTypes.js\";\nimport { ThresholdCounter } from \"../thresholdCounter.js\";\n\nclass FakeTelemetryLogger implements ITelemetryLoggerExt {\n\tpublic events: ITelemetryGenericEventExt[] = [];\n\n\tpublic send(_event: ITelemetryBaseEvent): void {\n\t\tassert.fail(\"Should not be called\");\n\t}\n\n\tpublic sendTelemetryEvent(_event: ITelemetryGenericEventExt, _error?: unknown): void {\n\t\tassert.fail(\"Should not be called\");\n\t}\n\n\tpublic sendErrorEvent(_event: ITelemetryErrorEventExt, _error?: unknown): void {\n\t\tassert.fail(\"Should not be called\");\n\t}\n\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEventExt, _error?: unknown): void {\n\t\tthis.events.push(event);\n\t}\n}\n\ndescribe(\"ThresholdCounter\", () => {\n\tlet logger: FakeTelemetryLogger;\n\tlet sender: ThresholdCounter;\n\tconst threshold = 100;\n\n\tbeforeEach(() => {\n\t\tlogger = new FakeTelemetryLogger();\n\t\tsender = new ThresholdCounter(threshold, logger);\n\t});\n\n\tit(\"Send only if it passes threshold\", () => {\n\t\tsender.send(\"event_1\", threshold);\n\t\tsender.send(\"event_2\", threshold + 1);\n\t\tsender.send(\"event_3\", threshold - 1);\n\t\tsender.send(\"event_4\", 0);\n\n\t\tassert.strictEqual(logger.events.length, 2);\n\t\tassert.deepStrictEqual(logger.events[0], { eventName: \"event_1\", value: threshold });\n\t\tassert.deepStrictEqual(logger.events[1], { eventName: \"event_2\", value: threshold + 1 });\n\t});\n\n\tit(\"Send only if value is multiple\", () => {\n\t\tsender.sendIfMultiple(\"event_1\", threshold);\n\t\tsender.sendIfMultiple(\"event_2\", threshold * 2);\n\t\tsender.sendIfMultiple(\"event_3\", threshold - 1);\n\t\tsender.sendIfMultiple(\"event_4\", 0);\n\n\t\tassert.strictEqual(logger.events.length, 2);\n\t\tassert.deepStrictEqual(logger.events[0], { eventName: \"event_1\", value: threshold });\n\t\tassert.deepStrictEqual(logger.events[1], { eventName: \"event_2\", value: threshold * 2 });\n\t});\n});\n"]}
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { strict as assert } from "node:assert";
6
- import { createSampledLogger } from "../utils.js";
7
- import { TelemetryDataTag, tagCodeArtifacts, tagData } from "../logger.js";
8
6
  import { mixinMonitoringContext } from "../config.js";
7
+ import { TelemetryDataTag, tagCodeArtifacts, tagData } from "../logger.js";
8
+ import { createSampledLogger } from "../utils.js";
9
9
  describe("tagData", () => {
10
10
  it("tagData with data", () => {
11
11
  const taggedData = tagData(TelemetryDataTag.CodeArtifact, { foo: "bar" });
@@ -1 +1 @@
1
- {"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../src/test/utils.spec.ts"],"names":[],"mappings":"AAAA;;;GAG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AC;QACF,MAAM,CAAC,eAAe,CACrB,UAAU,CAAC,OAAO,EAClB,oBAAoB,EACpB,yCAAyC,CACzC,CAAC;QAEF,+BAA+B;QAC/B,MAAM,WAAW,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;QAC9C,MAAM,WAAW,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;QAChD,MAAM,CAAC,eAAe,CACrB,WAAW,EACX,mBAAmB,EACnB,sCAAsC,CACtC,CAAC;QACF,MAAM,CAAC,eAAe,CACrB,WAAW,EACX,mBAAmB,EACnB,sCAAsC,CACtC,CAAC;QACF,MAAM,CAAC,eAAe,CACrB,YAAY,EACZ,oBAAoB,EACpB,uCAAuC,CACvC,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport {\n\tConfigTypes,\n\tIConfigProviderBase,\n\tITelemetryBaseEvent,\n} from \"@fluidframework/core-interfaces\";\nimport { IEventSampler, createSampledLogger } from \"../utils.js\";\nimport { TelemetryDataTag, tagCodeArtifacts, tagData } from \"../logger.js\";\nimport { mixinMonitoringContext } from \"../config.js\";\nimport { ITelemetryGenericEventExt, ITelemetryLoggerExt } from \"../telemetryTypes.js\";\n\ndescribe(\"tagData\", () => {\n\tit(\"tagData with data\", () => {\n\t\tconst taggedData = tagData(TelemetryDataTag.CodeArtifact, { foo: \"bar\" });\n\t\tconst expected: typeof taggedData = {\n\t\t\tfoo: {\n\t\t\t\tvalue: \"bar\",\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t};\n\t\tassert.deepStrictEqual(taggedData, expected);\n\t});\n\tit(\"tagData with undefined\", () => {\n\t\tconst taggedData = tagData(TelemetryDataTag.CodeArtifact, { none: undefined });\n\t\tconst expected: Partial<typeof taggedData> = {};\n\t\tassert.deepStrictEqual(taggedData, expected);\n\t});\n\n\tit(\"tagData with complex object\", () => {\n\t\tconst taggedData = tagData(TelemetryDataTag.CodeArtifact, {\n\t\t\tfoo: \"bar\",\n\t\t\tnone: undefined,\n\t\t\tnumber: 0,\n\t\t});\n\t\tconst expected: Partial<typeof taggedData> = {\n\t\t\tfoo: {\n\t\t\t\tvalue: \"bar\",\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t\tnumber: {\n\t\t\t\tvalue: 0,\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t};\n\n\t\tassert.deepEqual(taggedData, expected);\n\t});\n});\n\ndescribe(\"Sampling\", () => {\n\tlet events: (ITelemetryBaseEvent | ITelemetryGenericEventExt)[] = [];\n\n\tfunction getMockLoggerExtWithConfig(\n\t\tconfigDictionary?: Record<string, ConfigTypes>,\n\t): ITelemetryLoggerExt {\n\t\tconst logger: ITelemetryLoggerExt = {\n\t\t\tsend(event: ITelemetryBaseEvent): void {\n\t\t\t\tevents.push(event);\n\t\t\t},\n\t\t\tsendTelemetryEvent: (event) => {\n\t\t\t\tevents.push(event);\n\t\t\t},\n\t\t\tsendErrorEvent: (event) => {\n\t\t\t\tevents.push(event);\n\t\t\t},\n\t\t\tsendPerformanceEvent: (event) => {\n\t\t\t\tevents.push(event);\n\t\t\t},\n\t\t};\n\n\t\tconst configProvider = (settings: Record<string, ConfigTypes>): IConfigProviderBase => ({\n\t\t\tgetRawConfig: (name: string): ConfigTypes => settings[name],\n\t\t});\n\n\t\treturn mixinMonitoringContext(logger, configProvider(configDictionary ?? {})).logger;\n\t}\n\n\t/**\n\t * Creates an event sampler that uses a systematic approach to sampling (Sampling every nth event)\n\t */\n\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\tfunction createSystematicEventSampler(options: { samplingRate: number }): IEventSampler {\n\t\tlet eventCount = -1;\n\t\treturn {\n\t\t\tsample: (): boolean => {\n\t\t\t\teventCount++;\n\t\t\t\tconst shouldSample = eventCount % options.samplingRate === 0;\n\t\t\t\tif (shouldSample) {\n\t\t\t\t\teventCount = 0;\n\t\t\t\t}\n\t\t\t\treturn shouldSample;\n\t\t\t},\n\t\t};\n\t}\n\n\tbeforeEach(() => {\n\t\tevents = [];\n\t});\n\n\tit(\"Events are not sampled if DisableSampling telemetry flag is set to true\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": true,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\tconst loggerWithoutSampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 1 }),\n\t\t);\n\t\tconst loggerWithEvery5Sampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 5 }),\n\t\t);\n\n\t\tconst totalEventCount = 15;\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tloggerWithoutSampling.send({ category: \"generic\", eventName: \"noSampling\" });\n\t\t\tloggerWithEvery5Sampling.send({ category: \"generic\", eventName: \"oneEveryFive\" });\n\t\t}\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"noSampling\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"oneEveryFive\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t});\n\n\tit(\"Events are not sampled if DisableSampling telemetry flag is set to true and no sampler is provided\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": true,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\t// Sampling is enabled AND there was no sampler provided\n\t\tconst loggerWithoutSampling = createSampledLogger(logger);\n\n\t\tconst totalEventCount = 15;\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tloggerWithoutSampling.send({ category: \"generic\", eventName: \"noSampling\" });\n\t\t}\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"noSampling\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t});\n\n\tit(\"Events are not sampled if DisableSampling telemetry flag is set to false but no sampler is provided\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": false,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\t// Sampling is enabled however there was no sampler provided so all events will be sent.\n\t\tconst loggerWithoutSampling = createSampledLogger(logger);\n\n\t\tconst totalEventCount = 15;\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tloggerWithoutSampling.send({ category: \"generic\", eventName: \"noSampling\" });\n\t\t}\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"noSampling\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t});\n\n\tit(\"Systematic Sampling works as expected\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": false,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\tconst loggerWithoutSampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 1 }),\n\t\t);\n\t\tconst loggerWithEvery3Sampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 3 }),\n\t\t);\n\t\tconst loggerWithEvery5Sampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 5 }),\n\t\t);\n\n\t\tconst totalEventCount = 15;\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tloggerWithoutSampling.send({ category: \"generic\", eventName: \"noSampling\" });\n\t\t\tloggerWithEvery3Sampling.send({ category: \"generic\", eventName: \"oneEveryThree\" });\n\t\t\tloggerWithEvery5Sampling.send({ category: \"generic\", eventName: \"oneEveryFive\" });\n\t\t}\n\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"noSampling\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"oneEveryThree\").length,\n\t\t\ttotalEventCount / 3,\n\t\t);\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"oneEveryFive\").length,\n\t\t\ttotalEventCount / 5,\n\t\t);\n\t});\n\n\tit(\"Event Sampler works as expected with externally controlled state\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": false,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\tinterface ExampleEvent extends ITelemetryBaseEvent {\n\t\t\teventNumber: number;\n\t\t\tappNumber1: number;\n\t\t\tappNumber2: number;\n\t\t\tappBoolean1: boolean;\n\t\t\tappModeString: string;\n\t\t}\n\n\t\tlet exampleAppDataNumber1 = 0;\n\t\tlet exampleAppDataNumber2 = 10;\n\t\tlet exampleAppDataBoolean1 = true;\n\t\tlet exampleAppDataModeString = \"ready\";\n\n\t\t/* eslint-disable unicorn/consistent-function-scoping */\n\t\tconst shouldSampleEvent = (\n\t\t\tappNumber1: number,\n\t\t\tappNumber2: number,\n\t\t\tappBoolean1: boolean,\n\t\t\tappMode: string,\n\t\t): boolean => {\n\t\t\tconst shouldSample =\n\t\t\t\tappNumber1 < 1 && appNumber2 > 1 && appBoolean1 === true && appMode === \"ready\";\n\n\t\t\treturn shouldSample;\n\t\t};\n\t\t/* eslint-enable */\n\n\t\tconst customEventSampler: IEventSampler = {\n\t\t\tsample: () =>\n\t\t\t\tshouldSampleEvent(\n\t\t\t\t\texampleAppDataNumber1,\n\t\t\t\t\texampleAppDataNumber2,\n\t\t\t\t\texampleAppDataBoolean1,\n\t\t\t\t\texampleAppDataModeString,\n\t\t\t\t),\n\t\t};\n\n\t\tconst loggerWithSampling = createSampledLogger(logger, customEventSampler);\n\n\t\tconst totalEventCount = 20;\n\t\tconst eventName = \"testEvent\";\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\t// These values should cause events to be emitted (sampler returns false)\n\t\t\t\texampleAppDataNumber1 = -10;\n\t\t\t\texampleAppDataNumber2 = 2;\n\t\t\t\texampleAppDataBoolean1 = true;\n\t\t\t\texampleAppDataModeString = \"ready\";\n\t\t\t} else {\n\t\t\t\t// These values should cause events to not be emitted (sampler returns true)\n\t\t\t\texampleAppDataNumber1 = 0;\n\t\t\t\texampleAppDataNumber2 = 10;\n\t\t\t\texampleAppDataBoolean1 = true;\n\t\t\t\texampleAppDataModeString = \"not_ready\";\n\t\t\t}\n\n\t\t\tloggerWithSampling.send({\n\t\t\t\tcategory: \"generic\",\n\t\t\t\teventName,\n\t\t\t\teventNumber: i,\n\t\t\t\tappNumber1: exampleAppDataNumber1,\n\t\t\t\tappNumber2: exampleAppDataNumber2,\n\t\t\t\tappBoolean1: exampleAppDataBoolean1,\n\t\t\t\tappModeString: exampleAppDataModeString,\n\t\t\t});\n\t\t}\n\n\t\tconst emittedEvents = events.filter((event) => event.eventName === eventName);\n\t\tassert.equal(emittedEvents.length === 10, true);\n\t\tfor (const event of emittedEvents) {\n\t\t\tconst typedEvent = event as ExampleEvent;\n\t\t\tassert.equal(\n\t\t\t\tshouldSampleEvent(\n\t\t\t\t\ttypedEvent.appNumber1,\n\t\t\t\t\ttypedEvent.appNumber2,\n\t\t\t\t\ttypedEvent.appBoolean1,\n\t\t\t\t\ttypedEvent.appModeString,\n\t\t\t\t),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t});\n});\n\ndescribe(\"tagCodeArtifacts\", () => {\n\tit(\"tagCodeArtifacts with undefined\", () => {\n\t\tconst taggedData = tagCodeArtifacts({ node: undefined });\n\t\tconst expected: Partial<typeof taggedData> = {};\n\t\tassert.deepStrictEqual(taggedData, expected, \"undefined not tagged as expected\");\n\t});\n\n\tit(\"tagCodeArtifacts with TelemetryBaseEventPropertyType properties\", () => {\n\t\tconst taggedData = tagCodeArtifacts({\n\t\t\tstring: \"foo\",\n\t\t\tnumber: 0,\n\t\t\tboolean: true,\n\t\t\tnone: undefined,\n\t\t});\n\t\tconst expected: Partial<typeof taggedData> = {\n\t\t\tstring: {\n\t\t\t\tvalue: \"foo\",\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t\tnumber: {\n\t\t\t\tvalue: 0,\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t\tboolean: {\n\t\t\t\tvalue: true,\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t};\n\t\tassert.deepStrictEqual(\n\t\t\ttaggedData,\n\t\t\texpected,\n\t\t\t\"TelemetryBaseEventPropertyType not tagged as expected\",\n\t\t);\n\t});\n\n\tit(\"tagCodeArtifacts with TelemetryBaseEventPropertyType getters\", () => {\n\t\tconst taggedData = tagCodeArtifacts({\n\t\t\tstring: () => \"foo\",\n\t\t\tnumber: () => 0,\n\t\t\tboolean: () => true,\n\t\t});\n\t\tconst stringValue = taggedData.string();\n\t\tconst numberValue = taggedData.number();\n\t\tconst booleanValue = taggedData.boolean();\n\n\t\tassert.deepStrictEqual(\n\t\t\tstringValue,\n\t\t\t{\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\tvalue: \"foo\",\n\t\t\t},\n\t\t\t\"string getter not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\tnumberValue,\n\t\t\t{\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\tvalue: 0,\n\t\t\t},\n\t\t\t\"number getter not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\tbooleanValue,\n\t\t\t{\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\tvalue: true,\n\t\t\t},\n\t\t\t\"boolean getter not tagged as expected\",\n\t\t);\n\t});\n\n\tit(\"tagCodeArtifacts with both TelemetryBaseEventPropertyType properties and getters\", () => {\n\t\tconst expectedStringValue = {\n\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\tvalue: \"foo\",\n\t\t};\n\t\tconst expectedNumberValue = {\n\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\tvalue: 0,\n\t\t};\n\t\tconst expectedBooleanValue = {\n\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\tvalue: true,\n\t\t};\n\n\t\tconst taggedData = tagCodeArtifacts({\n\t\t\tstring: \"foo\",\n\t\t\tnumber: 0,\n\t\t\tboolean: true,\n\t\t\tstringGetter: () => \"foo\",\n\t\t\tnumberGetter: () => 0,\n\t\t\tbooleanGetter: () => true,\n\t\t});\n\n\t\t// Validate basic properties are tagged.\n\t\tassert.deepStrictEqual(\n\t\t\ttaggedData.string,\n\t\t\texpectedStringValue,\n\t\t\t\"string property not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\ttaggedData.number,\n\t\t\texpectedNumberValue,\n\t\t\t\"number property not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\ttaggedData.boolean,\n\t\t\texpectedBooleanValue,\n\t\t\t\"boolean property not tagged as expected\",\n\t\t);\n\n\t\t// Validate getters are tagged.\n\t\tconst stringValue = taggedData.stringGetter();\n\t\tconst numberValue = taggedData.numberGetter();\n\t\tconst booleanValue = taggedData.booleanGetter();\n\t\tassert.deepStrictEqual(\n\t\t\tstringValue,\n\t\t\texpectedStringValue,\n\t\t\t\"string getter not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\tnumberValue,\n\t\t\texpectedNumberValue,\n\t\t\t\"number getter not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\tbooleanValue,\n\t\t\texpectedBooleanValue,\n\t\t\t\"boolean getter not tagged as expected\",\n\t\t);\n\t});\n});\n"]}
1
+ {"version":3,"file":"utils.spec.js","sourceRoot":"","s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AAC,MAAM,EACjB,mBAAmB,EACnB,wCAAwC,CACxC,CAAC;QACF,MAAM,CAAC,eAAe,CACrB,UAAU,CAAC,OAAO,EAClB,oBAAoB,EACpB,yCAAyC,CACzC,CAAC;QAEF,+BAA+B;QAC/B,MAAM,WAAW,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;QAC9C,MAAM,WAAW,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC;QAChD,MAAM,CAAC,eAAe,CACrB,WAAW,EACX,mBAAmB,EACnB,sCAAsC,CACtC,CAAC;QACF,MAAM,CAAC,eAAe,CACrB,WAAW,EACX,mBAAmB,EACnB,sCAAsC,CACtC,CAAC;QACF,MAAM,CAAC,eAAe,CACrB,YAAY,EACZ,oBAAoB,EACpB,uCAAuC,CACvC,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport {\n\tConfigTypes,\n\tIConfigProviderBase,\n\tITelemetryBaseEvent,\n} from \"@fluidframework/core-interfaces\";\nimport { mixinMonitoringContext } from \"../config.js\";\nimport { TelemetryDataTag, tagCodeArtifacts, tagData } from \"../logger.js\";\nimport { ITelemetryGenericEventExt, ITelemetryLoggerExt } from \"../telemetryTypes.js\";\nimport { IEventSampler, createSampledLogger } from \"../utils.js\";\n\ndescribe(\"tagData\", () => {\n\tit(\"tagData with data\", () => {\n\t\tconst taggedData = tagData(TelemetryDataTag.CodeArtifact, { foo: \"bar\" });\n\t\tconst expected: typeof taggedData = {\n\t\t\tfoo: {\n\t\t\t\tvalue: \"bar\",\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t};\n\t\tassert.deepStrictEqual(taggedData, expected);\n\t});\n\tit(\"tagData with undefined\", () => {\n\t\tconst taggedData = tagData(TelemetryDataTag.CodeArtifact, { none: undefined });\n\t\tconst expected: Partial<typeof taggedData> = {};\n\t\tassert.deepStrictEqual(taggedData, expected);\n\t});\n\n\tit(\"tagData with complex object\", () => {\n\t\tconst taggedData = tagData(TelemetryDataTag.CodeArtifact, {\n\t\t\tfoo: \"bar\",\n\t\t\tnone: undefined,\n\t\t\tnumber: 0,\n\t\t});\n\t\tconst expected: Partial<typeof taggedData> = {\n\t\t\tfoo: {\n\t\t\t\tvalue: \"bar\",\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t\tnumber: {\n\t\t\t\tvalue: 0,\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t};\n\n\t\tassert.deepEqual(taggedData, expected);\n\t});\n});\n\ndescribe(\"Sampling\", () => {\n\tlet events: (ITelemetryBaseEvent | ITelemetryGenericEventExt)[] = [];\n\n\tfunction getMockLoggerExtWithConfig(\n\t\tconfigDictionary?: Record<string, ConfigTypes>,\n\t): ITelemetryLoggerExt {\n\t\tconst logger: ITelemetryLoggerExt = {\n\t\t\tsend(event: ITelemetryBaseEvent): void {\n\t\t\t\tevents.push(event);\n\t\t\t},\n\t\t\tsendTelemetryEvent: (event) => {\n\t\t\t\tevents.push(event);\n\t\t\t},\n\t\t\tsendErrorEvent: (event) => {\n\t\t\t\tevents.push(event);\n\t\t\t},\n\t\t\tsendPerformanceEvent: (event) => {\n\t\t\t\tevents.push(event);\n\t\t\t},\n\t\t};\n\n\t\tconst configProvider = (settings: Record<string, ConfigTypes>): IConfigProviderBase => ({\n\t\t\tgetRawConfig: (name: string): ConfigTypes => settings[name],\n\t\t});\n\n\t\treturn mixinMonitoringContext(logger, configProvider(configDictionary ?? {})).logger;\n\t}\n\n\t/**\n\t * Creates an event sampler that uses a systematic approach to sampling (Sampling every nth event)\n\t */\n\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\tfunction createSystematicEventSampler(options: { samplingRate: number }): IEventSampler {\n\t\tlet eventCount = -1;\n\t\treturn {\n\t\t\tsample: (): boolean => {\n\t\t\t\teventCount++;\n\t\t\t\tconst shouldSample = eventCount % options.samplingRate === 0;\n\t\t\t\tif (shouldSample) {\n\t\t\t\t\teventCount = 0;\n\t\t\t\t}\n\t\t\t\treturn shouldSample;\n\t\t\t},\n\t\t};\n\t}\n\n\tbeforeEach(() => {\n\t\tevents = [];\n\t});\n\n\tit(\"Events are not sampled if DisableSampling telemetry flag is set to true\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": true,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\tconst loggerWithoutSampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 1 }),\n\t\t);\n\t\tconst loggerWithEvery5Sampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 5 }),\n\t\t);\n\n\t\tconst totalEventCount = 15;\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tloggerWithoutSampling.send({ category: \"generic\", eventName: \"noSampling\" });\n\t\t\tloggerWithEvery5Sampling.send({ category: \"generic\", eventName: \"oneEveryFive\" });\n\t\t}\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"noSampling\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"oneEveryFive\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t});\n\n\tit(\"Events are not sampled if DisableSampling telemetry flag is set to true and no sampler is provided\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": true,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\t// Sampling is enabled AND there was no sampler provided\n\t\tconst loggerWithoutSampling = createSampledLogger(logger);\n\n\t\tconst totalEventCount = 15;\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tloggerWithoutSampling.send({ category: \"generic\", eventName: \"noSampling\" });\n\t\t}\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"noSampling\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t});\n\n\tit(\"Events are not sampled if DisableSampling telemetry flag is set to false but no sampler is provided\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": false,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\t// Sampling is enabled however there was no sampler provided so all events will be sent.\n\t\tconst loggerWithoutSampling = createSampledLogger(logger);\n\n\t\tconst totalEventCount = 15;\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tloggerWithoutSampling.send({ category: \"generic\", eventName: \"noSampling\" });\n\t\t}\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"noSampling\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t});\n\n\tit(\"Systematic Sampling works as expected\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": false,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\tconst loggerWithoutSampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 1 }),\n\t\t);\n\t\tconst loggerWithEvery3Sampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 3 }),\n\t\t);\n\t\tconst loggerWithEvery5Sampling = createSampledLogger(\n\t\t\tlogger,\n\t\t\tcreateSystematicEventSampler({ samplingRate: 5 }),\n\t\t);\n\n\t\tconst totalEventCount = 15;\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tloggerWithoutSampling.send({ category: \"generic\", eventName: \"noSampling\" });\n\t\t\tloggerWithEvery3Sampling.send({ category: \"generic\", eventName: \"oneEveryThree\" });\n\t\t\tloggerWithEvery5Sampling.send({ category: \"generic\", eventName: \"oneEveryFive\" });\n\t\t}\n\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"noSampling\").length,\n\t\t\ttotalEventCount,\n\t\t);\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"oneEveryThree\").length,\n\t\t\ttotalEventCount / 3,\n\t\t);\n\t\tassert.equal(\n\t\t\tevents.filter((event) => event.eventName === \"oneEveryFive\").length,\n\t\t\ttotalEventCount / 5,\n\t\t);\n\t});\n\n\tit(\"Event Sampler works as expected with externally controlled state\", () => {\n\t\tconst injectedSettings = {\n\t\t\t\"Fluid.Telemetry.DisableSampling\": false,\n\t\t};\n\t\tconst logger = getMockLoggerExtWithConfig(injectedSettings);\n\n\t\tinterface ExampleEvent extends ITelemetryBaseEvent {\n\t\t\teventNumber: number;\n\t\t\tappNumber1: number;\n\t\t\tappNumber2: number;\n\t\t\tappBoolean1: boolean;\n\t\t\tappModeString: string;\n\t\t}\n\n\t\tlet exampleAppDataNumber1 = 0;\n\t\tlet exampleAppDataNumber2 = 10;\n\t\tlet exampleAppDataBoolean1 = true;\n\t\tlet exampleAppDataModeString = \"ready\";\n\n\t\t/* eslint-disable unicorn/consistent-function-scoping */\n\t\tconst shouldSampleEvent = (\n\t\t\tappNumber1: number,\n\t\t\tappNumber2: number,\n\t\t\tappBoolean1: boolean,\n\t\t\tappMode: string,\n\t\t): boolean => {\n\t\t\tconst shouldSample =\n\t\t\t\tappNumber1 < 1 && appNumber2 > 1 && appBoolean1 === true && appMode === \"ready\";\n\n\t\t\treturn shouldSample;\n\t\t};\n\t\t/* eslint-enable */\n\n\t\tconst customEventSampler: IEventSampler = {\n\t\t\tsample: () =>\n\t\t\t\tshouldSampleEvent(\n\t\t\t\t\texampleAppDataNumber1,\n\t\t\t\t\texampleAppDataNumber2,\n\t\t\t\t\texampleAppDataBoolean1,\n\t\t\t\t\texampleAppDataModeString,\n\t\t\t\t),\n\t\t};\n\n\t\tconst loggerWithSampling = createSampledLogger(logger, customEventSampler);\n\n\t\tconst totalEventCount = 20;\n\t\tconst eventName = \"testEvent\";\n\t\tfor (let i = 0; i < totalEventCount; i++) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\t// These values should cause events to be emitted (sampler returns false)\n\t\t\t\texampleAppDataNumber1 = -10;\n\t\t\t\texampleAppDataNumber2 = 2;\n\t\t\t\texampleAppDataBoolean1 = true;\n\t\t\t\texampleAppDataModeString = \"ready\";\n\t\t\t} else {\n\t\t\t\t// These values should cause events to not be emitted (sampler returns true)\n\t\t\t\texampleAppDataNumber1 = 0;\n\t\t\t\texampleAppDataNumber2 = 10;\n\t\t\t\texampleAppDataBoolean1 = true;\n\t\t\t\texampleAppDataModeString = \"not_ready\";\n\t\t\t}\n\n\t\t\tloggerWithSampling.send({\n\t\t\t\tcategory: \"generic\",\n\t\t\t\teventName,\n\t\t\t\teventNumber: i,\n\t\t\t\tappNumber1: exampleAppDataNumber1,\n\t\t\t\tappNumber2: exampleAppDataNumber2,\n\t\t\t\tappBoolean1: exampleAppDataBoolean1,\n\t\t\t\tappModeString: exampleAppDataModeString,\n\t\t\t});\n\t\t}\n\n\t\tconst emittedEvents = events.filter((event) => event.eventName === eventName);\n\t\tassert.equal(emittedEvents.length === 10, true);\n\t\tfor (const event of emittedEvents) {\n\t\t\tconst typedEvent = event as ExampleEvent;\n\t\t\tassert.equal(\n\t\t\t\tshouldSampleEvent(\n\t\t\t\t\ttypedEvent.appNumber1,\n\t\t\t\t\ttypedEvent.appNumber2,\n\t\t\t\t\ttypedEvent.appBoolean1,\n\t\t\t\t\ttypedEvent.appModeString,\n\t\t\t\t),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t});\n});\n\ndescribe(\"tagCodeArtifacts\", () => {\n\tit(\"tagCodeArtifacts with undefined\", () => {\n\t\tconst taggedData = tagCodeArtifacts({ node: undefined });\n\t\tconst expected: Partial<typeof taggedData> = {};\n\t\tassert.deepStrictEqual(taggedData, expected, \"undefined not tagged as expected\");\n\t});\n\n\tit(\"tagCodeArtifacts with TelemetryBaseEventPropertyType properties\", () => {\n\t\tconst taggedData = tagCodeArtifacts({\n\t\t\tstring: \"foo\",\n\t\t\tnumber: 0,\n\t\t\tboolean: true,\n\t\t\tnone: undefined,\n\t\t});\n\t\tconst expected: Partial<typeof taggedData> = {\n\t\t\tstring: {\n\t\t\t\tvalue: \"foo\",\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t\tnumber: {\n\t\t\t\tvalue: 0,\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t\tboolean: {\n\t\t\t\tvalue: true,\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t},\n\t\t};\n\t\tassert.deepStrictEqual(\n\t\t\ttaggedData,\n\t\t\texpected,\n\t\t\t\"TelemetryBaseEventPropertyType not tagged as expected\",\n\t\t);\n\t});\n\n\tit(\"tagCodeArtifacts with TelemetryBaseEventPropertyType getters\", () => {\n\t\tconst taggedData = tagCodeArtifacts({\n\t\t\tstring: () => \"foo\",\n\t\t\tnumber: () => 0,\n\t\t\tboolean: () => true,\n\t\t});\n\t\tconst stringValue = taggedData.string();\n\t\tconst numberValue = taggedData.number();\n\t\tconst booleanValue = taggedData.boolean();\n\n\t\tassert.deepStrictEqual(\n\t\t\tstringValue,\n\t\t\t{\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\tvalue: \"foo\",\n\t\t\t},\n\t\t\t\"string getter not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\tnumberValue,\n\t\t\t{\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\tvalue: 0,\n\t\t\t},\n\t\t\t\"number getter not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\tbooleanValue,\n\t\t\t{\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\tvalue: true,\n\t\t\t},\n\t\t\t\"boolean getter not tagged as expected\",\n\t\t);\n\t});\n\n\tit(\"tagCodeArtifacts with both TelemetryBaseEventPropertyType properties and getters\", () => {\n\t\tconst expectedStringValue = {\n\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\tvalue: \"foo\",\n\t\t};\n\t\tconst expectedNumberValue = {\n\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\tvalue: 0,\n\t\t};\n\t\tconst expectedBooleanValue = {\n\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\tvalue: true,\n\t\t};\n\n\t\tconst taggedData = tagCodeArtifacts({\n\t\t\tstring: \"foo\",\n\t\t\tnumber: 0,\n\t\t\tboolean: true,\n\t\t\tstringGetter: () => \"foo\",\n\t\t\tnumberGetter: () => 0,\n\t\t\tbooleanGetter: () => true,\n\t\t});\n\n\t\t// Validate basic properties are tagged.\n\t\tassert.deepStrictEqual(\n\t\t\ttaggedData.string,\n\t\t\texpectedStringValue,\n\t\t\t\"string property not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\ttaggedData.number,\n\t\t\texpectedNumberValue,\n\t\t\t\"number property not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\ttaggedData.boolean,\n\t\t\texpectedBooleanValue,\n\t\t\t\"boolean property not tagged as expected\",\n\t\t);\n\n\t\t// Validate getters are tagged.\n\t\tconst stringValue = taggedData.stringGetter();\n\t\tconst numberValue = taggedData.numberGetter();\n\t\tconst booleanValue = taggedData.booleanGetter();\n\t\tassert.deepStrictEqual(\n\t\t\tstringValue,\n\t\t\texpectedStringValue,\n\t\t\t\"string getter not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\tnumberValue,\n\t\t\texpectedNumberValue,\n\t\t\t\"number getter not tagged as expected\",\n\t\t);\n\t\tassert.deepStrictEqual(\n\t\t\tbooleanValue,\n\t\t\texpectedBooleanValue,\n\t\t\t\"boolean getter not tagged as expected\",\n\t\t);\n\t});\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.2.0.0.246488",
3
+ "version": "2.0.0-dev-rc.3.0.0.250606",
4
4
  "description": "Collection of telemetry relates utilities for Fluid",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -77,16 +77,17 @@
77
77
  "temp-directory": "nyc/.nyc_output"
78
78
  },
79
79
  "dependencies": {
80
- "@fluid-internal/client-utils": "2.0.0-dev-rc.2.0.0.246488",
81
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.2.0.0.246488",
82
- "@fluidframework/core-utils": "2.0.0-dev-rc.2.0.0.246488",
80
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.3.0.0.250606",
81
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.3.0.0.250606",
82
+ "@fluidframework/core-utils": "2.0.0-dev-rc.3.0.0.250606",
83
83
  "@fluidframework/protocol-definitions": "^3.2.0",
84
84
  "debug": "^4.3.4",
85
85
  "uuid": "^9.0.0"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@arethetypeswrong/cli": "^0.13.3",
89
- "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.2.0.0.246488",
89
+ "@biomejs/biome": "^1.6.2",
90
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.3.0.0.250606",
90
91
  "@fluid-tools/build-cli": "^0.34.0",
91
92
  "@fluidframework/build-common": "^2.0.3",
92
93
  "@fluidframework/build-tools": "^0.34.0",
@@ -157,16 +158,18 @@
157
158
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
158
159
  "bump-version": "npm version minor --no-push --no-git-tag-version && npm run build:genver",
159
160
  "check:are-the-types-wrong": "attw --pack . --entrypoints .",
161
+ "check:biome": "biome check .",
162
+ "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
160
163
  "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
161
164
  "ci:build:docs": "api-extractor run",
162
165
  "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
163
166
  "eslint": "eslint --format stylish src",
164
167
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
165
- "format": "npm run prettier:fix",
166
- "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
167
- "lint:fix": "npm run prettier:fix && npm run eslint:fix",
168
- "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
169
- "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
168
+ "format": "fluid-build --task format .",
169
+ "format:biome": "biome check --apply .",
170
+ "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
171
+ "lint": "fluid-build . --task lint",
172
+ "lint:fix": "fluid-build . --task eslint:fix --task format",
170
173
  "test": "npm run test:mocha",
171
174
  "test:coverage": "c8 npm test",
172
175
  "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
package/src/config.ts CHANGED
@@ -4,9 +4,9 @@
4
4
  */
5
5
 
6
6
  import {
7
- ITelemetryBaseLogger,
8
- IConfigProviderBase,
9
7
  ConfigTypes,
8
+ IConfigProviderBase,
9
+ ITelemetryBaseLogger,
10
10
  } from "@fluidframework/core-interfaces";
11
11
  import { Lazy } from "@fluidframework/core-utils";
12
12
  import { createChildLogger, tagCodeArtifacts } from "./logger.js";
package/src/error.ts CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  import {
7
7
  FluidErrorTypes,
8
- IGenericError,
9
8
  IErrorBase,
9
+ IGenericError,
10
10
  ITelemetryBaseProperties,
11
11
  IUsageError,
12
12
  } from "@fluidframework/core-interfaces";
@@ -10,17 +10,17 @@ import type {
10
10
  } from "@fluidframework/core-interfaces";
11
11
  import { v4 as uuid } from "uuid";
12
12
  import {
13
- hasErrorInstanceId,
14
13
  IFluidErrorBase,
14
+ hasErrorInstanceId,
15
15
  isFluidError,
16
16
  isValidLegacyError,
17
17
  } from "./fluidErrorBase.js";
18
+ import { convertToBasePropertyType } from "./logger.js";
18
19
  import type {
19
20
  ITelemetryLoggerExt,
20
- TelemetryEventPropertyTypeExt,
21
21
  ITelemetryPropertiesExt,
22
+ TelemetryEventPropertyTypeExt,
22
23
  } from "./telemetryTypes.js";
23
- import { convertToBasePropertyType } from "./logger.js";
24
24
 
25
25
  /**
26
26
  * Determines if the provided value is an object but neither null nor an array.
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { TypedEventEmitter, EventEmitterEventType } from "@fluid-internal/client-utils";
6
+ import { EventEmitterEventType, TypedEventEmitter } from "@fluid-internal/client-utils";
7
7
  import { IEvent } from "@fluidframework/core-interfaces";
8
8
 
9
9
  /**
package/src/logger.ts CHANGED
@@ -3,35 +3,35 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { IsomorphicPerformance, performance } from "@fluid-internal/client-utils";
6
7
  import {
7
8
  ITelemetryBaseEvent,
8
9
  ITelemetryBaseLogger,
10
+ ITelemetryBaseProperties,
9
11
  LogLevel,
10
12
  Tagged,
11
- ITelemetryBaseProperties,
12
13
  TelemetryBaseEventPropertyType,
13
14
  } from "@fluidframework/core-interfaces";
14
- import { IsomorphicPerformance, performance } from "@fluid-internal/client-utils";
15
15
  import {
16
16
  CachedConfigProvider,
17
17
  loggerIsMonitoringContext,
18
18
  mixinMonitoringContext,
19
19
  } from "./config.js";
20
20
  import {
21
- isILoggingError,
22
21
  extractLogSafeErrorProperties,
23
22
  generateStack,
23
+ isILoggingError,
24
24
  isTaggedTelemetryPropertyValue,
25
25
  } from "./errorLogging.js";
26
26
  import {
27
+ type ITelemetryErrorEventExt,
27
28
  ITelemetryEventExt,
28
29
  ITelemetryGenericEventExt,
29
30
  ITelemetryLoggerExt,
30
31
  ITelemetryPerformanceEventExt,
31
- TelemetryEventPropertyTypeExt,
32
- TelemetryEventCategory,
33
32
  ITelemetryPropertiesExt,
34
- type ITelemetryErrorEventExt,
33
+ TelemetryEventCategory,
34
+ TelemetryEventPropertyTypeExt,
35
35
  } from "./telemetryTypes.js";
36
36
 
37
37
  export interface Memory {
package/src/mockLogger.ts CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  LogLevel,
10
10
  } from "@fluidframework/core-interfaces";
11
11
  import { assert } from "@fluidframework/core-utils";
12
- import { ITelemetryLoggerExt, ITelemetryPropertiesExt } from "./telemetryTypes.js";
13
12
  import { createChildLogger } from "./logger.js";
13
+ import { ITelemetryLoggerExt, ITelemetryPropertiesExt } from "./telemetryTypes.js";
14
14
 
15
15
  /**
16
16
  * The MockLogger records events sent to it, and then can walk back over those events