@azure/msal-common 10.0.0 → 11.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.
Files changed (103) hide show
  1. package/dist/_virtual/_tslib.js +1 -1
  2. package/dist/account/AuthToken.js +1 -1
  3. package/dist/account/CcsCredential.js +1 -1
  4. package/dist/account/ClientInfo.js +1 -1
  5. package/dist/authority/Authority.js +1 -1
  6. package/dist/authority/AuthorityFactory.js +1 -1
  7. package/dist/authority/AuthorityMetadata.js +1 -1
  8. package/dist/authority/AuthorityOptions.js +1 -1
  9. package/dist/authority/AuthorityType.js +1 -1
  10. package/dist/authority/CloudInstanceDiscoveryErrorResponse.js +1 -1
  11. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  12. package/dist/authority/OpenIdConfigResponse.js +1 -1
  13. package/dist/authority/ProtocolMode.js +1 -1
  14. package/dist/authority/RegionDiscovery.js +1 -1
  15. package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +16 -0
  16. package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -0
  17. package/dist/cache/CacheManager.js +2 -2
  18. package/dist/cache/CacheManager.js.map +1 -1
  19. package/dist/cache/entities/AccessTokenEntity.js +1 -1
  20. package/dist/cache/entities/AccountEntity.js +1 -1
  21. package/dist/cache/entities/AppMetadataEntity.js +1 -1
  22. package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
  23. package/dist/cache/entities/CacheRecord.js +1 -1
  24. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  25. package/dist/cache/entities/CredentialEntity.js +6 -3
  26. package/dist/cache/entities/CredentialEntity.js.map +1 -1
  27. package/dist/cache/entities/IdTokenEntity.js +1 -1
  28. package/dist/cache/entities/RefreshTokenEntity.js +1 -1
  29. package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
  30. package/dist/cache/entities/ThrottlingEntity.js +1 -1
  31. package/dist/cache/persistence/TokenCacheContext.js +1 -1
  32. package/dist/client/AuthorizationCodeClient.js +1 -1
  33. package/dist/client/BaseClient.js +1 -1
  34. package/dist/client/ClientCredentialClient.js +1 -1
  35. package/dist/client/DeviceCodeClient.js +1 -1
  36. package/dist/client/OnBehalfOfClient.js +1 -1
  37. package/dist/client/RefreshTokenClient.js +1 -1
  38. package/dist/client/SilentFlowClient.js +1 -1
  39. package/dist/client/UsernamePasswordClient.js +1 -1
  40. package/dist/config/ClientConfiguration.js +1 -1
  41. package/dist/crypto/ICrypto.js +1 -1
  42. package/dist/crypto/JoseHeader.js +3 -3
  43. package/dist/crypto/JoseHeader.js.map +1 -1
  44. package/dist/crypto/PopTokenGenerator.js +1 -1
  45. package/dist/error/AuthError.js +1 -1
  46. package/dist/error/ClientAuthError.d.ts +16 -0
  47. package/dist/error/ClientAuthError.d.ts.map +1 -1
  48. package/dist/error/ClientAuthError.js +21 -1
  49. package/dist/error/ClientAuthError.js.map +1 -1
  50. package/dist/error/ClientConfigurationError.js +1 -1
  51. package/dist/error/InteractionRequiredAuthError.js +1 -1
  52. package/dist/error/JoseHeaderError.js +1 -1
  53. package/dist/error/ServerError.js +1 -1
  54. package/dist/index.cjs.js +132 -184
  55. package/dist/index.cjs.js.map +1 -1
  56. package/dist/index.d.ts +6 -3
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +1 -1
  59. package/dist/logger/Logger.js +1 -1
  60. package/dist/network/INetworkModule.js +1 -1
  61. package/dist/network/NetworkManager.d.ts +11 -0
  62. package/dist/network/NetworkManager.d.ts.map +1 -1
  63. package/dist/network/NetworkManager.js +1 -1
  64. package/dist/network/NetworkManager.js.map +1 -1
  65. package/dist/network/ThrottlingUtils.js +1 -1
  66. package/dist/packageMetadata.d.ts +1 -1
  67. package/dist/packageMetadata.js +2 -2
  68. package/dist/packageMetadata.js.map +1 -1
  69. package/dist/request/AuthenticationHeaderParser.js +1 -1
  70. package/dist/request/NativeRequest.d.ts +20 -0
  71. package/dist/request/NativeRequest.d.ts.map +1 -0
  72. package/dist/request/NativeSignOutRequest.d.ts +6 -0
  73. package/dist/request/NativeSignOutRequest.d.ts.map +1 -0
  74. package/dist/request/RequestParameterBuilder.js +1 -1
  75. package/dist/request/RequestValidator.js +1 -1
  76. package/dist/request/ScopeSet.js +1 -1
  77. package/dist/response/ResponseHandler.d.ts +1 -1
  78. package/dist/response/ResponseHandler.d.ts.map +1 -1
  79. package/dist/response/ResponseHandler.js +8 -4
  80. package/dist/response/ResponseHandler.js.map +1 -1
  81. package/dist/response/ServerAuthorizationTokenResponse.d.ts +1 -0
  82. package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
  83. package/dist/telemetry/performance/IPerformanceClient.d.ts +5 -3
  84. package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
  85. package/dist/telemetry/performance/PerformanceClient.d.ts +18 -41
  86. package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  87. package/dist/telemetry/performance/PerformanceClient.js +93 -175
  88. package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
  89. package/dist/telemetry/performance/PerformanceEvent.d.ts +28 -5
  90. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  91. package/dist/telemetry/performance/PerformanceEvent.js +3 -1
  92. package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
  93. package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
  94. package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
  95. package/dist/url/UrlString.js +1 -1
  96. package/dist/utils/Constants.d.ts +2 -1
  97. package/dist/utils/Constants.d.ts.map +1 -1
  98. package/dist/utils/Constants.js +2 -1
  99. package/dist/utils/Constants.js.map +1 -1
  100. package/dist/utils/ProtocolUtils.js +1 -1
  101. package/dist/utils/StringUtils.js +1 -1
  102. package/dist/utils/TimeUtils.js +1 -1
  103. package/package.json +1 -1
