From f9e96968133b470cedcc36d044091718d7f7f6b7 Mon Sep 17 00:00:00 2001 From: amitjoshi438 <54068463+amitjoshi438@users.noreply.github.com> Date: Tue, 14 Nov 2023 08:58:58 +0530 Subject: [PATCH] Added artemis response (geo) on extension load (#761) * added artemis (geo) to extension load telemetry * added try - catch --------- Co-authored-by: amitjoshi Co-authored-by: tyaginidhi --- src/common/ArtemisService.ts | 14 +++++++++++--- src/web/client/common/constants.ts | 1 + src/web/client/extension.ts | 28 +++++++++++++++++++++++++++ src/web/client/telemetry/constants.ts | 2 ++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/common/ArtemisService.ts b/src/common/ArtemisService.ts index 92a39978..c8f930b5 100644 --- a/src/common/ArtemisService.ts +++ b/src/common/ArtemisService.ts @@ -10,10 +10,8 @@ import { sendTelemetryEvent } from "./copilot/telemetry/copilotTelemetry"; import { CopilotArtemisFailureEvent, CopilotArtemisSuccessEvent } from "./copilot/telemetry/telemetryConstants"; export async function getIntelligenceEndpoint(orgId: string, telemetry: ITelemetry, sessionID: string) { - const { tstUrl, preprodUrl, prodUrl } = convertGuidToUrls(orgId); - const endpoints = [tstUrl, preprodUrl, prodUrl]; - const artemisResponse = await fetchIslandInfo(endpoints, telemetry, sessionID); + const artemisResponse = await fetchArtemisResponse(orgId, telemetry, sessionID); if (!artemisResponse) { return null; @@ -32,6 +30,16 @@ export async function getIntelligenceEndpoint(orgId: string, telemetry: ITelemet } +// Function to fetch Artemis response +export async function fetchArtemisResponse(orgId: string, telemetry: ITelemetry, sessionID = '') { + const { tstUrl, preprodUrl, prodUrl } = convertGuidToUrls(orgId); + const endpoints = [tstUrl, preprodUrl, prodUrl]; + + const artemisResponse = await fetchIslandInfo(endpoints, telemetry, sessionID); + + return artemisResponse; + } + async function fetchIslandInfo(endpoints: string[], telemetry: ITelemetry, sessionID: string) { const requestInit: RequestInit = { diff --git a/src/web/client/common/constants.ts b/src/web/client/common/constants.ts index f11a2358..0bcca39a 100644 --- a/src/web/client/common/constants.ts +++ b/src/web/client/common/constants.ts @@ -28,6 +28,7 @@ export const MAX_CONCURRENT_REQUEST_QUEUE_COUNT = 1000; export const INTELLIGENCE_SCOPE_DEFAULT = "https://text.pai.dynamics.com/.default"; export const BACK_TO_STUDIO_URL_TEMPLATE = "https://make{.region}.powerpages.microsoft.com/e/{environmentId}/sites/{webSiteId}/pages"; export const STUDIO_PROD_REGION = "prod"; +export const ARTEMIS_RESPONSE_FAILED = "Artemis response failed" // Web extension constants export const BASE_64 = 'base64'; diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index 88c3f787..f374b5f7 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -10,6 +10,7 @@ import { PUBLIC, queryParameters, IS_MULTIFILE_FIRST_RUN_EXPERIENCE, + ARTEMIS_RESPONSE_FAILED, } from "./common/constants"; import { PortalsFS } from "./dal/fileSystemProvider"; import { @@ -33,6 +34,7 @@ import * as copilot from "../../common/copilot/PowerPagesCopilot"; import { IOrgInfo } from "../../common/copilot/model"; import { copilotNotificationPanel, disposeNotificationPanel } from "../../common/copilot/welcome-notification/CopilotNotificationPanel"; import { COPILOT_NOTIFICATION_DISABLED } from "../../common/copilot/constants"; +import { fetchArtemisResponse } from "../../common/ArtemisService"; export function activate(context: vscode.ExtensionContext): void { // setup telemetry @@ -144,6 +146,8 @@ export function activate(context: vscode.ExtensionContext): void { context.extensionUri ); } + + await logArtemisTelemetry(); } break; default: @@ -460,3 +464,27 @@ function isActiveDocument(fileFsPath: string): boolean { WebExtensionContext.fileDataMap.getFileMap.has(fileFsPath) ); } + +async function logArtemisTelemetry() { + + try { + const orgId = WebExtensionContext.urlParametersMap.get( + queryParameters.ORG_ID + ) as string + + const artemisResponse = await fetchArtemisResponse(orgId, WebExtensionContext.telemetry.getTelemetryReporter()); + + if (!artemisResponse) { + return; + } + + const { geoName } = artemisResponse[0]; + 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); + } +} diff --git a/src/web/client/telemetry/constants.ts b/src/web/client/telemetry/constants.ts index 4a019eb9..db3e8e98 100644 --- a/src/web/client/telemetry/constants.ts +++ b/src/web/client/telemetry/constants.ts @@ -99,5 +99,7 @@ export enum telemetryEventNames { WEB_EXTENSION_PREVIEW_SITE_TRIGGERED = 'webExtensionPreviewSiteTriggered', WEB_EXTENSION_IMAGE_EDIT_SUPPORTED_FILE_EXTENSION = 'webExtensionImageEditSupportedFileExtension', WEB_EXTENSION_SAVE_IMAGE_FILE_TRIGGERED = 'webExtensionSaveImageFileTriggered', + WEB_EXTENSION_ARTEMIS_RESPONSE = 'webExtensionArtemisResponse', + WEB_EXTENSION_ARTEMIS_RESPONSE_FAILED = 'webExtensionArtemisResponseFailed', WEB_EXTENSION_FAILED_TO_UPDATE_FOREIGN_KEY_DETAILS = 'webExtensionFailedToUpdateForeignKeyDetails', }