Skip to content

Commit

Permalink
Users/nityagi/update feature branch (#933)
Browse files Browse the repository at this point in the history
* Moving auth create flow to utils (#926)

Co-authored-by: amitjoshi <[email protected]>

* Making auth provider a common module flow (#928)

* refactor: Update QuickPickProvider to handle tab input changes (#930)

The code changes in the QuickPickProvider class handle tab input changes by checking if the active tab is an instance of vscode.TabInputCustom or vscode.TabInputText. If it is, the QuickPickProvider updates the quick pick items based on the file path of the tab input.

Note: This commit message follows the convention used in recent repository commits.

* Updates to Artemis service & telemetry endpoints for gov clouds (#906)

* Updates to artemis for gov clouds

* change

* changes

---------

Co-authored-by: Shivika Gupta <[email protected]>

---------

Co-authored-by: amitjoshi438 <[email protected]>
Co-authored-by: amitjoshi <[email protected]>
Co-authored-by: Ritik Ramuka <[email protected]>
Co-authored-by: gshivi <[email protected]>
Co-authored-by: Shivika Gupta <[email protected]>
  • Loading branch information
6 people authored May 7, 2024
1 parent 34e8239 commit 2ec0bbc
Show file tree
Hide file tree
Showing 30 changed files with 404 additions and 272 deletions.
2 changes: 2 additions & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"You are editing a live, public site ": "You are editing a live, public site ",
"Preview site": "Preview site",
"Open in Power Pages studio": "Open in Power Pages studio",
"Preview site URL is not available": "Preview site URL is not available",
"Opening preview site...": "Opening preview site...",
"Power Pages studio URL is not available": "Power Pages studio URL is not available",
"Microsoft wants your feeback": "Microsoft wants your feeback",
"Check the URL and verify the parameters are correct": "Check the URL and verify the parameters are correct",
"Unable to complete the request": "Unable to complete the request",
Expand Down
6 changes: 6 additions & 0 deletions loc/translations-export/vscode-powerplatform.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,19 @@ The {3} represents Dataverse Environment's Organization ID (GUID)</note>
<source xml:lang="en">Power Pages Copilot is now connected to the environment: {0} : {1}</source>
<note>{0} represents the environment name</note>
</trans-unit>
<trans-unit id="++CODE++cce89cd3a0f118dafd3173f6444abdcd2b9782153af1b6bfa8f63ef3d4b68268">
<source xml:lang="en">Power Pages studio URL is not available</source>
</trans-unit>
<trans-unit id="++CODE++777d5f3afd46e18d42c0baad6d9a0c7a6867cdf31ae4d342ad5e695486f05ae7">
<source xml:lang="en">Preparing pac CLI (v{0})...</source>
<note>{0} represents the version number</note>
</trans-unit>
<trans-unit id="++CODE++f6412ced721a26ac3e3cb55d3ff713d8403c3dfc2efa0cff07b48478bdd57555">
<source xml:lang="en">Preview site</source>
</trans-unit>
<trans-unit id="++CODE++f190e8061b8cbadd991ff217210525eff0000a8c6ddc2d44baec8388b7bd1a3e">
<source xml:lang="en">Preview site URL is not available</source>
</trans-unit>
<trans-unit id="++CODE++7a6098eb5ff2c2401890216bb502ce6583ff7bddc99e62f8751551eab45ae1b4">
<source xml:lang="en">Profile Kind: {0}</source>
<note>The {0} represents the profile type (Admin vs Dataverse)</note>
Expand Down
4 changes: 2 additions & 2 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ export async function activate(
const orgID = orgDetails.OrgId;
const artemisResponse = await fetchArtemisResponse(orgID, _telemetry);
if (artemisResponse) {
const { geoName } = artemisResponse[0];
oneDSLoggerWrapper.instantiate(geoName);
const { geoName, geoLongName } = artemisResponse[0];
oneDSLoggerWrapper.instantiate(geoName, geoLongName);
oneDSLoggerWrapper.getLogger().traceInfo(telemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT, {...orgDetails, orgGeo: geoName});
}
})
Expand Down
14 changes: 11 additions & 3 deletions src/common/ArtemisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ 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 { tstUrl, preprodUrl, prodUrl, gccUrl, highUrl, mooncakeUrl, dodUrl } = convertGuidToUrls(orgId);
const endpoints = [tstUrl, preprodUrl, prodUrl, gccUrl, highUrl, mooncakeUrl, dodUrl];

const artemisResponse = await fetchIslandInfo(endpoints, telemetry, sessionID);

Expand Down Expand Up @@ -87,10 +87,18 @@ export function convertGuidToUrls(orgId: string) {
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`;
const gccUrl = `https://${domain}.${nonProdSegment}.organization.api.gov.powerplatform.microsoft.us/gateway/cluster?api-version=1`;
const highUrl = `https://${domain}.${nonProdSegment}.organization.api.high.powerplatform.microsoft.us/gateway/cluster?api-version=1`;
const mooncakeUrl = `https://${domain}.${nonProdSegment}.organization.api.powerplatform.partner.microsoftonline.cn/gateway/cluster?app-version=1`;
const dodUrl = `https://${domain}.${nonProdSegment}.organization.api.appsplatform.us/gateway/cluster?app-version=1`;

return {
tstUrl,
preprodUrl,
prodUrl
prodUrl,
gccUrl,
highUrl,
mooncakeUrl,
dodUrl
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@
*/

import * as vscode from "vscode";
import WebExtensionContext from "../WebExtensionContext";
import { telemetryEventNames } from "../telemetry/constants";
import {
INTELLIGENCE_SCOPE_DEFAULT,
PROVIDER_ID,
SCOPE_OPTION_CONTACTS_READ,
SCOPE_OPTION_DEFAULT,
SCOPE_OPTION_OFFLINE_ACCESS,
SCOPE_OPTION_USERS_READ_BASIC_ALL,
} from "./constants";
import { ERRORS, showErrorDialog } from "./errorHandler";
import { ITelemetry } from "../../../client/telemetry/ITelemetry";
import { sendTelemetryEvent } from "../../../common/copilot/telemetry/copilotTelemetry";
import { CopilotLoginFailureEvent, CopilotLoginSuccessEvent } from "../../../common/copilot/telemetry/telemetryConstants";
import { getUserAgent } from "../../../common/Utils";
} from "../web/client/common/constants";
import { showErrorDialog } from "../web/client/common/errorHandler";
import { ITelemetry } from "../client/telemetry/ITelemetry";
import { sendTelemetryEvent } from "./copilot/telemetry/copilotTelemetry";
import { CopilotLoginFailureEvent, CopilotLoginSuccessEvent } from "./copilot/telemetry/telemetryConstants";
import { getUserAgent } from "./Utils";
import {
VSCODE_EXTENSION_DATAVERSE_AUTHENTICATION_COMPLETED,
VSCODE_EXTENSION_DATAVERSE_AUTHENTICATION_FAILED,
VSCODE_EXTENSION_NPS_AUTHENTICATION_COMPLETED,
VSCODE_EXTENSION_NPS_AUTHENTICATION_FAILED,
VSCODE_EXTENSION_NPS_AUTHENTICATION_STARTED,
VSCODE_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_FAILED,
VSCODE_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_COMPLETED
} from "./TelemetryConstants";
import { ERRORS } from "./ErrorConstants";


export function getCommonHeadersForDataverse(
Expand Down Expand Up @@ -85,6 +93,7 @@ export async function intelligenceAPIAuthentication(telemetry: ITelemetry, sessi
}

export async function dataverseAuthentication(
telemetry: ITelemetry,
dataverseOrgURL: string,
firstTimeAuth = false
): Promise<{ accessToken: string, userId: string }> {
Expand Down Expand Up @@ -119,37 +128,38 @@ export async function dataverseAuthentication(
}

if (firstTimeAuth) {
WebExtensionContext.telemetry.sendInfoTelemetry(
telemetryEventNames.WEB_EXTENSION_DATAVERSE_AUTHENTICATION_COMPLETED,
sendTelemetryEvent(telemetry,
{
eventName: VSCODE_EXTENSION_DATAVERSE_AUTHENTICATION_COMPLETED,
userId: userId
}
);
}
} catch (error) {
const authError = (error as Error)?.message;
showErrorDialog(
vscode.l10n.t(
"Authorization Failed. Please run again to authorize it"
),
vscode.l10n.t("There was a permissions problem with the server")
);
WebExtensionContext.telemetry.sendErrorTelemetry(
telemetryEventNames.WEB_EXTENSION_DATAVERSE_AUTHENTICATION_FAILED,
dataverseAuthentication.name,
authError
sendTelemetryEvent(
telemetry, {
eventName: VSCODE_EXTENSION_DATAVERSE_AUTHENTICATION_FAILED,
error: error as Error
}
);
}

return { accessToken, userId };
}

export async function npsAuthentication(
telemetry: ITelemetry,
cesSurveyAuthorizationEndpoint: string
): Promise<string> {
let accessToken = "";
WebExtensionContext.telemetry.sendInfoTelemetry(
telemetryEventNames.NPS_AUTHENTICATION_STARTED
sendTelemetryEvent(telemetry,
{ eventName: VSCODE_EXTENSION_NPS_AUTHENTICATION_STARTED }
);
try {
const session = await vscode.authentication.getSession(
Expand All @@ -161,28 +171,30 @@ export async function npsAuthentication(
if (!accessToken) {
throw new Error(ERRORS.NO_ACCESS_TOKEN);
}
WebExtensionContext.telemetry.sendInfoTelemetry(
telemetryEventNames.NPS_AUTHENTICATION_COMPLETED
sendTelemetryEvent(telemetry,
{ eventName: VSCODE_EXTENSION_NPS_AUTHENTICATION_COMPLETED }
);
} catch (error) {
const authError = (error as Error)?.message;
showErrorDialog(
vscode.l10n.t(
"Authorization Failed. Please run again to authorize it"
),
vscode.l10n.t("There was a permissions problem with the server")
);
WebExtensionContext.telemetry.sendErrorTelemetry(
telemetryEventNames.NPS_AUTHENTICATION_FAILED,
npsAuthentication.name,
authError
sendTelemetryEvent(
telemetry,
{
eventName: VSCODE_EXTENSION_NPS_AUTHENTICATION_FAILED,
error: error as Error
}
);
}

return accessToken;
}

export async function graphClientAuthentication(
telemetry: ITelemetry,
firstTimeAuth = false
): Promise<string> {
let accessToken = "";
Expand Down Expand Up @@ -213,29 +225,24 @@ export async function graphClientAuthentication(
}

if (firstTimeAuth) {
WebExtensionContext.telemetry.sendInfoTelemetry(
telemetryEventNames.WEB_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_COMPLETED,
{
userId:
session?.account.id.split("/").pop() ??
session?.account.id ??
"",
}
);
sendTelemetryEvent(telemetry, {
eventName: VSCODE_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_COMPLETED,
userId:
session?.account.id.split("/").pop() ??
session?.account.id ??
"",
});
}
} catch (error) {
const authError = (error as Error)?.message;
showErrorDialog(
vscode.l10n.t(
"Authorization Failed. Please run again to authorize it"
),
vscode.l10n.t("There was a permissions problem with the server")
);
WebExtensionContext.telemetry.sendErrorTelemetry(
telemetryEventNames.WEB_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_FAILED,
graphClientAuthentication.name,
authError
);
sendTelemetryEvent(telemetry,
{ eventName: VSCODE_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_FAILED, error: error as Error }
)
}

return accessToken;
Expand Down
55 changes: 55 additions & 0 deletions src/common/ErrorConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/


export const ERRORS = {
SUBURI_EMPTY: "SubURI value for entity file is empty",
NO_ACCESS_TOKEN: "No access token was created",
PORTAL_FOLDER_NAME_EMPTY: "portalFolderName value for entity file is empty",
ATTRIBUTES_EMPTY: "Entity file attribute or extension field empty",
WORKSPACE_INITIAL_LOAD: "There was a problem opening the workspace",
WORKSPACE_INITIAL_LOAD_DESC: "Try refreshing the browser",
UNKNOWN_APP: "Unable to find that app",
AUTHORIZATION_FAILED:
"Authorization Failed. Please run again to authorize it",
FILE_NOT_FOUND: "The file was not found",
RETRY_LIMIT_EXCEEDED: "Unable to complete that operation",
RETRY_LIMIT_EXCEEDED_DESC: "You've exceeded the retry limit ",
PRECONDITION_CHECK_FAILED: "The precondition check did not work",
PRECONDITION_CHECK_FAILED_DESC: "Try again",
SERVER_ERROR_RETRY_LATER: "There was a problem with the server",
SERVER_ERROR_RETRY_LATER_DESC: "Please try again in a minute or two",
SERVER_ERROR_PERMISSION_DENIED:
"There was a permissions problem with the server",
SERVER_ERROR_PERMISSION_DENIED_DESC: "Please try again in a minute or two",
EMPTY_RESPONSE: "There was no response",
EMPTY_RESPONSE_DESC: "Try again",
THRESHOLD_LIMIT_EXCEEDED: "Threshold for dataverse api",
THRESHOLD_LIMIT_EXCEEDED_DESC:
"You’ve exceeded the threshold rate limit for the Dataverse API",
BAD_REQUEST: "Unable to complete the request",
BAD_REQUEST_DESC:
"One or more attribute names have been changed or removed. Contact your admin.",
BACKEND_ERROR: "There’s a problem on the back end",
SERVICE_UNAVAILABLE: "There’s a problem connecting to Dataverse",
SERVICE_ERROR: "There’s a problem connecting to Dataverse",
INVALID_ARGUMENT: "One or more commands are invalid or malformed",
BACKEND_ERROR_DESC: "Try again",
SERVICE_UNAVAILABLE_DESC: "Try again",
SERVICE_ERROR_DESC: "Try again",
INVALID_ARGUMENT_DESC: "Check the parameters and try again",
MANDATORY_PARAMETERS_NULL: "The workspace is not available ",
MANDATORY_PARAMETERS_NULL_DESC:
"Check the URL and verify the parameters are correct",
FILE_NAME_NOT_SET: "That file is not available",
FILE_NAME_NOT_SET_DESC:
"The metadata may have changed in the Dataverse side. Contact your admin. {message_attribute}",
FILE_NAME_EMPTY: "File name is empty",
FILE_ID_EMPTY: "File ID is empty",
LANGUAGE_CODE_ID_VALUE_NULL: "Language code ID is empty",
LANGUAGE_CODE_EMPTY: "Language code is empty",
BULKHEAD_LIMITS_EXCEEDED: "Bulkhead queue limits exceeded",
NPS_FAILED_AUTH: "Failed to authenticate with NPS"
};
53 changes: 38 additions & 15 deletions src/common/OneDSLoggerTelemetry/oneDSLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class OneDSLogger implements ITelemetryLogger {
},
};

public constructor(geo?: string) {
public constructor(geo?:string, geoLongName?:string ) {

this.appInsightsCore = new AppInsightsCore();
this.postChannel = new PostChannel();
Expand All @@ -93,7 +93,7 @@ export class OneDSLogger implements ITelemetryLogger {
httpXHROverride: this.fetchHttpXHROverride,
};

const instrumentationSetting: IInstrumentationSettings = OneDSLogger.getInstrumentationSettings(geo); // Need to replace with actual data
const instrumentationSetting : IInstrumentationSettings= OneDSLogger.getInstrumentationSettings(geo, geoLongName); // Need to replace with actual data

// Configure App insights core to send to collector
const coreConfig: IExtendedConfiguration = {
Expand Down Expand Up @@ -136,12 +136,26 @@ export class OneDSLogger implements ITelemetryLogger {
}
}

private static getInstrumentationSettings(geo?: string): IInstrumentationSettings {
const buildRegion: string = region;
const instrumentationSettings: IInstrumentationSettings = {
private static getInstrumentationSettings(geo?:string, geoLongName?: string): IInstrumentationSettings {
const buildRegion:string = region;
const instrumentationSettings:IInstrumentationSettings = {
endpointURL: 'https://self.pipe.aria.int.microsoft.com/OneCollector/1.0/',
instrumentationKey: 'ffdb4c99ca3a4ad5b8e9ffb08bf7da0d-65357ff3-efcd-47fc-b2fd-ad95a52373f4-7402'
};
switch(geoLongName){
case 'usgov':
geo = 'gov';
break;
case 'usgovhigh':
geo = 'high';
break;
case 'usdod':
geo = 'dod';
break;
case 'china':
geo = 'mooncake';
break;
}
switch (buildRegion) {
case 'tie':
case 'test':
Expand All @@ -161,7 +175,7 @@ export class OneDSLogger implements ITelemetryLogger {
case 'ae':
case 'kr':
instrumentationSettings.endpointURL = 'https://us-mobile.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
break;
case 'eu':
case 'uk':
Expand All @@ -170,21 +184,30 @@ export class OneDSLogger implements ITelemetryLogger {
case 'no':
case 'ch':
instrumentationSettings.endpointURL = 'https://eu-mobile.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
break;
case 'gov':
instrumentationSettings.endpointURL = 'https://tb.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = '2f217cb8f40440eeb8b0aa80a2be2f7e-e0ec7b51-d1bb-4d8c-83b1-cc77aaba9009-7472'
break;
case 'high':
instrumentationSettings.endpointURL = 'https://tb.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = '4a07e143372c46aabf3841dc4f0ef795-a753031e-2005-4282-9451-a086fea4234a-6942'
break;
case 'dod':
instrumentationSettings.endpointURL = 'https://pf.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = 'af47f3d608774379a53fa07cf36362ea-69701588-1aad-43ee-8b52-f71125849774-6656'
break;
case 'mooncake':
instrumentationSettings.endpointURL = 'https://collector.azure.cn/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = 'f9b6e63b5e394453ba8f58f7a7b9aea7-f38fcfa2-eb34-48bc-9ae2-61fba4abbd39-7390' //prod key;
break;
default:
instrumentationSettings.endpointURL = 'https://us-mobile.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
break;
}
break;
case 'gov':
case 'high':
case 'dod':
case 'mooncake':
instrumentationSettings.endpointURL = '',
instrumentationSettings.instrumentationKey = '' //prod key;
break;
case 'ex':
case 'rx':
default:
Expand Down
Loading

0 comments on commit 2ec0bbc

Please sign in to comment.