Skip to content

Commit

Permalink
Log AadObjectId for desktop extension telemetry (#1009)
Browse files Browse the repository at this point in the history
* Changed for AAD Id

* Updates

* Removing extra line

* change

* Adding null check

---------

Co-authored-by: Shivika Gupta <[email protected]>
  • Loading branch information
gshivi and Shivika Gupta authored Aug 8, 2024
1 parent 17ea81a commit f21aefa
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import { desktopTelemetryEventNames } from "../common/OneDSLoggerTelemetry/clien
import { ArtemisService } from "../common/services/ArtemisService";
import { workspaceContainsPortalConfigFolder } from "../common/utilities/PathFinderUtil";
import { getPortalsOrgURLs } from "../common/utilities/WorkspaceInfoFinderUtil";
import { SUCCESS } from "../common/constants";
import { AadIdKey } from "../common/OneDSLoggerTelemetry/telemetryConstants";

let client: LanguageClient;
let _context: vscode.ExtensionContext;
Expand Down Expand Up @@ -191,9 +193,18 @@ export async function activate(
const orgID = orgDetails.OrgId;
const artemisResponse = await ArtemisService.getArtemisResponse(orgID, _telemetry, "");
if (artemisResponse !== null && artemisResponse.response !== null) {
const pacActiveAuth = await pacTerminal.getWrapper()?.activeAuth();
let AadIdObject;
if ((pacActiveAuth && pacActiveAuth.Status === SUCCESS)) {
AadIdObject = pacActiveAuth.Results?.filter(obj => obj.Key === AadIdKey);
}
const { geoName, geoLongName } = artemisResponse.response;
oneDSLoggerWrapper.instantiate(geoName, geoLongName);
oneDSLoggerWrapper.getLogger().traceInfo(desktopTelemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT, { ...orgDetails, orgGeo: geoName });
let initContext: object = { ...orgDetails, orgGeo: geoName };
if (AadIdObject?.[0]?.Value) {
initContext = { ...initContext, AadId: AadIdObject[0].Value }
}
oneDSLoggerWrapper.getLogger().traceInfo(desktopTelemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT, initContext);
}
})
);
Expand Down
7 changes: 7 additions & 0 deletions src/client/pac/PacTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ export type ActiveOrgOutput = {
}

export type PacOrgWhoOutput = PacOutputWithResult<ActiveOrgOutput>;

export type ActiveAuthOutput = {
Key: string,
Value: string
}

export type PacAuthWhoOutput = PacOutputWithResultList<ActiveAuthOutput>;
6 changes: 5 additions & 1 deletion src/client/pac/PacWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as fs from "fs-extra";
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
import { BlockingQueue } from "../../common/utilities/BlockingQueue";
import { ITelemetry } from "../../common/OneDSLoggerTelemetry/telemetry/ITelemetry";
import { PacOutput, PacAdminListOutput, PacAuthListOutput, PacSolutionListOutput, PacOrgListOutput, PacOrgWhoOutput } from "./PacTypes";
import { PacOutput, PacAdminListOutput, PacAuthListOutput, PacSolutionListOutput, PacOrgListOutput, PacOrgWhoOutput, PacAuthWhoOutput } from "./PacTypes";
import { v4 } from "uuid";
import { oneDSLoggerWrapper } from "../../common/OneDSLoggerTelemetry/oneDSLoggerWrapper";

Expand Down Expand Up @@ -168,6 +168,10 @@ export class PacWrapper {
return this.executeCommandAndParseResults<PacOrgWhoOutput>(new PacArguments("org", "who"));
}

public async activeAuth(): Promise <PacAuthWhoOutput> {
return this.executeCommandAndParseResults<PacAuthWhoOutput>(new PacArguments("auth", "who"));
}

public async pcfInit(outputDirectory: string): Promise<PacOutput> {
return this.executeCommandAndParseResults<PacOutput>(new PacArguments("pcf", "init", "--outputDirectory", outputDirectory));
}
Expand Down
1 change: 1 addition & 0 deletions src/common/OneDSLoggerTelemetry/oneDSLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ export class OneDSLogger implements ITelemetryLogger {
OneDSLogger.contextInfo.orgId = JSON.parse(envelope.data.eventInfo).OrgId;
OneDSLogger.contextInfo.envId = JSON.parse(envelope.data.eventInfo).EnvironmentId;
OneDSLogger.contextInfo.orgGeo = JSON.parse(envelope.data.eventInfo).orgGeo;
OneDSLogger.userInfo.oid = JSON.parse(envelope.data.eventInfo).AadId;
// TODO: Populate website id
OneDSLogger.contextInfo.websiteId = 'test'
}
Expand Down
2 changes: 2 additions & 0 deletions src/common/OneDSLoggerTelemetry/telemetryConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ export enum GeoNames {
}
// Custom telemetry feature flag
export const CUSTOM_TELEMETRY_FOR_POWER_PAGES_SETTING_NAME = 'enableTelemetry';

export const AadIdKey= 'Entra ID Object Id:';

0 comments on commit f21aefa

Please sign in to comment.