@@ -3,6 +3,10 @@ import { Logger } from "../../logger/Logger";
3
3
  import { InProgressPerformanceEvent, IPerformanceClient, PerformanceCallbackFunction, QueueMeasurement } from "./IPerformanceClient";
4
4
  import { IPerformanceMeasurement } from "./IPerformanceMeasurement";
5
5
  import { Counters, PerformanceEvent, PerformanceEvents, StaticFields } from "./PerformanceEvent";
6
+ export interface PreQueueEvent {
7
+ name: PerformanceEvents;
8
+ time: number;
9
+ }
6
10
  export declare abstract class PerformanceClient implements IPerformanceClient {
7
11
  protected authority: string;
8
12
  protected libraryName: string;
@@ -13,34 +17,17 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
13
17
  protected callbacks: Map<string, PerformanceCallbackFunction>;
14
18
  /**
15
19
  * Multiple events with the same correlation id.
16
- * Double keyed by correlation id and event id.
17
20
  * @protected
18
- * @type {Map<string, Map<string, PerformanceEvent>>}
19
- */
20
- protected eventsByCorrelationId: Map<string, Map<string, PerformanceEvent>>;
21
- /**
22
- * Fields to be emitted which are scoped to the top level request and whose value will not change in submeasurements
23
- * For example: App name, version, etc.
21
+ * @type {Map<string, PerformanceEvent>}
24
22
  */
25
- protected staticFieldsByCorrelationId: Map<string, StaticFields>;
26
- /**
27
- * Counters to be emitted which are scoped to the top level request and whose value may change in sub-measurements
28
- */
29
- protected countersByCorrelationId: Map<string, Counters>;
30
- /**
31
- * Underlying performance measurements for each operation
32
- *
33
- * @protected
34
- * @type {Map<string, IPerformanceMeasurement>}
35
- */
36
- protected measurementsById: Map<string, IPerformanceMeasurement>;
23
+ protected eventsByCorrelationId: Map<string, PerformanceEvent>;
37
24
  /**
38
25
  * Map of pre-queue times by correlation Id
39
26
  *
40
27
  * @protected
41
- * @type {Map<string, Map<string, number>>}
28
+ * @type {Map<string, PreQueueEvent>}
42
29
  */
43
- protected preQueueTimeByCorrelationId: Map<string, Map<string, number>>;
30
+ protected preQueueTimeByCorrelationId: Map<string, PreQueueEvent>;
44
31
  /**
45
32
  * Map of queue measurements by correlation Id
46
33
  *
@@ -119,12 +106,13 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
119
106
  /**
120
107
  * Adds queue measurement time to QueueMeasurements array for given correlation ID.
121
108
  *
122
- * @param {PerformanceEvents} name
109
+ * @param {PerformanceEvents} eventName
123
110
  * @param {?string} correlationId
124
- * @param {?number} time
111
+ * @param {?number} queueTime
112
+ * @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
125
113
  * @returns
126
114
  */
127
- addQueueMeasurement(eventName: PerformanceEvents, correlationId?: string, queueTime?: number): void;
115
+ addQueueMeasurement(eventName: PerformanceEvents, correlationId?: string, queueTime?: number, manuallyCompleted?: boolean): void;
128
116
  /**
129
117
  * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
130
118
  *
@@ -136,11 +124,14 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
136
124
  /**
137
125
  * Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
138
126
  * as consumers should instead use the function returned by startMeasurement.
127
+ * Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
128
+ * otherwise.
139
129
  *
140
130
  * @param {PerformanceEvent} event
131
+ * @param {IPerformanceMeasurement} measurement
141
132
  * @returns {(PerformanceEvent | null)}
142
133
  */
143
- endMeasurement(event: PerformanceEvent): PerformanceEvent | null;
134
+ endMeasurement(event: PerformanceEvent, measurement?: IPerformanceMeasurement): PerformanceEvent | null;
144
135
  /**
145
136
  * Saves extra information to be emitted when the measurements are flushed
146
137
  * @param fields
@@ -163,21 +154,7 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
163
154
  * @param {PerformanceEvent} event
164
155
  */
165
156
  private cacheEventByCorrelationId;
166
- /**
167
- * Cache measurements by their id.
168
- *
169
- * @private
170
- * @param {PerformanceEvent} event
171
- * @param {IPerformanceMeasurement} measurement
172
- */
173
- private cacheMeasurement;
174
- /**
175
- * Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
176
- *
177
- * @param {PerformanceEvents} measureName
178
- * @param {string} correlationId
179
- */
180
- flushMeasurements(measureName: PerformanceEvents, correlationId: string): void;
157
+ private getQueueInfo;
181
158
  /**
182
159
  * Removes measurements for a given correlation id.
183
160
  *
@@ -187,7 +164,7 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
187
164
  /**
188
165
  * Removes cache for a given correlation id.
189
166
  *
190
- * @param {string} correlation identifier
167
+ * @param {string} correlationId correlation identifier
191
168
  */
192
169
  private discardCache;
193
170
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PerformanceClient.d.ts","sourceRoot":"","sources":["../../../src/telemetry/performance/PerformanceClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrI,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACH,QAAQ,EACR,gBAAgB,EAEhB,iBAAiB,EAEjB,YAAY,EACf,MAAM,oBAAoB,CAAC;AAE5B,8BAAsB,iBAAkB,YAAW,kBAAkB;IACjE,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IACrD,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;IAE9D;;;;;OAKG;IACH,SAAS,CAAC,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE5E;;;OAGG;IACH,SAAS,CAAC,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAEjE;;OAEG;I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H,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAKhD;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAUpB;;;;;OAKG;IACH,sBAAsB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,MAAM;IAQrE;;;;;OAKG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAYtD;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IASnE;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;CAOjC"}
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v10.0.0 2023-02-06 */
1
+ /*! @azure/msal-common v11.0.0 2023-03-07 */
2
2
  'use strict';
3
3
  import { __assign } from '../../_virtual/_tslib.js';
4
4
  import { IntFields, PerformanceEventStatus } from './PerformanceEvent.js';
@@ -28,11 +28,8 @@ var PerformanceClient = /** @class */ (function () {
28
28
  this.logger = logger;
29
29
  this.callbacks = new Map();
30
30
  this.eventsByCorrelationId = new Map();
31
- this.staticFieldsByCorrelationId = new Map();
32
- this.measurementsById = new Map();
33
31
  this.queueMeasurements = new Map();
34
32
  this.preQueueTimeByCorrelationId = new Map();
35
- this.countersByCorrelationId = new Map();
36
33
  }
37
34
  /**
38
35
  * Starts and returns an platform-specific implementation of IPerformanceMeasurement.
@@ -73,16 +70,16 @@ var PerformanceClient = /** @class */ (function () {
73
70
  * @returns {number}
74
71
  */
75
72
  PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
76
- var preQueueTimesByEvents = this.preQueueTimeByCorrelationId.get(correlationId);
77
- if (!preQueueTimesByEvents) {
73
+ var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
74
+ if (!preQueueEvent) {
78
75
  this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
79
76
  return;
80
77
  }
81
- else if (!preQueueTimesByEvents.get(eventName)) {
78
+ else if (preQueueEvent.name !== eventName) {
82
79
  this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
83
80
  return;
84
81
  }
85
- return preQueueTimesByEvents.get(eventName);
82
+ return preQueueEvent.time;
86
83
  };
87
84
  /**
88
85
  * Calculates the difference between current time and time when function was queued.
@@ -110,12 +107,13 @@ var PerformanceClient = /** @class */ (function () {
110
107
  /**
111
108
  * Adds queue measurement time to QueueMeasurements array for given correlation ID.
112
109
  *
113
- * @param {PerformanceEvents} name
110
+ * @param {PerformanceEvents} eventName
114
111
  * @param {?string} correlationId
115
- * @param {?number} time
112
+ * @param {?number} queueTime
113
+ * @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
116
114
  * @returns
117
115
  */
118
- PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
116
+ PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
119
117
  if (!correlationId) {
120
118
  this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
121
119
  return;
@@ -128,7 +126,7 @@ var PerformanceClient = /** @class */ (function () {
128
126
  this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
129
127
  return;
130
128
  }
131
- var queueMeasurement = { eventName: eventName, queueTime: queueTime };
129
+ var queueMeasurement = { eventName: eventName, queueTime: queueTime, manuallyCompleted: manuallyCompleted };
132
130
  // Adds to existing correlation Id if present in queueMeasurements
133
131
  var existingMeasurements = this.queueMeasurements.get(correlationId);
134
132
  if (existingMeasurements) {
@@ -141,6 +139,8 @@ var PerformanceClient = /** @class */ (function () {
141
139
  var measurementArray = [queueMeasurement];
142
140
  this.queueMeasurements.set(correlationId, measurementArray);
143
141
  }
142
+ // Delete processed pre-queue event.
143
+ this.preQueueTimeByCorrelationId.delete(correlationId);
144
144
  };
145
145
  /**
146
146
  * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
@@ -159,17 +159,8 @@ var PerformanceClient = /** @class */ (function () {
159
159
  }
160
160
  // Duplicate code to address spelling error will be removed at the next major version bump.
161
161
  this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
162
- var validMeasurement;
163
- var performanceMeasuremeant = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
164
- if (performanceMeasuremeant.startMeasurement) {
165
- performanceMeasuremeant.startMeasurement();
166
- validMeasurement = performanceMeasuremeant;
167
- }
168
- else {
169
- var performanceMeasurement = this.startPerformanceMeasurement(measureName, eventCorrelationId);
170
- performanceMeasurement.startMeasurement();
171
- validMeasurement = performanceMeasurement;
172
- }
162
+ var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
163
+ performanceMeasurement.startMeasurement();
173
164
  var inProgressEvent = {
174
165
  eventId: this.generateId(),
175
166
  status: PerformanceEventStatus.InProgress,
@@ -180,27 +171,15 @@ var PerformanceClient = /** @class */ (function () {
180
171
  name: measureName,
181
172
  startTimeMs: Date.now(),
182
173
  correlationId: eventCorrelationId,
183
- };
184
- // Store in progress events so they can be discarded if not ended properly
185
- this.cacheEventByCorrelationId(inProgressEvent);
186
- var staticFields = {
187
174
  appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
188
175
  appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
189
176
  };
190
- this.addStaticFields(staticFields, eventCorrelationId);
191
- this.cacheMeasurement(inProgressEvent, validMeasurement);
177
+ // Store in progress events so they can be discarded if not ended properly
178
+ this.cacheEventByCorrelationId(inProgressEvent);
192
179
  // Return the event and functions the caller can use to properly end/flush the measurement
193
180
  return {
194
181
  endMeasurement: function (event) {
195
- var completedEvent = _this.endMeasurement(__assign(__assign({}, inProgressEvent), event));
196
- if (completedEvent) {
197
- // Cache event so that submeasurements can be added downstream
198
- _this.cacheEventByCorrelationId(completedEvent);
199
- }
200
- return completedEvent;
201
- },
202
- flushMeasurement: function () {
203
- return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
182
+ return _this.endMeasurement(__assign(__assign({}, inProgressEvent), event), performanceMeasurement);
204
183
  },
205
184
  discardMeasurement: function () {
206
185
  return _this.discardMeasurements(inProgressEvent.correlationId);
@@ -211,40 +190,66 @@ var PerformanceClient = /** @class */ (function () {
211
190
  increment: function (counters) {
212
191
  return _this.increment(counters, inProgressEvent.correlationId);
213
192
  },
214
- measurement: validMeasurement,
193
+ measurement: performanceMeasurement,
215
194
  event: inProgressEvent
216
195
  };
217
196
  };
218
197
  /**
219
198
  * Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
220
199
  * as consumers should instead use the function returned by startMeasurement.
200
+ * Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
201
+ * otherwise.
221
202
  *
222
203
  * @param {PerformanceEvent} event
204
+ * @param {IPerformanceMeasurement} measurement
223
205
  * @returns {(PerformanceEvent | null)}
224
206
  */
225
- PerformanceClient.prototype.endMeasurement = function (event) {
226
- var performanceMeasurement = this.measurementsById.get(event.eventId);
227
- if (performanceMeasurement) {
228
- // Immediately delete so that the same event isnt ended twice
229
- this.measurementsById.delete(event.eventId);
230
- performanceMeasurement.endMeasurement();
231
- var durationMs = performanceMeasurement.flushMeasurement();
232
- // null indicates no measurement was taken (e.g. needed performance APIs not present)
233
- if (durationMs !== null) {
234
- this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
235
- var completedEvent = __assign(__assign({
236
- // Allow duration to be overwritten when event ends (e.g. testing), but not status
237
- durationMs: Math.round(durationMs) }, event), { status: PerformanceEventStatus.Completed });
238
- return completedEvent;
239
- }
240
- else {
241
- this.logger.trace("PerformanceClient: Performance measurement not taken", event.correlationId);
242
- }
207
+ PerformanceClient.prototype.endMeasurement = function (event, measurement) {
208
+ var _this = this;
209
+ var _a, _b;
210
+ var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
211
+ if (!rootEvent) {
212
+ this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
213
+ return null;
214
+ }
215
+ var isRoot = event.eventId === rootEvent.eventId;
216
+ var queueInfo = {
217
+ totalQueueTime: 0,
218
+ totalQueueCount: 0,
219
+ manuallyCompletedCount: 0
220
+ };
221
+ if (isRoot) {
222
+ queueInfo = this.getQueueInfo(event.correlationId);
223
+ this.discardCache(rootEvent.correlationId);
243
224
  }
244
225
  else {
245
- this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
226
+ (_a = rootEvent.incompleteSubMeasurements) === null || _a === void 0 ? void 0 : _a.delete(event.eventId);
227
+ }
228
+ measurement === null || measurement === void 0 ? void 0 : measurement.endMeasurement();
229
+ var durationMs = measurement === null || measurement === void 0 ? void 0 : measurement.flushMeasurement();
230
+ // null indicates no measurement was taken (e.g. needed performance APIs not present)
231
+ if (!durationMs) {
232
+ this.logger.trace("PerformanceClient: Performance measurement not taken", rootEvent.correlationId);
233
+ return null;
234
+ }
235
+ this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
236
+ // Add sub-measurement attribute to root event.
237
+ if (!isRoot) {
238
+ rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
239
+ return __assign({}, rootEvent);
246
240
  }
247
- return null;
241
+ var finalEvent = __assign(__assign({}, rootEvent), event);
242
+ var incompleteSubsCount = 0;
243
+ // Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
244
+ (_b = finalEvent.incompleteSubMeasurements) === null || _b === void 0 ? void 0 : _b.forEach(function (subMeasurement) {
245
+ _this.logger.trace("PerformanceClient: Incomplete submeasurement " + subMeasurement.name + " found for " + event.name, finalEvent.correlationId);
246
+ incompleteSubsCount++;
247
+ });
248
+ finalEvent.incompleteSubMeasurements = undefined;
249
+ finalEvent = __assign(__assign({}, finalEvent), { durationMs: Math.round(durationMs), queuedTimeMs: queueInfo.totalQueueTime, queuedCount: queueInfo.totalQueueCount, queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount, status: PerformanceEventStatus.Completed, incompleteSubsCount: incompleteSubsCount });
250
+ this.truncateIntegralFields(finalEvent, this.getIntFields());
251
+ this.emitEvents([finalEvent], event.correlationId);
252
+ return finalEvent;
248
253
  };
249
254
  /**
250
255
  * Saves extra information to be emitted when the measurements are flushed
@@ -252,14 +257,13 @@ var PerformanceClient = /** @class */ (function () {
252
257
  * @param correlationId
253
258
  */
254
259
  PerformanceClient.prototype.addStaticFields = function (fields, correlationId) {
255
- var existingStaticFields = this.staticFieldsByCorrelationId.get(correlationId);
256
- if (existingStaticFields) {
257
- this.logger.trace("PerformanceClient: Updating static fields");
258
- this.staticFieldsByCorrelationId.set(correlationId, __assign(__assign({}, existingStaticFields), fields));
260
+ this.logger.trace("PerformanceClient: Updating static fields");
261
+ var event = this.eventsByCorrelationId.get(correlationId);
262
+ if (event) {
263
+ this.eventsByCorrelationId.set(correlationId, __assign(__assign({}, event), fields));
259
264
  }
260
265
  else {
261
- this.logger.trace("PerformanceClient: Adding static fields");
262
- this.staticFieldsByCorrelationId.set(correlationId, fields);
266
+ this.logger.trace("PerformanceClient: Event not found for", correlationId);
263
267
  }
264
268
  };
265
269
  /**
@@ -268,18 +272,18 @@ var PerformanceClient = /** @class */ (function () {
268
272
  * @param correlationId {string} correlation identifier
269
273
  */
270
274
  PerformanceClient.prototype.increment = function (counters, correlationId) {
271
- var existing = this.countersByCorrelationId.get(correlationId);
272
- if (!existing) {
273
- this.logger.trace("PerformanceClient: Setting counters");
274
- this.countersByCorrelationId.set(correlationId, __assign({}, counters));
275
- return;
276
- }
277
275
  this.logger.trace("PerformanceClient: Updating counters");
278
- for (var counter in counters) {
279
- if (!existing.hasOwnProperty(counter)) {
280
- existing[counter] = 0;
276
+ var event = this.eventsByCorrelationId.get(correlationId);
277
+ if (event) {
278
+ for (var counter in counters) {
279
+ if (!event.hasOwnProperty(counter)) {
280
+ event[counter] = 0;
281
+ }
282
+ event[counter] += counters[counter];
281
283
  }
282
- existing[counter] += counters[counter];
284
+ }
285
+ else {
286
+ this.logger.trace("PerformanceClient: Event not found for", correlationId);
283
287
  }
284
288
  };
285
289
  /**
@@ -292,117 +296,35 @@ var PerformanceClient = /** @class */ (function () {
292
296
  * @param {PerformanceEvent} event
293
297
  */
294
298
  PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
295
- var existingEvents = this.eventsByCorrelationId.get(event.correlationId);
296
- if (existingEvents) {
299
+ var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
300
+ if (rootEvent) {
297
301
  this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
298
- existingEvents.set(event.eventId, event);
302
+ rootEvent.incompleteSubMeasurements = rootEvent.incompleteSubMeasurements || new Map();
303
+ rootEvent.incompleteSubMeasurements.set(event.eventId, { name: event.name, startTimeMs: event.startTimeMs });
299
304
  }
300
305
  else {
301
306
  this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
302
- this.eventsByCorrelationId.set(event.correlationId, new Map().set(event.eventId, event));
307
+ this.eventsByCorrelationId.set(event.correlationId, __assign({}, event));
303
308
  }
304
309
  };
305
- /**
306
- * Cache measurements by their id.
307
- *
308
- * @private
309
- * @param {PerformanceEvent} event
310
- * @param {IPerformanceMeasurement} measurement
311
- */
312
- PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
313
- this.measurementsById.set(event.eventId, measurement);
314
- };
315
- /**
316
- * Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
317
- *
318
- * @param {PerformanceEvents} measureName
319
- * @param {string} correlationId
320
- */
321
- PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
322
- var _this = this;
323
- this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
324
- /**
325
- * Adds all queue time and count measurements for given correlation ID
326
- * then deletes queue times for given correlation ID from queueMeasurements map.
327
- */
310
+ PerformanceClient.prototype.getQueueInfo = function (correlationId) {
328
311
  var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
329
312
  if (!queueMeasurementForCorrelationId) {
330
313
  this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
331
314
  }
332
315
  var totalQueueTime = 0;
333
316
  var totalQueueCount = 0;
317
+ var manuallyCompletedCount = 0;
334
318
  queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
335
319
  totalQueueTime += measurement.queueTime;
336
320
  totalQueueCount++;
321
+ manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
337
322
  });
338
- var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
339
- var staticFields = this.staticFieldsByCorrelationId.get(correlationId);
340
- var counters = this.countersByCorrelationId.get(correlationId);
341
- if (eventsForCorrelationId) {
342
- this.discardCache(correlationId);
343
- /*
344
- * Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
345
- * Incomplete submeasurements are likely an instrumentation bug that should be fixed.
346
- * IE only supports Map.forEach.
347
- */
348
- var completedEvents_1 = [];
349
- var incompleteSubsCount_1 = 0;
350
- eventsForCorrelationId.forEach(function (event) {
351
- if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
352
- _this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
353
- incompleteSubsCount_1++;
354
- var completedEvent = _this.endMeasurement(event);
355
- if (completedEvent) {
356
- completedEvents_1.push(completedEvent);
357
- }
358
- }
359
- completedEvents_1.push(event);
360
- });
361
- // Sort events by start time (earliest first)
362
- var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
363
- // Take completed top level event and add completed submeasurements durations as properties
364
- var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
365
- if (topLevelEvents.length > 0) {
366
- /*
367
- * Only take the first top-level event if there are multiple events with the same correlation id.
368
- * This greatly simplifies logic for submeasurements.
369
- */
370
- if (topLevelEvents.length > 1) {
371
- this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
372
- }
373
- var topLevelEvent = topLevelEvents[0];
374
- this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
375
- // Build event object with top level and sub measurements
376
- var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
377
- if (current.name !== measureName) {
378
- _this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
379
- // TODO: Emit additional properties for each subMeasurement
380
- var subMeasurementName = current.name + "DurationMs";
381
- /*
382
- * Some code paths, such as resolving an authority, can occur multiple times.
383
- * Only take the first measurement, since the second could be read from the cache,
384
- * or due to the same correlation id being used for two distinct requests.
385
- */
386
- if (!previous[subMeasurementName]) {
387
- previous[subMeasurementName] = current.durationMs;
388
- }
389
- else {
390
- _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
391
- }
392
- }
393
- return previous;
394
- }, topLevelEvent);
395
- var finalEvent = __assign(__assign(__assign(__assign({}, eventToEmit), staticFields), counters), { queuedTimeMs: totalQueueTime, queuedCount: totalQueueCount, incompleteSubsCount: incompleteSubsCount_1 });
396
- this.truncateIntegralFields(finalEvent, this.getIntFields());
397
- this.emitEvents([finalEvent], eventToEmit.correlationId);
398
- }
399
- else {
400
- this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
401
- }
402
- }
403
- else {
404
- this.logger.verbose("PerformanceClient: No measurements found", correlationId);
405
- }
323
+ return {
324
+ totalQueueTime: totalQueueTime,
325
+ totalQueueCount: totalQueueCount,
326
+ manuallyCompletedCount: manuallyCompletedCount
327
+ };
406
328
  };
407
329
  /**
408
330
  * Removes measurements for a given correlation id.
@@ -416,14 +338,10 @@ var PerformanceClient = /** @class */ (function () {
416
338
  /**
417
339
  * Removes cache for a given correlation id.
418
340
  *
419
- * @param {string} correlation identifier
341
+ * @param {string} correlationId correlation identifier
420
342
  */
421
343
  PerformanceClient.prototype.discardCache = function (correlationId) {
422
344
  this.discardMeasurements(correlationId);
423
- this.logger.trace("PerformanceClient: Static fields discarded", correlationId);
424
- this.staticFieldsByCorrelationId.delete(correlationId);
425
- this.logger.trace("PerformanceClient: Counters discarded", correlationId);
426
- this.countersByCorrelationId.delete(correlationId);
427
345
  this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
428
346
  this.queueMeasurements.delete(correlationId);
429
347
  this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);