Skip to content

Commit

Permalink
Cleanup and arrange the files
Browse files Browse the repository at this point in the history
  • Loading branch information
tyaginidhi committed May 16, 2024
1 parent 485e51f commit f013b3d
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { bootstrapDiff } from "./power-pages/bootstrapdiff/BootstrapDiff";
import { CopilotNotificationShown } from "../common/copilot/telemetry/telemetryConstants";
import { copilotNotificationPanel, disposeNotificationPanel } from "../common/copilot/welcome-notification/CopilotNotificationPanel";
import { COPILOT_NOTIFICATION_DISABLED } from "../common/copilot/constants";
import { fetchArtemisResponse } from "../common/ArtemisService";
import { fetchArtemisResponse } from "../common/services/ArtemisService";
import { oneDSLoggerWrapper } from "../common/OneDSLoggerTelemetry/oneDSLoggerWrapper";
import { OrgChangeNotifier, orgChangeEvent } from "../common/OrgChangeNotifier";
import { ActiveOrgOutput } from "./pac/PacTypes";
Expand Down
34 changes: 17 additions & 17 deletions src/common/OneDSLoggerTelemetry/oneDSLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ITelemetryLogger } from "./ITelemetryLogger";
import { IContextInfo, IUserInfo } from "./IEventTypes";
import { EventType, Severity } from "./telemetryConstants";
import * as vscode from "vscode";
import { getExtensionType, getExtensionVersion } from "../../common/Utils";
import { getExtensionType, getExtensionVersion } from "../utilities/Utils";
import { EXTENSION_ID } from "../../client/constants";
import { OneDSCollectorEventName } from "./EventContants";
import { telemetryEventNames } from "../../web/client/telemetry/constants";
Expand Down Expand Up @@ -83,7 +83,7 @@ export class OneDSLogger implements ITelemetryLogger {
},
};

public constructor(geo?:string, geoLongName?: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, geoLongName); // 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,22 +136,22 @@ export class OneDSLogger implements ITelemetryLogger {
}
}

