Skip to content

Commit

Permalink
fix formatting from latest pull
Browse files Browse the repository at this point in the history
  • Loading branch information
tnorling committed Jul 28, 2023
1 parent 686e6f0 commit 201f4e2
Show file tree
Hide file tree
Showing 12 changed files with 341 additions and 322 deletions.
4 changes: 2 additions & 2 deletions lib/msal-browser/src/config/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ export function buildConfiguration(
version,
{
appName: Constants.EMPTY_STRING,
appVersion: Constants.EMPTY_STRING
appVersion: Constants.EMPTY_STRING,
}
)
),
};

// Throw an error if user has set OIDCOptions without being in OIDC protocol mode
Expand Down
15 changes: 10 additions & 5 deletions lib/msal-browser/src/telemetry/BrowserPerformanceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@ export class BrowserPerformanceClient
super(
configuration.auth.clientId,
configuration.auth.authority || `${Constants.DEFAULT_AUTHORITY}`,
logger || new Logger(
configuration.system?.loggerOptions || {},
libName,
libVersion),
logger ||
new Logger(
configuration.system?.loggerOptions || {},
libName,
libVersion
),
libName,
libVersion,
configuration.telemetry?.application || { appName: '', appVersion: '' },
configuration.telemetry?.application || {
appName: "",
appVersion: "",
},
intFields
);
this.browserCrypto = new BrowserCrypto(this.logger);
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-browser/test/app/PublicClientApplication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ describe("PublicClientApplication.ts Class Unit Tests", () => {
},
telemetry: {
client: new BrowserPerformanceClient(testAppConfig),
}
},
});

