Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log AadObjectId for desktop extension telemetry #1009

Merged
merged 6 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import { IArtemisAPIOrgResponse } from "../common/services/Interfaces";
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 @@ -192,9 +194,14 @@ export async function activate(
const orgID = orgDetails.OrgId;
const artemisResponse = await ArtemisService.fetchArtemisResponse(orgID, _telemetry);
if (artemisResponse !== null && artemisResponse.length > 0) {
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[0]?.response as unknown as IArtemisAPIOrgResponse;
oneDSLoggerWrapper.instantiate(geoName, geoLongName);
oneDSLoggerWrapper.getLogger().traceInfo(desktopTelemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT, { ...orgDetails, orgGeo: geoName });
oneDSLoggerWrapper.getLogger().traceInfo(desktopTelemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT, { ...orgDetails, orgGeo: geoName, AadId: AadIdObject?.[0]?.Value });
gshivi marked this conversation as resolved.
Show resolved Hide resolved
}
})
);
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:';