Skip to content

Commit

Permalink
Added artemis response (geo) on extension load (#761)
Browse files Browse the repository at this point in the history
* added artemis (geo) to extension load telemetry

* added try - catch

---------

Co-authored-by: amitjoshi <[email protected]>
Co-authored-by: tyaginidhi <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2023
1 parent 97af6c2 commit f9e9696
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/common/ArtemisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions src/web/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
28 changes: 28 additions & 0 deletions src/web/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
PUBLIC,
queryParameters,
IS_MULTIFILE_FIRST_RUN_EXPERIENCE,
ARTEMIS_RESPONSE_FAILED,
} from "./common/constants";
import { PortalsFS } from "./dal/fileSystemProvider";
import {
Expand All @@ -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
Expand Down Expand Up @@ -144,6 +146,8 @@ export function activate(context: vscode.ExtensionContext): void {
context.extensionUri
);
}

await logArtemisTelemetry();
}
break;
default:
Expand Down Expand Up @@ -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);
}
}
2 changes: 2 additions & 0 deletions src/web/client/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

0 comments on commit f9e9696

Please sign in to comment.