diff --git a/src/common/copilot/PowerPagesCopilot.ts b/src/common/copilot/PowerPagesCopilot.ts index 86e93855..fe139ceb 100644 --- a/src/common/copilot/PowerPagesCopilot.ts +++ b/src/common/copilot/PowerPagesCopilot.ts @@ -34,7 +34,7 @@ let orgID: string; let environmentName: string; let activeOrgUrl: string; let tenantId: string | undefined; -let environmentId: string | undefined; +let environmentId: string; declare const IS_DESKTOP: string | undefined; //TODO: Check if it can be converted to singleton @@ -393,11 +393,12 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { environmentName = activeOrg.FriendlyName; userID = activeOrg.UserId; activeOrgUrl = activeOrg.OrgUrl; + environmentId = activeOrg.EnvironmentId sessionID = uuidv4(); // Generate a new session ID on org change sendTelemetryEvent(this.telemetry, { eventName: CopilotOrgChangedEvent, copilotSessionId: sessionID, orgId: orgID }); - const intelligenceAPIEndpointInfo = await ArtemisService.getIntelligenceEndpoint(orgID, this.telemetry, sessionID, environmentId ?? ''); + const intelligenceAPIEndpointInfo = await ArtemisService.getIntelligenceEndpoint(orgID, this.telemetry, sessionID, environmentId); this.aibEndpoint = intelligenceAPIEndpointInfo.intelligenceEndpoint; this.geoName = intelligenceAPIEndpointInfo.geoName; this.crossGeoDataMovementEnabledPPACFlag = intelligenceAPIEndpointInfo.crossGeoDataMovementEnabledPPACFlag; diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index 988109fb..5a304141 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -116,9 +116,9 @@ export function activate(context: vscode.ExtensionContext): void { ); logOneDSLogger(queryParamsMap); const orgId = queryParamsMap.get(queryParameters.ORG_ID) as string; - const orgGeo = await fetchArtemisData(orgId); - WebExtensionContext.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_ORG_GEO, { orgGeo: orgGeo }); - oneDSLoggerWrapper.instantiate(orgGeo); + const { geoName, geoLongName } = await fetchArtemisData(orgId); + WebExtensionContext.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_ORG_GEO, { orgId: orgId, orgGeo: geoName }); + oneDSLoggerWrapper.instantiate(geoName, geoLongName); WebExtensionContext.telemetry.sendExtensionInitPathParametersTelemetry( appName, @@ -172,8 +172,6 @@ export function activate(context: vscode.ExtensionContext): void { context.extensionUri ); } - - await logArtemisTelemetry(); } break; default: @@ -651,32 +649,18 @@ function isActiveDocument(fileFsPath: string): boolean { ); } -async function fetchArtemisData(orgId: string): Promise { +async function fetchArtemisData(orgId: string): Promise { const artemisResponse = await ArtemisService.fetchArtemisResponse(orgId, WebExtensionContext.telemetry.getTelemetryReporter()); if (artemisResponse === null || artemisResponse.length === 0) { - // Todo: Log in error telemetry. Runtime maintains another table for this kind of failure. We should do the same. - return ''; - } - - return (artemisResponse[0]?.response as unknown as IArtemisAPIOrgResponse).geoName as string; -} - -async function logArtemisTelemetry() { - - try { - const orgId = WebExtensionContext.urlParametersMap.get( - queryParameters.ORG_ID - ) as string - - const geoName = await fetchArtemisData(orgId); - WebExtensionContext.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_ARTEMIS_RESPONSE, - { orgId: orgId, geoName: String(geoName) }); - } catch (error) { WebExtensionContext.telemetry.sendErrorTelemetry( telemetryEventNames.WEB_EXTENSION_ARTEMIS_RESPONSE_FAILED, - logArtemisTelemetry.name, - ARTEMIS_RESPONSE_FAILED); + fetchArtemisData.name, + ARTEMIS_RESPONSE_FAILED + ); + return { geo: "", geoLongName: "" } as unknown as IArtemisAPIOrgResponse; } + + return artemisResponse[0]?.response as unknown as IArtemisAPIOrgResponse; } function logOneDSLogger(queryParamsMap: Map) { diff --git a/src/web/client/telemetry/constants.ts b/src/web/client/telemetry/constants.ts index 76399dd5..b9a97255 100644 --- a/src/web/client/telemetry/constants.ts +++ b/src/web/client/telemetry/constants.ts @@ -107,7 +107,6 @@ export enum telemetryEventNames { WEB_EXTENSION_FETCH_WORKER_SCRIPT_FAILED = 'webExtensionFetchWorkerScriptFailed', WEB_EXTENSION_WEB_WORKER_REGISTERED = 'webExtensionWebWorkerRegistered', WEB_EXTENSION_WEB_WORKER_REGISTRATION_FAILED = 'webExtensionWebWorkerRegistrationFailed', - WEB_EXTENSION_ARTEMIS_RESPONSE = 'webExtensionArtemisResponse', WEB_EXTENSION_ARTEMIS_RESPONSE_FAILED = 'webExtensionArtemisResponseFailed', WEB_EXTENSION_FAILED_TO_UPDATE_FOREIGN_KEY_DETAILS = 'webExtensionFailedToUpdateForeignKeyDetails', WEB_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_FAILED = "WebExtensionGraphClientAuthenticationFailed",