const callbackId = pca.addPerformanceCallback((events) => {
Expand Down
12 changes: 3 additions & 9 deletions lib/msal-browser/test/telemetry/BrowserPerformanceClient.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
PerformanceEvents,
} from "@azure/msal-common";
import { PerformanceEvents } from "@azure/msal-common";
import { BrowserPerformanceClient } from "../../src/telemetry/BrowserPerformanceClient";
import { TEST_CONFIG } from "../utils/StringConstants";

Expand Down Expand Up @@ -31,9 +29,7 @@ describe("BrowserPerformanceClient.ts", () => {
});

it("sets pre-queue time", () => {
const browserPerfClient = new BrowserPerformanceClient(
testAppConfig
);
const browserPerfClient = new BrowserPerformanceClient(testAppConfig);
const eventName = PerformanceEvents.AcquireTokenSilent;
const correlationId = "test-correlation-id";
const perfTimeNow = 1234567890;
Expand Down Expand Up @@ -100,9 +96,7 @@ describe("BrowserPerformanceClient.ts", () => {
});

it("supportsBrowserPerformanceNow returns false if window.performance not present", () => {
const browserPerfClient = new BrowserPerformanceClient(
testAppConfig
);
const browserPerfClient = new BrowserPerformanceClient(testAppConfig);

// @ts-ignore
jest.spyOn(window, "performance", "get").mockReturnValue(undefined);
Expand Down
16 changes: 6 additions & 10 deletions lib/msal-browser/test/utils/TelemetryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Licensed under the MIT License.
*/

import {
IPerformanceClient,
} from "@azure/msal-common";
import { IPerformanceClient } from "@azure/msal-common";
import { BrowserPerformanceClient } from "../../src/telemetry/BrowserPerformanceClient";
import { TEST_CONFIG } from "./StringConstants";

export function getDefaultPerformanceClient(): IPerformanceClient {
return new BrowserPerformanceClient(
{
auth: {
clientId: TEST_CONFIG.MSAL_CLIENT_ID,
},
}
);
return new BrowserPerformanceClient({
auth: {
clientId: TEST_CONFIG.MSAL_CLIENT_ID,
},
});
}
1 change: 0 additions & 1 deletion lib/msal-common/src/client/AuthorizationCodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export class AuthorizationCodeClient extends BaseClient {
async getAuthCodeUrl(
request: CommonAuthorizationUrlRequest
): Promise<string> {

this.performanceClient?.addQueueMeasurement(
PerformanceEvents.GetAuthCodeUrl,
request.correlationId
Expand Down
23 changes: 12 additions & 11 deletions lib/msal-common/src/telemetry/performance/IPerformanceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
* Licensed under the MIT License.
*/

import {
PerformanceEvent,
PerformanceEvents
} from "./PerformanceEvent";
import { PerformanceEvent, PerformanceEvents } from "./PerformanceEvent";
import { IPerformanceMeasurement } from "./IPerformanceMeasurement";

export type PerformanceCallbackFunction = (events: PerformanceEvent[]) => void;

export type InProgressPerformanceEvent = {
end: (
event?: Partial<PerformanceEvent>
) => PerformanceEvent | null;
end: (event?: Partial<PerformanceEvent>) => PerformanceEvent | null;
discard: () => void;
add: (fields: { [key: string]: {} | undefined; }) => void;
increment: (fields: { [key: string]: number | undefined; }) => void;
add: (fields: { [key: string]: {} | undefined }) => void;
increment: (fields: { [key: string]: number | undefined }) => void;
event: PerformanceEvent;
measurement: IPerformanceMeasurement;
};
Expand All @@ -29,8 +24,14 @@ export interface IPerformanceClient {
): InProgressPerformanceEvent;
endMeasurement(event: PerformanceEvent): PerformanceEvent | null;
discardMeasurements(correlationId: string): void;
addFields(fields: { [key: string]: {} | undefined }, correlationId: string): void;
incrementFields(fields: { [key: string]: number | undefined }, correlationId: string): void;
addFields(
fields: { [key: string]: {} | undefined },
correlationId: string
): void;
incrementFields(
fields: { [key: string]: number | undefined },
correlationId: string
): void;
removePerformanceCallback(callbackId: string): boolean;
addPerformanceCallback(callback: PerformanceCallbackFunction): string;
emitEvents(events: PerformanceEvent[], correlationId: string): void;
Expand Down
26 changes: 15 additions & 11 deletions lib/msal-common/src/telemetry/performance/PerformanceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
IntFields,
PerformanceEvent,
PerformanceEvents,
PerformanceEventStatus
PerformanceEventStatus,
} from "./PerformanceEvent";

export interface PreQueueEvent {
Expand Down Expand Up @@ -316,15 +316,15 @@ export abstract class PerformanceClient implements IPerformanceClient {
discard: () => {
return this.discardMeasurements(inProgressEvent.correlationId);
},
add: (fields: { [key: string]: {} | undefined; }) => {
return this.addFields(
add: (fields: { [key: string]: {} | undefined }) => {
return this.addFields(fields, inProgressEvent.correlationId);
},
increment: (fields: { [key: string]: number | undefined }) => {
return this.incrementFields(
fields,
inProgressEvent.correlationId
);
},
increment: (fields: { [key: string]: number | undefined; }) => {
return this.incrementFields(fields, inProgressEvent.correlationId);
},
measurement: performanceMeasurement,
event: inProgressEvent,
};
Expand Down Expand Up @@ -421,7 +421,10 @@ export abstract class PerformanceClient implements IPerformanceClient {
* @param fields
* @param correlationId
*/
addFields(fields: { [key: string]: {} | undefined; }, correlationId: string): void {
addFields(
fields: { [key: string]: {} | undefined },
correlationId: string
): void {
this.logger.trace("PerformanceClient: Updating static fields");
const event = this.eventsByCorrelationId.get(correlationId);
if (event) {
Expand All @@ -442,7 +445,10 @@ export abstract class PerformanceClient implements IPerformanceClient {
* @param fields {string[]}
* @param correlationId {string} correlation identifier
*/
incrementFields(fields: { [key: string]: number | undefined; }, correlationId: string): void {
incrementFields(
fields: { [key: string]: number | undefined },
correlationId: string
): void {
this.logger.trace("PerformanceClient: Updating counters");
const event = this.eventsByCorrelationId.get(correlationId);
if (event) {
Expand Down Expand Up @@ -622,9 +628,7 @@ export abstract class PerformanceClient implements IPerformanceClient {
* @param {PerformanceEvent} event performance event to update.
* @param {Set<string>} intFields integral fields.
*/
private truncateIntegralFields(
event: PerformanceEvent
): void {
private truncateIntegralFields(event: PerformanceEvent): void {
this.intFields.forEach((key) => {
if (key in event && typeof event[key] === "number") {
event[key] = Math.floor(event[key]);
Expand Down
Loading

0 comments on commit 201f4e2

Please sign in to comment.