Skip to content

Commit

Permalink
CES survey telemetry endpoint update for copilots geo expansion (#785)
Browse files Browse the repository at this point in the history
* Update telemetry collection for non-US geos copilot feedback - this needs to be updated after follow-up with Privacy champs on EUDB boundaries

* Add constants value
  • Loading branch information
tyaginidhi authored Dec 5, 2023
1 parent a5d2c46 commit 26fac4e
Show file tree
Hide file tree
Showing 7 changed files with 565 additions and 539 deletions.
100 changes: 50 additions & 50 deletions src/common/ArtemisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ import { CopilotArtemisFailureEvent, CopilotArtemisSuccessEvent } from "./copilo

export async function getIntelligenceEndpoint(orgId: string, telemetry: ITelemetry, sessionID: string) {

const artemisResponse = await fetchArtemisResponse(orgId, telemetry, sessionID);
const artemisResponse = await fetchArtemisResponse(orgId, telemetry, sessionID);

if (!artemisResponse) {
return null;
}
if (!artemisResponse) {
return { intelligenceEndpoint: null, geoName: null };
}

const { geoName, environment, clusterNumber } = artemisResponse[0];
sendTelemetryEvent(telemetry, { eventName: CopilotArtemisSuccessEvent, copilotSessionId: sessionID, geoName: String(geoName), orgId: orgId });
const { geoName, environment, clusterNumber } = artemisResponse[0];
sendTelemetryEvent(telemetry, { eventName: CopilotArtemisSuccessEvent, copilotSessionId: sessionID, geoName: String(geoName), orgId: orgId });

if (geoName !== US_GEO) {
return COPILOT_UNAVAILABLE;
}
if (geoName !== US_GEO) {
return { intelligenceEndpoint: COPILOT_UNAVAILABLE, geoName: geoName };
}

const intelligenceEndpoint = `https://aibuildertextapiservice.${geoName}-${'il' + clusterNumber}.gateway.${environment}.island.powerapps.com/v1.0/${orgId}/appintelligence/chat`
const intelligenceEndpoint = `https://aibuildertextapiservice.${geoName}-${'il' + clusterNumber}.gateway.${environment}.island.powerapps.com/v1.0/${orgId}/appintelligence/chat`

return intelligenceEndpoint;
return { intelligenceEndpoint: intelligenceEndpoint, geoName: geoName };

}

Expand All @@ -38,35 +38,35 @@ export async function fetchArtemisResponse(orgId: string, telemetry: ITelemetry,
const artemisResponse = await fetchIslandInfo(endpoints, telemetry, sessionID);

return artemisResponse;
}
}

async function fetchIslandInfo(endpoints: string[], telemetry: ITelemetry, sessionID: string) {

const requestInit: RequestInit = {
method: 'GET',
redirect: 'follow'
};

try {
const promises = endpoints.map(async endpoint => {
try {
const response = await fetch(endpoint, requestInit);
if (!response.ok) {
throw new Error('Request failed');
}
return response.json();
} catch (error) {
const requestInit: RequestInit = {
method: 'GET',
redirect: 'follow'
};

try {
const promises = endpoints.map(async endpoint => {
try {
const response = await fetch(endpoint, requestInit);
if (!response.ok) {
throw new Error('Request failed');
}
return response.json();
} catch (error) {
return null;
}
});

const responses = await Promise.all(promises);
const successfulResponses = responses.filter(response => response !== null);
return successfulResponses;
} catch (error) {
sendTelemetryEvent(telemetry, { eventName: CopilotArtemisFailureEvent, copilotSessionId: sessionID, error: error as Error })
return null;
}
});

const responses = await Promise.all(promises);
const successfulResponses = responses.filter(response => response !== null);
return successfulResponses;
} catch (error) {
sendTelemetryEvent(telemetry, { eventName: CopilotArtemisFailureEvent, copilotSessionId: sessionID, error: error as Error })
return null;
}
}
}


Expand All @@ -79,18 +79,18 @@ async function fetchIslandInfo(endpoints: string[], telemetry: ITelemetry, sessi
* Prod: https:// c7809087d9b84a00a78aa4b901caa2.3f.organization.api.powerplatform.com/artemis
*/
export function convertGuidToUrls(orgId: string) {
const updatedOrgId = orgId.replace(/-/g, "");
const domain = updatedOrgId.slice(0, -1);
const domainProd = updatedOrgId.slice(0, -2);
const nonProdSegment = updatedOrgId.slice(-1);
const prodSegment = updatedOrgId.slice(-2);
const tstUrl = `https://${domain}.${nonProdSegment}.organization.api.test.powerplatform.com/gateway/cluster?api-version=1`;
const preprodUrl = `https://${domain}.${nonProdSegment}.organization.api.preprod.powerplatform.com/gateway/cluster?api-version=1`;
const prodUrl = `https://${domainProd}.${prodSegment}.organization.api.powerplatform.com/gateway/cluster?api-version=1`;

return {
tstUrl,
preprodUrl,
prodUrl
};
const updatedOrgId = orgId.replace(/-/g, "");
const domain = updatedOrgId.slice(0, -1);
const domainProd = updatedOrgId.slice(0, -2);
const nonProdSegment = updatedOrgId.slice(-1);
const prodSegment = updatedOrgId.slice(-2);
const tstUrl = `https://${domain}.${nonProdSegment}.organization.api.test.powerplatform.com/gateway/cluster?api-version=1`;
const preprodUrl = `https://${domain}.${nonProdSegment}.organization.api.preprod.powerplatform.com/gateway/cluster?api-version=1`;
const prodUrl = `https://${domainProd}.${prodSegment}.organization.api.powerplatform.com/gateway/cluster?api-version=1`;

return {
tstUrl,
preprodUrl,
prodUrl
};
}
Loading

0 comments on commit 26fac4e

Please sign in to comment.