@fluidframework/telemetry-utils 2.0.0-internal.2.4.0 → 2.0.0-internal.3.0.0

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.
@@ -18,7 +18,7 @@ export declare class MockLogger extends TelemetryLogger implements ITelemetryLog
18
18
  * events in order.
19
19
  * @param expectedEvents - events in order that are expected to appear in the recorded log.
20
20
  * These event objects may be subsets of the logged events.
21
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
21
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
22
22
  */
23
23
  matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
24
24
  /** Asserts that matchEvents is true, and prints the actual/expected output if not */
@@ -28,12 +28,22 @@ export declare class MockLogger extends TelemetryLogger implements ITelemetryLog
28
28
  * expected events.
29
29
  * @param expectedEvents - events that are expected to appear in the recorded log.
30
30
  * These event objects may be subsets of the logged events.
31
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
31
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
32
32
  * @returns if any of the expected events is found.
33
33
  */
34
34
  matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
35
35
  /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */
36
36
  assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
37
+ /**
38
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
39
+ * events in order.
40
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
41
+ * These event objects may be subsets of the logged events.
42
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
43
+ */
44
+ matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
45
+ /** Asserts that matchEvents is true, and prints the actual/expected output if not */
46
+ assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
37
47
  /** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */
38
48
  assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
39
49
  private getMatchedEventsCount;
