@fluidframework/telemetry-utils 0.47.0-36699 → 0.48.0-38142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mockLogger.d.ts +38 -0
- package/dist/mockLogger.d.ts.map +1 -0
- package/dist/mockLogger.js +69 -0
- package/dist/mockLogger.js.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/mockLogger.d.ts +38 -0
- package/lib/mockLogger.d.ts.map +1 -0
- package/lib/mockLogger.js +65 -0
- package/lib/mockLogger.js.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/mockLogger.ts +74 -0
- package/src/packageVersion.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./eventEmitterWithErrorHandling";
|
|
|
8
8
|
export * from "./events";
|
|
9
9
|
export * from "./fluidErrorBase";
|
|
10
10
|
export * from "./logger";
|
|
11
|
+
export * from "./mockLogger";
|
|
11
12
|
export * from "./thresholdCounter";
|
|
12
13
|
export * from "./utils";
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./eventEmitterWithErrorHandling"), exports);
|
|
|
20
20
|
__exportStar(require("./events"), exports);
|
|
21
21
|
__exportStar(require("./fluidErrorBase"), exports);
|
|
22
22
|
__exportStar(require("./logger"), exports);
|
|
23
|
+
__exportStar(require("./mockLogger"), exports);
|
|
23
24
|
__exportStar(require("./thresholdCounter"), exports);
|
|
24
25
|
__exportStar(require("./utils"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;GAGG;AACH,gDAA8B;AAC9B,iDAA+B;AAC/B,kEAAgD;AAChD,2CAAyB;AACzB,mDAAiC;AACjC,2CAAyB;AACzB,qDAAmC;AACnC,0CAAwB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport * from \"./debugLogger\";\nexport * from \"./errorLogging\";\nexport * from \"./eventEmitterWithErrorHandling\";\nexport * from \"./events\";\nexport * from \"./fluidErrorBase\";\nexport * from \"./logger\";\nexport * from \"./thresholdCounter\";\nexport * from \"./utils\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;GAGG;AACH,gDAA8B;AAC9B,iDAA+B;AAC/B,kEAAgD;AAChD,2CAAyB;AACzB,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAC7B,qDAAmC;AACnC,0CAAwB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport * from \"./debugLogger\";\nexport * from \"./errorLogging\";\nexport * from \"./eventEmitterWithErrorHandling\";\nexport * from \"./events\";\nexport * from \"./fluidErrorBase\";\nexport * from \"./logger\";\nexport * from \"./mockLogger\";\nexport * from \"./thresholdCounter\";\nexport * from \"./utils\";\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryLogger, ITelemetryBaseEvent } from "@fluidframework/common-definitions";
|
|
6
|
+
import { TelemetryLogger } from "./logger";
|
|
7
|
+
/**
|
|
8
|
+
* The MockLogger records events sent to it, and then can walk back over those events
|
|
9
|
+
* searching for a set of expected events to match against the logged events.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MockLogger extends TelemetryLogger implements ITelemetryLogger {
|
|
12
|
+
events: ITelemetryBaseEvent[];
|
|
13
|
+
constructor();
|
|
14
|
+
send(event: ITelemetryBaseEvent): void;
|
|
15
|
+
/**
|
|
16
|
+
* Search events logged since the last time matchEvents was called, looking for the given expected
|
|
17
|
+
* events in order.
|
|
18
|
+
* @param expectedEvents - events in order that are expected to appear in the recorded log.
|
|
19
|
+
* These event objects may be subsets of the logged events.
|
|
20
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
21
|
+
*/
|
|
22
|
+
matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Search events logged since the last time matchEvents was called, looking for any of the given
|
|
25
|
+
* expected events.
|
|
26
|
+
* @param expectedEvents - events that are expected to appear in the recorded log.
|
|
27
|
+
* These event objects may be subsets of the logged events.
|
|
28
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
29
|
+
* @returns if any of the expected events is found.
|
|
30
|
+
*/
|
|
31
|
+
matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
|
|
32
|
+
private getMatchedEventsCount;
|
|
33
|
+
/**
|
|
34
|
+
* Ensure the expected event is a strict subset of the actual event
|
|
35
|
+
*/
|
|
36
|
+
private static eventsMatch;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=mockLogger.d.ts.map
|
|
@@ -0,0 +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,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAItC;;;;;;OAMG;IACH,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAO7E;;;;;;;OAOG;IACH,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAK/E,OAAO,CAAC,qBAAqB;IAkB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;CAI7B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MockLogger = void 0;
|
|
8
|
+
const logger_1 = require("./logger");
|
|
9
|
+
/**
|
|
10
|
+
* The MockLogger records events sent to it, and then can walk back over those events
|
|
11
|
+
* searching for a set of expected events to match against the logged events.
|
|
12
|
+
*/
|
|
13
|
+
class MockLogger extends logger_1.TelemetryLogger {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.events = [];
|
|
17
|
+
}
|
|
18
|
+
send(event) {
|
|
19
|
+
this.events.push(event);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Search events logged since the last time matchEvents was called, looking for the given expected
|
|
23
|
+
* events in order.
|
|
24
|
+
* @param expectedEvents - events in order that are expected to appear in the recorded log.
|
|
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.
|
|
27
|
+
*/
|
|
28
|
+
matchEvents(expectedEvents) {
|
|
29
|
+
const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
|
|
30
|
+
// How many expected events were left over? Hopefully none.
|
|
31
|
+
const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;
|
|
32
|
+
return unmatchedExpectedEventCount === 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Search events logged since the last time matchEvents was called, looking for any of the given
|
|
36
|
+
* expected events.
|
|
37
|
+
* @param expectedEvents - events that are expected to appear in the recorded log.
|
|
38
|
+
* These event objects may be subsets of the logged events.
|
|
39
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
40
|
+
* @returns if any of the expected events is found.
|
|
41
|
+
*/
|
|
42
|
+
matchAnyEvent(expectedEvents) {
|
|
43
|
+
const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
|
|
44
|
+
return matchedExpectedEventCount > 0;
|
|
45
|
+
}
|
|
46
|
+
getMatchedEventsCount(expectedEvents) {
|
|
47
|
+
let iExpectedEvent = 0;
|
|
48
|
+
this.events.forEach((event) => {
|
|
49
|
+
if (iExpectedEvent < expectedEvents.length &&
|
|
50
|
+
MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])) {
|
|
51
|
+
// We found the next expected event; increment
|
|
52
|
+
++iExpectedEvent;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Remove the events so far; next call will just compare subsequent events from here
|
|
56
|
+
this.events = [];
|
|
57
|
+
// Return the count of matched events.
|
|
58
|
+
return iExpectedEvent;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Ensure the expected event is a strict subset of the actual event
|
|
62
|
+
*/
|
|
63
|
+
static eventsMatch(actual, expected) {
|
|
64
|
+
const masked = Object.assign(Object.assign({}, actual), expected);
|
|
65
|
+
return JSON.stringify(masked) === JSON.stringify(actual);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.MockLogger = MockLogger;
|
|
69
|
+
//# sourceMappingURL=mockLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAI,CAAC,KAA0B;QAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,cAAuD;QAC/D,MAAM,yBAAyB,GAAG,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAC7E,2DAA2D;QAC3D,MAAM,2BAA2B,GAAG,cAAc,CAAC,MAAM,GAAG,yBAAyB,CAAC;QACtF,OAAO,2BAA2B,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,cAAuD;QACjE,MAAM,yBAAyB,GAAG,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAC7E,OAAO,yBAAyB,GAAG,CAAC,CAAC;IACzC,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;AA7DD,gCA6DC","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 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 /**\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 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"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -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 = "0.
|
|
8
|
+
export declare const pkgVersion = "0.48.0-38142";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -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 = "0.
|
|
11
|
+
exports.pkgVersion = "0.48.0-38142";
|
|
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,cAAc,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 = \"0.
|
|
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,cAAc,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 = \"0.48.0-38142\";\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./eventEmitterWithErrorHandling";
|
|
|
8
8
|
export * from "./events";
|
|
9
9
|
export * from "./fluidErrorBase";
|
|
10
10
|
export * from "./logger";
|
|
11
|
+
export * from "./mockLogger";
|
|
11
12
|
export * from "./thresholdCounter";
|
|
12
13
|
export * from "./utils";
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./eventEmitterWithErrorHandling";
|
|
|
8
8
|
export * from "./events";
|
|
9
9
|
export * from "./fluidErrorBase";
|
|
10
10
|
export * from "./logger";
|
|
11
|
+
export * from "./mockLogger";
|
|
11
12
|
export * from "./thresholdCounter";
|
|
12
13
|
export * from "./utils";
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport * from \"./debugLogger\";\nexport * from \"./errorLogging\";\nexport * from \"./eventEmitterWithErrorHandling\";\nexport * from \"./events\";\nexport * from \"./fluidErrorBase\";\nexport * from \"./logger\";\nexport * from \"./thresholdCounter\";\nexport * from \"./utils\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport * from \"./debugLogger\";\nexport * from \"./errorLogging\";\nexport * from \"./eventEmitterWithErrorHandling\";\nexport * from \"./events\";\nexport * from \"./fluidErrorBase\";\nexport * from \"./logger\";\nexport * from \"./mockLogger\";\nexport * from \"./thresholdCounter\";\nexport * from \"./utils\";\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryLogger, ITelemetryBaseEvent } from "@fluidframework/common-definitions";
|
|
6
|
+
import { TelemetryLogger } from "./logger";
|
|
7
|
+
/**
|
|
8
|
+
* The MockLogger records events sent to it, and then can walk back over those events
|
|
9
|
+
* searching for a set of expected events to match against the logged events.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MockLogger extends TelemetryLogger implements ITelemetryLogger {
|
|
12
|
+
events: ITelemetryBaseEvent[];
|
|
13
|
+
constructor();
|
|
14
|
+
send(event: ITelemetryBaseEvent): void;
|
|
15
|
+
/**
|
|
16
|
+
* Search events logged since the last time matchEvents was called, looking for the given expected
|
|
17
|
+
* events in order.
|
|
18
|
+
* @param expectedEvents - events in order that are expected to appear in the recorded log.
|
|
19
|
+
* These event objects may be subsets of the logged events.
|
|
20
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
21
|
+
*/
|
|
22
|
+
matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Search events logged since the last time matchEvents was called, looking for any of the given
|
|
25
|
+
* expected events.
|
|
26
|
+
* @param expectedEvents - events that are expected to appear in the recorded log.
|
|
27
|
+
* These event objects may be subsets of the logged events.
|
|
28
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
29
|
+
* @returns if any of the expected events is found.
|
|
30
|
+
*/
|
|
31
|
+
matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
|
|
32
|
+
private getMatchedEventsCount;
|
|
33
|
+
/**
|
|
34
|
+
* Ensure the expected event is a strict subset of the actual event
|
|
35
|
+
*/
|
|
36
|
+
private static eventsMatch;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=mockLogger.d.ts.map
|
|
@@ -0,0 +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,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAItC;;;;;;OAMG;IACH,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAO7E;;;;;;;OAOG;IACH,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAK/E,OAAO,CAAC,qBAAqB;IAkB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;CAI7B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { TelemetryLogger } from "./logger";
|
|
6
|
+
/**
|
|
7
|
+
* The MockLogger records events sent to it, and then can walk back over those events
|
|
8
|
+
* searching for a set of expected events to match against the logged events.
|
|
9
|
+
*/
|
|
10
|
+
export class MockLogger extends TelemetryLogger {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.events = [];
|
|
14
|
+
}
|
|
15
|
+
send(event) {
|
|
16
|
+
this.events.push(event);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Search events logged since the last time matchEvents was called, looking for the given expected
|
|
20
|
+
* events in order.
|
|
21
|
+
* @param expectedEvents - events in order that are expected to appear in the recorded log.
|
|
22
|
+
* These event objects may be subsets of the logged events.
|
|
23
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
24
|
+
*/
|
|
25
|
+
matchEvents(expectedEvents) {
|
|
26
|
+
const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
|
|
27
|
+
// How many expected events were left over? Hopefully none.
|
|
28
|
+
const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;
|
|
29
|
+
return unmatchedExpectedEventCount === 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Search events logged since the last time matchEvents was called, looking for any of the given
|
|
33
|
+
* expected events.
|
|
34
|
+
* @param expectedEvents - events that are expected to appear in the recorded log.
|
|
35
|
+
* These event objects may be subsets of the logged events.
|
|
36
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
37
|
+
* @returns if any of the expected events is found.
|
|
38
|
+
*/
|
|
39
|
+
matchAnyEvent(expectedEvents) {
|
|
40
|
+
const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
|
|
41
|
+
return matchedExpectedEventCount > 0;
|
|
42
|
+
}
|
|
43
|
+
getMatchedEventsCount(expectedEvents) {
|
|
44
|
+
let iExpectedEvent = 0;
|
|
45
|
+
this.events.forEach((event) => {
|
|
46
|
+
if (iExpectedEvent < expectedEvents.length &&
|
|
47
|
+
MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])) {
|
|
48
|
+
// We found the next expected event; increment
|
|
49
|
+
++iExpectedEvent;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
// Remove the events so far; next call will just compare subsequent events from here
|
|
53
|
+
this.events = [];
|
|
54
|
+
// Return the count of matched events.
|
|
55
|
+
return iExpectedEvent;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Ensure the expected event is a strict subset of the actual event
|
|
59
|
+
*/
|
|
60
|
+
static eventsMatch(actual, expected) {
|
|
61
|
+
const masked = Object.assign(Object.assign({}, actual), expected);
|
|
62
|
+
return JSON.stringify(masked) === JSON.stringify(actual);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=mockLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAI,CAAC,KAA0B;QAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,cAAuD;QAC/D,MAAM,yBAAyB,GAAG,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAC7E,2DAA2D;QAC3D,MAAM,2BAA2B,GAAG,cAAc,CAAC,MAAM,GAAG,yBAAyB,CAAC;QACtF,OAAO,2BAA2B,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,cAAuD;QACjE,MAAM,yBAAyB,GAAG,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAC7E,OAAO,yBAAyB,GAAG,CAAC,CAAC;IACzC,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","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 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 /**\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 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"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -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 = "0.
|
|
8
|
+
export declare const pkgVersion = "0.48.0-38142";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -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,cAAc,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 = \"0.
|
|
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,cAAc,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 = \"0.48.0-38142\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/telemetry-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0-38142",
|
|
4
4
|
"description": "Collection of telemetry relates utilities for Fluid",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": "https://github.com/microsoft/FluidFramework",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@fluidframework/build-common": "^0.23.0-0",
|
|
70
70
|
"@fluidframework/eslint-config-fluid": "^0.23.0",
|
|
71
|
-
"@fluidframework/mocha-test-setup": "0.
|
|
71
|
+
"@fluidframework/mocha-test-setup": "0.48.0-38142",
|
|
72
72
|
"@microsoft/api-extractor": "^7.16.1",
|
|
73
73
|
"@types/debug": "^4.1.5",
|
|
74
74
|
"@types/events": "^3.0.0",
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ITelemetryLogger, ITelemetryBaseEvent } from "@fluidframework/common-definitions";
|
|
7
|
+
import { TelemetryLogger } from "./logger";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The MockLogger records events sent to it, and then can walk back over those events
|
|
11
|
+
* searching for a set of expected events to match against the logged events.
|
|
12
|
+
*/
|
|
13
|
+
export class MockLogger extends TelemetryLogger implements ITelemetryLogger {
|
|
14
|
+
events: ITelemetryBaseEvent[] = [];
|
|
15
|
+
|
|
16
|
+
constructor() { super(); }
|
|
17
|
+
|
|
18
|
+
send(event: ITelemetryBaseEvent): void {
|
|
19
|
+
this.events.push(event);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Search events logged since the last time matchEvents was called, looking for the given expected
|
|
24
|
+
* events in order.
|
|
25
|
+
* @param expectedEvents - events in order that are expected to appear in the recorded log.
|
|
26
|
+
* These event objects may be subsets of the logged events.
|
|
27
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
28
|
+
*/
|
|
29
|
+
matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean {
|
|
30
|
+
const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
|
|
31
|
+
// How many expected events were left over? Hopefully none.
|
|
32
|
+
const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;
|
|
33
|
+
return unmatchedExpectedEventCount === 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Search events logged since the last time matchEvents was called, looking for any of the given
|
|
38
|
+
* expected events.
|
|
39
|
+
* @param expectedEvents - events that are expected to appear in the recorded log.
|
|
40
|
+
* These event objects may be subsets of the logged events.
|
|
41
|
+
* Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
|
|
42
|
+
* @returns if any of the expected events is found.
|
|
43
|
+
*/
|
|
44
|
+
matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean {
|
|
45
|
+
const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
|
|
46
|
+
return matchedExpectedEventCount > 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private getMatchedEventsCount(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): number {
|
|
50
|
+
let iExpectedEvent = 0;
|
|
51
|
+
this.events.forEach((event) => {
|
|
52
|
+
if (iExpectedEvent < expectedEvents.length &&
|
|
53
|
+
MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])
|
|
54
|
+
) {
|
|
55
|
+
// We found the next expected event; increment
|
|
56
|
+
++iExpectedEvent;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Remove the events so far; next call will just compare subsequent events from here
|
|
61
|
+
this.events = [];
|
|
62
|
+
|
|
63
|
+
// Return the count of matched events.
|
|
64
|
+
return iExpectedEvent;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Ensure the expected event is a strict subset of the actual event
|
|
69
|
+
*/
|
|
70
|
+
private static eventsMatch(actual: ITelemetryBaseEvent, expected: Omit<ITelemetryBaseEvent, "category">): boolean {
|
|
71
|
+
const masked = { ...actual, ...expected };
|
|
72
|
+
return JSON.stringify(masked) === JSON.stringify(actual);
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/packageVersion.ts
CHANGED