private static getInstrumentationSettings(geo?:string, geoLongName?: 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){
switch (geoLongName) {
case 'usgov':
geo = 'gov';
break;
case 'usgovhigh':
geo = 'high';
break;
break;
case 'usdod':
geo = 'dod';
break;
break;
case 'china':
geo = 'mooncake';
break;
Expand All @@ -175,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 @@ -184,27 +184,27 @@ 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'
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'
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'
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;
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;
Expand Down Expand Up @@ -365,7 +365,7 @@ export class OneDSLogger implements ITelemetryLogger {
OneDSLogger.contextInfo.orgGeo = eventInfo.orgGeo ?? '';
OneDSLogger.contextInfo.sku = eventInfo.sku ?? '';
}

if (envelope.data.eventName == telemetryEventNames.WEB_EXTENSION_DATAVERSE_AUTHENTICATION_COMPLETED) {
OneDSLogger.userInfo.oid = JSON.parse(envelope.data.eventInfo).userId;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/OneDSLoggerTelemetry/oneDSLoggerWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { isCustomTelemetryEnabled } from "../Utils";
import { isCustomTelemetryEnabled } from "../utilities/Utils";
import { OneDSLogger } from "./oneDSLogger";

//// Wrapper class of oneDSLogger for below purposes
Expand All @@ -23,7 +23,7 @@ export class oneDSLoggerWrapper {
return this.instance;
}

static instantiate(geo?:string, geoLongName?: string){
static instantiate(geo?: string, geoLongName?: string) {
oneDSLoggerWrapper.instance = new oneDSLoggerWrapper(geo, geoLongName);
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/copilot/IntelligenceApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IActiveFileParams } from "./model";
import { sendTelemetryEvent } from "./telemetry/copilotTelemetry";
import { ITelemetry } from "../../client/telemetry/ITelemetry";
import { CopilotResponseFailureEvent, CopilotResponseFailureEventWithMessage, CopilotResponseOkFailureEvent, CopilotResponseSuccessEvent } from "./telemetry/telemetryConstants";
import { getExtensionType, getExtensionVersion } from "../Utils";
import { getExtensionType, getExtensionVersion } from "../utilities/Utils";
import { EXTENSION_NAME } from "../../client/constants";
import { enableCrossGeoDataFlowInGeo } from "./utils/copilotUtil";

Expand Down
8 changes: 4 additions & 4 deletions src/common/copilot/PowerPagesCopilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@

import * as vscode from "vscode";
import { sendApiRequest } from "./IntelligenceApiService";
import { dataverseAuthentication, intelligenceAPIAuthentication } from "../AuthenticationProvider";
import { dataverseAuthentication, intelligenceAPIAuthentication } from "../services/AuthenticationProvider";
import { v4 as uuidv4 } from 'uuid'
import { PacWrapper } from "../../client/pac/PacWrapper";
import { ITelemetry } from "../../client/telemetry/ITelemetry";
import { ADX_ENTITYFORM, ADX_ENTITYLIST, AUTH_CREATE_FAILED, AUTH_CREATE_MESSAGE, AuthProfileNotFound, COPILOT_UNAVAILABLE, CopilotDisclaimer, CopilotStylePathSegments, EXPLAIN_CODE, PAC_SUCCESS, SELECTED_CODE_INFO, SELECTED_CODE_INFO_ENABLED, THUMBS_DOWN, THUMBS_UP, UserPrompt, WebViewMessage, sendIconSvg } from "./constants";
import { IActiveFileParams, IOrgInfo } from './model';
import { createAuthProfileExp, escapeDollarSign, getActiveEditorContent, getNonce, getSelectedCode, getSelectedCodeLineRange, getUserName, openWalkthrough, showConnectedOrgMessage, showInputBoxAndGetOrgUrl, showProgressWithNotification } from "../Utils";
import { createAuthProfileExp, escapeDollarSign, getActiveEditorContent, getNonce, getSelectedCode, getSelectedCodeLineRange, getUserName, openWalkthrough, showConnectedOrgMessage, showInputBoxAndGetOrgUrl, showProgressWithNotification } from "../utilities/Utils";
import { CESUserFeedback } from "./user-feedback/CESSurvey";
import { ActiveOrgOutput } from "../../client/pac/PacTypes";
import { CopilotWalkthroughEvent, CopilotCopyCodeToClipboardEvent, CopilotInsertCodeToEditorEvent, CopilotLoadedEvent, CopilotOrgChangedEvent, CopilotUserFeedbackThumbsDownEvent, CopilotUserFeedbackThumbsUpEvent, CopilotUserPromptedEvent, CopilotCodeLineCountEvent, CopilotClearChatEvent, CopilotNotAvailable, CopilotExplainCode, CopilotExplainCodeSize, CopilotNotAvailableECSConfig } from "./telemetry/telemetryConstants";
import { sendTelemetryEvent } from "./telemetry/copilotTelemetry";
import { getIntelligenceEndpoint } from "../ArtemisService";
import { getIntelligenceEndpoint } from "../services/ArtemisService";
import TelemetryReporter from "@vscode/extension-telemetry";
import { getEntityColumns, getEntityName, getFormXml } from "./dataverseMetadata";
import { isWithinTokenLimit, encode } from "gpt-tokenizer";
import { orgChangeErrorEvent, orgChangeEvent } from "../OrgChangeNotifier";
import { getDisabledOrgList, getDisabledTenantList } from "./utils/copilotUtil";
import { INTELLIGENCE_SCOPE_DEFAULT, PROVIDER_ID } from "../Constants";
import { INTELLIGENCE_SCOPE_DEFAULT, PROVIDER_ID } from "../services/Constants";

let intelligenceApiToken: string;
let userID: string; // Populated from PAC or intelligence API
Expand Down
14 changes: 7 additions & 7 deletions src/common/copilot/dataverseMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CopilotDataverseMetadataFailureEvent, CopilotDataverseMetadataSuccessEv
import { getEntityMetadata } from "../../web/client/utilities/fileAndEntityUtil";
import { DOMParser } from "@xmldom/xmldom";
import { ATTRIBUTE_CLASSID, ATTRIBUTE_DATAFIELD_NAME, ATTRIBUTE_DESCRIPTION, ControlClassIdMap, SYSTEFORMS_API_PATH } from "./constants";
import { getUserAgent } from "../Utils";
import { getUserAgent } from "../utilities/Utils";


declare const IS_DESKTOP: string | undefined;
Expand Down Expand Up @@ -45,7 +45,7 @@ export async function getEntityColumns(entityName: string, orgUrl: string, apiTo
}
}

export async function getFormXml(entityName: string, formName: string, orgUrl: string, apiToken: string, telemetry: ITelemetry, sessionID: string): Promise<(string [])>{
export async function getFormXml(entityName: string, formName: string, orgUrl: string, apiToken: string, telemetry: ITelemetry, sessionID: string): Promise<(string[])> {
try {
// Ensure the orgUrl ends with a '/'
const formattedOrgUrl = orgUrl.endsWith('/') ? orgUrl : `${orgUrl}/`;
Expand Down Expand Up @@ -93,10 +93,10 @@ async function fetchJsonResponse(url: string, requestInit: RequestInit): Promise
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getAttributesFromResponse(jsonResponse: any): string[] {
if (jsonResponse.Attributes && Array.isArray(jsonResponse.Attributes) && jsonResponse.Attributes.length > 0) {
const attributes = jsonResponse.Attributes;
const attributes = jsonResponse.Attributes;
const logicalNameDisplayName: string[] = [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
attributes.forEach((attr:any) => {
attributes.forEach((attr: any) => {
const attrDisplayName = attr.DisplayName?.UserLocalizedLabel?.Label; // Optional chaining for handling missing values
if (attrDisplayName) {
logicalNameDisplayName.push(attrDisplayName)
Expand Down Expand Up @@ -143,7 +143,7 @@ function parseXML(formXml: string) {
let classid = control.getAttribute(ATTRIBUTE_CLASSID);

let controlType = '';
if(classid){
if (classid) {

// Use a regular expression to replace both '{' and '}' with an empty string
// Input: '{5B773807-9FB2-42DB-97C3-7A91EFF8ADFF}'
Expand All @@ -163,7 +163,7 @@ function parseXML(formXml: string) {
}


export async function getEntityName(telemetry: ITelemetry, sessionID: string, dataverseEntity: string): Promise<{entityName: string, formName: string}> {
export async function getEntityName(telemetry: ITelemetry, sessionID: string, dataverseEntity: string): Promise<{ entityName: string, formName: string }> {
let entityName = '';
let formName = '';

Expand Down Expand Up @@ -196,7 +196,7 @@ export async function getEntityName(telemetry: ITelemetry, sessionID: string, da
sendTelemetryEvent(telemetry, { eventName: CopilotGetEntityFailureEvent, copilotSessionId: sessionID, dataverseEntity: dataverseEntity, error: error as Error });
entityName = '';
}
return {entityName, formName};
return { entityName, formName };
}

async function getMatchingFiles(folderPath: string, fileNameFirstPart: string): Promise<string[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/common/copilot/user-feedback/CESSurvey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/

import * as vscode from "vscode";
import { npsAuthentication } from "../../AuthenticationProvider";
import { npsAuthentication } from "../../services/AuthenticationProvider";
import { SurveyConstants } from "../../../web/client/common/constants";
import fetch from "node-fetch";
import { getNonce } from "../../Utils";
import { getNonce } from "../../utilities/Utils";
import { ITelemetry } from "../../../client/telemetry/ITelemetry";
import { CopilotNpsAuthenticationCompleted, CopilotUserFeedbackFailureEvent, CopilotUserFeedbackSuccessEvent } from "../telemetry/telemetryConstants";
import { sendTelemetryEvent } from "../telemetry/copilotTelemetry";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import * as vscode from "vscode";
import { getNonce, openWalkthrough } from "../../Utils";
import { getNonce, openWalkthrough } from "../../utilities/Utils";
import TelemetryReporter from "@vscode/extension-telemetry";
import { CopilotNotificationDoNotShowChecked, CopilotTryNotificationClickedEvent, CopilotWalkthroughEvent, CopilotNotificationDoNotShowUnchecked } from "../telemetry/telemetryConstants";
import { COPILOT_NOTIFICATION_DISABLED } from "../constants";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
*/

import fetch, { RequestInit } from "node-fetch";
import { COPILOT_UNAVAILABLE } from "./copilot/constants";
import { ITelemetry } from "../client/telemetry/ITelemetry";
import { sendTelemetryEvent } from "./copilot/telemetry/copilotTelemetry";
import { CopilotArtemisFailureEvent, CopilotArtemisSuccessEvent } from "./copilot/telemetry/telemetryConstants";
import { COPILOT_UNAVAILABLE } from "../copilot/constants";
import { ITelemetry } from "../../client/telemetry/ITelemetry";
import { sendTelemetryEvent } from "../copilot/telemetry/copilotTelemetry";
import { CopilotArtemisFailureEvent, CopilotArtemisSuccessEvent } from "../copilot/telemetry/telemetryConstants";
import { getCrossGeoCopilotDataMovementEnabledFlag } from "./BAPService";
import { BAPServiceStamp as BAPAPIEndpointStamp } from "./Constants";
import { IArtemisAPIOrgResponse, IArtemisServiceEndpointInformation, IIntelligenceAPIEndpointInformation } from "./Interfaces";
import { isCopilotDisabledInGeo, isCopilotSupportedInGeo } from "./copilot/utils/copilotUtil";
import { isCopilotDisabledInGeo, isCopilotSupportedInGeo } from "../copilot/utils/copilotUtil";

export async function getIntelligenceEndpoint(orgId: string, telemetry: ITelemetry, sessionID: string, environmentId: string): Promise<IIntelligenceAPIEndpointInformation> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/

import * as vscode from "vscode";
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 { 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 "../utilities/Utils";
import {
VSCODE_EXTENSION_DATAVERSE_AUTHENTICATION_COMPLETED,
VSCODE_EXTENSION_DATAVERSE_AUTHENTICATION_FAILED,
Expand All @@ -20,7 +20,7 @@ import {
VSCODE_EXTENSION_BAP_SERVICE_AUTHENTICATION_COMPLETED,
VSCODE_EXTENSION_BAP_SERVICE_AUTHENTICATION_FAILED
} from "./TelemetryConstants";
import { ERRORS } from "./ErrorConstants";
import { ERRORS } from "../ErrorConstants";
import { BAP_SERVICE_SCOPE_DEFAULT, INTELLIGENCE_SCOPE_DEFAULT, PROVIDER_ID, SCOPE_OPTION_CONTACTS_READ, SCOPE_OPTION_DEFAULT, SCOPE_OPTION_OFFLINE_ACCESS, SCOPE_OPTION_USERS_READ_BASIC_ALL } from "./Constants";


Expand Down Expand Up @@ -288,5 +288,3 @@ export async function bapServiceAuthentication(

return accessToken;
}


Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { ITelemetry } from "../client/telemetry/ITelemetry";
import { ITelemetry } from "../../client/telemetry/ITelemetry";
import { bapServiceAuthentication, getCommonHeaders } from "./AuthenticationProvider";
import { VSCODE_EXTENSION_GET_CROSS_GEO_DATA_MOVEMENT_ENABLED_FLAG_COMPLETED, VSCODE_EXTENSION_GET_CROSS_GEO_DATA_MOVEMENT_ENABLED_FLAG_FAILED } from "./TelemetryConstants";
import { BAPServiceStamp, BAP_API_VERSION, BAP_SERVICE_COPILOT_CROSS_GEO_FLAG_RELATIVE_URL, BAP_SERVICE_ENDPOINT } from "./Constants";
import { sendTelemetryEvent } from "./copilot/telemetry/copilotTelemetry";
import { sendTelemetryEvent } from "../copilot/telemetry/copilotTelemetry";

export async function getCrossGeoCopilotDataMovementEnabledFlag(serviceEndpointStamp: BAPServiceStamp, telemetry: ITelemetry, environmentId: string): Promise<boolean> {

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f013b3d

Please sign in to comment.