@@ -1 +1 @@
1
- {"version":3,"file":"mockLogger.d.ts","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAAgB,YAAW,gBAAgB;IACvE,MAAM,EAAE,mBAAmB,EAAE,CAAM;;IAInC,KAAK;IAIL,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAItC;;;;;;OAMG;IACH,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAO7E,qFAAqF;IACrF,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAYrF;;;;;;;OAOG;IACH,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAK/E,uFAAuF;IACvF,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAYxF,6GAA6G;IAC7G,eAAe,CAAC,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAY3F,OAAO,CAAC,qBAAqB;IAkB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;CAI7B"}
1
+ {"version":3,"file":"mockLogger.d.ts","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAG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order.
27
27
  * @param expectedEvents - events in order that are expected to appear in the recorded log.
28
28
  * These event objects may be subsets of the logged events.
29
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
29
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
30
30
  */
31
31
  matchEvents(expectedEvents) {
32
32
  const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
@@ -51,7 +51,7 @@ ${JSON.stringify(actualEvents)}`);
51
51
  * expected events.
52
52
  * @param expectedEvents - events that are expected to appear in the recorded log.
53
53
  * These event objects may be subsets of the logged events.
54
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
54
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
55
55
  * @returns if any of the expected events is found.
56
56
  */
57
57
  matchAnyEvent(expectedEvents) {
@@ -66,6 +66,28 @@ ${JSON.stringify(actualEvents)}`);
66
66
  expected:
67
67
  ${JSON.stringify(expectedEvents)}
68
68
 
69
+ actual:
70
+ ${JSON.stringify(actualEvents)}`);
71
+ }
72
+ }
73
+ /**
74
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
75
+ * events in order.
76
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
77
+ * These event objects may be subsets of the logged events.
78
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
79
+ */
80
+ matchEventStrict(expectedEvents) {
81
+ return expectedEvents.length === this.events.length && this.matchEvents(expectedEvents);
82
+ }
83
+ /** Asserts that matchEvents is true, and prints the actual/expected output if not */
84
+ assertMatchStrict(expectedEvents, message) {
85
+ const actualEvents = this.events;
86
+ if (!this.matchEventStrict(expectedEvents)) {
87
+ throw new Error(`${message}
88
+ expected:
89
+ ${JSON.stringify(expectedEvents)}
90
+
69
91
  actual:
70
92
  ${JSON.stringify(actualEvents)}`);
71
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAA2C;AA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pC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;;;EAG9B,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;SACrB;IACT,CAAC;IAED,6GAA6G;IAC7G,eAAe,CAAC,gBAAyD,EAAE,OAAgB;QACvF,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;QACjC,IAAI,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO;;EAEpC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;;;EAGhC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;SACrB;IACT,CAAC;IAEO,qBAAqB,CAAC,cAAuD;QACjF,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1B,IAAI,cAAc,GAAG,cAAc,CAAC,MAAM;gBACtC,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC,EAC/D;gBACE,8CAA8C;gBAC9C,EAAE,cAAc,CAAC;aACpB;QACL,CAAC,CAAC,CAAC;QAEH,oFAAoF;QACpF,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAEjB,sCAAsC;QACtC,OAAO,cAAc,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,WAAW,CAAC,MAA2B,EAAE,QAA+C;QACnG,MAAM,MAAM,mCAAQ,MAAM,GAAK,QAAQ,CAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACJ;AAxGD,gCAwGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { TelemetryLogger } from \"./logger\";\n\n/**\n * The MockLogger records events sent to it, and then can walk back over those events\n * searching for a set of expected events to match against the logged events.\n */\nexport class MockLogger extends TelemetryLogger implements ITelemetryLogger {\n events: ITelemetryBaseEvent[] = [];\n\n constructor() { super(); }\n\n clear() {\n this.events = [];\n }\n\n send(event: ITelemetryBaseEvent): void {\n this.events.push(event);\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n // How many expected events were left over? Hopefully none.\n const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n return unmatchedExpectedEventCount === 0;\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEvents(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for any of the given\n * expected events.\n * @param expectedEvents - events that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.\n * @returns if any of the expected events is found.\n */\n matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n return matchedExpectedEventCount > 0;\n }\n\n /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */\n assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchAnyEvent(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */\n assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (this.matchAnyEvent(disallowedEvents)) {\n throw new Error(`${message}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n private getMatchedEventsCount(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): number {\n let iExpectedEvent = 0;\n this.events.forEach((event) => {\n if (iExpectedEvent < expectedEvents.length &&\n MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])\n ) {\n // We found the next expected event; increment\n ++iExpectedEvent;\n }\n });\n\n // Remove the events so far; next call will just compare subsequent events from here\n this.events = [];\n\n // Return the count of matched events.\n return iExpectedEvent;\n }\n\n /**\n * Ensure the expected event is a strict subset of the actual event\n */\n private static eventsMatch(actual: ITelemetryBaseEvent, expected: Omit<ITelemetryBaseEvent, \"category\">): boolean {\n const masked = { ...actual, ...expected };\n return JSON.stringify(masked) === JSON.stringify(actual);\n }\n}\n"]}
1
+ {"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAA2C;AAE3C;;;GAGG;AACH,MAAa,UAAW,SAAQ,wBAAe;IAG3C;QAAgB,KAAK,EAAE,CAAC;QAFxB,WAAM,GAA0B,EAAE,CAAC;IAEV,CAAC;IAE1B,KAAK;QACD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,KAA0B;QAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,cAAuD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,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACJ;AAhID,gCAgIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { TelemetryLogger } from \"./logger\";\n\n/**\n * The MockLogger records events sent to it, and then can walk back over those events\n * searching for a set of expected events to match against the logged events.\n */\nexport class MockLogger extends TelemetryLogger implements ITelemetryLogger {\n events: ITelemetryBaseEvent[] = [];\n\n constructor() { super(); }\n\n clear() {\n this.events = [];\n }\n\n send(event: ITelemetryBaseEvent): void {\n this.events.push(event);\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n // How many expected events were left over? Hopefully none.\n const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n return unmatchedExpectedEventCount === 0;\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEvents(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for any of the given\n * expected events.\n * @param expectedEvents - events that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n * @returns if any of the expected events is found.\n */\n matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n return matchedExpectedEventCount > 0;\n }\n\n /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */\n assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchAnyEvent(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking only for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to be the only events in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n return expectedEvents.length === this.events.length && this.matchEvents(expectedEvents);\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEventStrict(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */\n assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (this.matchAnyEvent(disallowedEvents)) {\n throw new Error(`${message}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n private getMatchedEventsCount(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): number {\n let iExpectedEvent = 0;\n this.events.forEach((event) => {\n if (iExpectedEvent < expectedEvents.length &&\n MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])\n ) {\n // We found the next expected event; increment\n ++iExpectedEvent;\n }\n });\n\n // Remove the events so far; next call will just compare subsequent events from here\n this.events = [];\n\n // Return the count of matched events.\n return iExpectedEvent;\n }\n\n /**\n * Ensure the expected event is a strict subset of the actual event\n */\n private static eventsMatch(actual: ITelemetryBaseEvent, expected: Omit<ITelemetryBaseEvent, \"category\">): boolean {\n const masked = { ...actual, ...expected };\n return JSON.stringify(masked) === JSON.stringify(actual);\n }\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/telemetry-utils";
8
- export declare const pkgVersion = "2.0.0-internal.2.4.0";
8
+ export declare const pkgVersion = "2.0.0-internal.3.0.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/telemetry-utils";
11
- exports.pkgVersion = "2.0.0-internal.2.4.0";
11
+ exports.pkgVersion = "2.0.0-internal.3.0.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,iCAAiC,CAAC;AAC5C,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/telemetry-utils\";\nexport const pkgVersion = \"2.0.0-internal.2.4.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,iCAAiC,CAAC;AAC5C,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/telemetry-utils\";\nexport const pkgVersion = \"2.0.0-internal.3.0.0\";\n"]}
@@ -18,7 +18,7 @@ export declare class MockLogger extends TelemetryLogger implements ITelemetryLog
18
18
  * events in order.
19
19
  * @param expectedEvents - events in order that are expected to appear in the recorded log.
20
20
  * These event objects may be subsets of the logged events.
21
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
21
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
22
22
  */
23
23
  matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
24
24
  /** Asserts that matchEvents is true, and prints the actual/expected output if not */
@@ -28,12 +28,22 @@ export declare class MockLogger extends TelemetryLogger implements ITelemetryLog
28
28
  * expected events.
29
29
  * @param expectedEvents - events that are expected to appear in the recorded log.
30
30
  * These event objects may be subsets of the logged events.
31
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
31
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
32
32
  * @returns if any of the expected events is found.
33
33
  */
34
34
  matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
35
35
  /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */
36
36
  assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
37
+ /**
38
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
39
+ * events in order.
40
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
41
+ * These event objects may be subsets of the logged events.
42
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
43
+ */
44
+ matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
45
+ /** Asserts that matchEvents is true, and prints the actual/expected output if not */
46
+ assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
37
47
  /** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */
38
48
  assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
39
49
  private getMatchedEventsCount;
@@ -1 +1 @@
1
- {"version":3,"file":"mockLogger.d.ts","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAAgB,YAAW,gBAAgB;IACvE,MAAM,EAAE,mBAAmB,EAAE,CAAM;;IAInC,KAAK;IAIL,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAItC;;;;;;OAMG;IACH,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAO7E,qFAAqF;IACrF,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAYrF;;;;;;;OAOG;IACH,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAK/E,uFAAuF;IACvF,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAYxF,6GAA6G;IAC7G,eAAe,CAAC,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAY3F,OAAO,CAAC,qBAAqB;IAkB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;CAI7B"}
1
+ {"version":3,"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,WAAW;CAI7B"}
package/lib/mockLogger.js CHANGED
@@ -23,7 +23,7 @@ export class MockLogger extends TelemetryLogger {
23
23
  * events in order.
24
24
  * @param expectedEvents - events in order that are expected to appear in the recorded log.
25
25
  * These event objects may be subsets of the logged events.
26
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
26
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
27
27
  */
28
28
  matchEvents(expectedEvents) {
29
29
  const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
@@ -48,7 +48,7 @@ ${JSON.stringify(actualEvents)}`);
48
48
  * expected events.
49
49
  * @param expectedEvents - events that are expected to appear in the recorded log.
50
50
  * These event objects may be subsets of the logged events.
51
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
51
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
52
52
  * @returns if any of the expected events is found.
53
53
  */
54
54
  matchAnyEvent(expectedEvents) {
@@ -63,6 +63,28 @@ ${JSON.stringify(actualEvents)}`);
63
63
  expected:
64
64
  ${JSON.stringify(expectedEvents)}
65
65
 
66
+ actual:
67
+ ${JSON.stringify(actualEvents)}`);
68
+ }
69
+ }
70
+ /**
71
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
72
+ * events in order.
73
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
74
+ * These event objects may be subsets of the logged events.
75
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
76
+ */
77
+ matchEventStrict(expectedEvents) {
78
+ return expectedEvents.length === this.events.length && this.matchEvents(expectedEvents);
79
+ }
80
+ /** Asserts that matchEvents is true, and prints the actual/expected output if not */
81
+ assertMatchStrict(expectedEvents, message) {
82
+ const actualEvents = this.events;
83
+ if (!this.matchEventStrict(expectedEvents)) {
84
+ throw new Error(`${message}
85
+ expected:
86
+ ${JSON.stringify(expectedEvents)}
87
+
66
88
  actual:
67
89
  ${JSON.stringify(actualEvents)}`);
68
90
  }
@@ -1 +1 @@
1
- {"version":3,"file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CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { TelemetryLogger } from \"./logger\";\n\n/**\n * The MockLogger records events sent to it, and then can walk back over those events\n * searching for a set of expected events to match against the logged events.\n */\nexport class MockLogger extends TelemetryLogger implements ITelemetryLogger {\n events: ITelemetryBaseEvent[] = [];\n\n constructor() { super(); }\n\n clear() {\n this.events = [];\n }\n\n send(event: ITelemetryBaseEvent): void {\n this.events.push(event);\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n // How many expected events were left over? Hopefully none.\n const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n return unmatchedExpectedEventCount === 0;\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEvents(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for any of the given\n * expected events.\n * @param expectedEvents - events that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.\n * @returns if any of the expected events is found.\n */\n matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n return matchedExpectedEventCount > 0;\n }\n\n /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */\n assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchAnyEvent(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */\n assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (this.matchAnyEvent(disallowedEvents)) {\n throw new Error(`${message}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n private getMatchedEventsCount(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): number {\n let iExpectedEvent = 0;\n this.events.forEach((event) => {\n if (iExpectedEvent < expectedEvents.length &&\n MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])\n ) {\n // We found the next expected event; increment\n ++iExpectedEvent;\n }\n });\n\n // Remove the events so far; next call will just compare subsequent events from here\n this.events = [];\n\n // Return the count of matched events.\n return iExpectedEvent;\n }\n\n /**\n * Ensure the expected event is a strict subset of the actual event\n */\n private static eventsMatch(actual: ITelemetryBaseEvent, expected: Omit<ITelemetryBaseEvent, \"category\">): boolean {\n const masked = { ...actual, ...expected };\n return JSON.stringify(masked) === JSON.stringify(actual);\n }\n}\n"]}
1
+ {"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,eAAe;IAG3C;QAAgB,KAAK,EAAE,CAAC;QAFxB,WAAM,GAA0B,EAAE,CAAC;IAEV,CAAC;IAE1B,KAAK;QACD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACr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C,WAAW,CAAC,MAA2B,EAAE,QAA+C;QACnG,MAAM,MAAM,mCAAQ,MAAM,GAAK,QAAQ,CAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { TelemetryLogger } from \"./logger\";\n\n/**\n * The MockLogger records events sent to it, and then can walk back over those events\n * searching for a set of expected events to match against the logged events.\n */\nexport class MockLogger extends TelemetryLogger implements ITelemetryLogger {\n events: ITelemetryBaseEvent[] = [];\n\n constructor() { super(); }\n\n clear() {\n this.events = [];\n }\n\n send(event: ITelemetryBaseEvent): void {\n this.events.push(event);\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n // How many expected events were left over? Hopefully none.\n const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n return unmatchedExpectedEventCount === 0;\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEvents(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for any of the given\n * expected events.\n * @param expectedEvents - events that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n * @returns if any of the expected events is found.\n */\n matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n return matchedExpectedEventCount > 0;\n }\n\n /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */\n assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchAnyEvent(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking only for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to be the only events in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n return expectedEvents.length === this.events.length && this.matchEvents(expectedEvents);\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEventStrict(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */\n assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (this.matchAnyEvent(disallowedEvents)) {\n throw new Error(`${message}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n private getMatchedEventsCount(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): number {\n let iExpectedEvent = 0;\n this.events.forEach((event) => {\n if (iExpectedEvent < expectedEvents.length &&\n MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])\n ) {\n // We found the next expected event; increment\n ++iExpectedEvent;\n }\n });\n\n // Remove the events so far; next call will just compare subsequent events from here\n this.events = [];\n\n // Return the count of matched events.\n return iExpectedEvent;\n }\n\n /**\n * Ensure the expected event is a strict subset of the actual event\n */\n private static eventsMatch(actual: ITelemetryBaseEvent, expected: Omit<ITelemetryBaseEvent, \"category\">): boolean {\n const masked = { ...actual, ...expected };\n return JSON.stringify(masked) === JSON.stringify(actual);\n }\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/telemetry-utils";
8
- export declare const pkgVersion = "2.0.0-internal.2.4.0";
8
+ export declare const pkgVersion = "2.0.0-internal.3.0.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/telemetry-utils";
8
- export const pkgVersion = "2.0.0-internal.2.4.0";
8
+ export const pkgVersion = "2.0.0-internal.3.0.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,iCAAiC,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/telemetry-utils\";\nexport const pkgVersion = \"2.0.0-internal.2.4.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,iCAAiC,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/telemetry-utils\";\nexport const pkgVersion = \"2.0.0-internal.3.0.0\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/telemetry-utils",
3
- "version": "2.0.0-internal.2.4.0",
3
+ "version": "2.0.0-internal.3.0.0",
4
4
  "description": "Collection of telemetry relates utilities for Fluid",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -79,7 +79,7 @@
79
79
  "@fluidframework/build-common": "^1.1.0",
80
80
  "@fluidframework/build-tools": "^0.8.0",
81
81
  "@fluidframework/eslint-config-fluid": "^2.0.0",
82
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
82
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0",
83
83
  "@fluidframework/telemetry-utils-previous": "npm:@fluidframework/telemetry-utils@2.0.0-internal.2.2.0",
84
84
  "@microsoft/api-extractor": "^7.22.2",
85
85
  "@rushstack/eslint-config": "^2.5.1",
@@ -100,9 +100,13 @@
100
100
  "typescript": "~4.5.5"
101
101
  },
102
102
  "typeValidation": {
103
- "version": "2.0.0-internal.2.3.0",
104
- "baselineRange": ">=2.0.0-internal.2.2.0 <2.0.0-internal.2.3.0",
105
- "baselineVersion": "2.0.0-internal.2.2.0",
106
- "broken": {}
103
+ "version": "2.0.0-internal.3.0.0",
104
+ "baselineRange": ">=2.0.0-internal.2.0.0 <2.0.0-internal.3.0.0",
105
+ "baselineVersion": "2.0.0-internal.2.1.1",
106
+ "broken": {
107
+ "ClassDeclaration_MockLogger": {
108
+ "forwardCompat": false
109
+ }
110
+ }
107
111
  }
108
112
  }
package/src/mockLogger.ts CHANGED
@@ -28,7 +28,7 @@ export class MockLogger extends TelemetryLogger implements ITelemetryLogger {
28
28
  * events in order.
29
29
  * @param expectedEvents - events in order that are expected to appear in the recorded log.
30
30
  * These event objects may be subsets of the logged events.
31
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
31
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
32
32
  */
33
33
  matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean {
34
34
  const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
@@ -55,7 +55,7 @@ ${JSON.stringify(actualEvents)}`);
55
55
  * expected events.
56
56
  * @param expectedEvents - events that are expected to appear in the recorded log.
57
57
  * These event objects may be subsets of the logged events.
58
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
58
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
59
59
  * @returns if any of the expected events is found.
60
60
  */
61
61
  matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean {
@@ -76,6 +76,30 @@ ${JSON.stringify(actualEvents)}`);
76
76
  }
77
77
  }
78
78
 
79
+ /**
80
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
81
+ * events in order.
82
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
83
+ * These event objects may be subsets of the logged events.
84
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
85
+ */
86
+ matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean {
87
+ return expectedEvents.length === this.events.length && this.matchEvents(expectedEvents);
88
+ }
89
+
90
+ /** Asserts that matchEvents is true, and prints the actual/expected output if not */
91
+ assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string) {
92
+ const actualEvents = this.events;
93
+ if (!this.matchEventStrict(expectedEvents)) {
94
+ throw new Error(`${message}
95
+ expected:
96
+ ${JSON.stringify(expectedEvents)}
97
+
98
+ actual:
99
+ ${JSON.stringify(actualEvents)}`);
100
+ }
101
+ }
102
+
79
103
  /** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */
80
104
  assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string) {
81
105
  const actualEvents = this.events;
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/telemetry-utils";
9
- export const pkgVersion = "2.0.0-internal.2.4.0";
9
+ export const pkgVersion = "2.0.0-internal.3.0.0";