diff --git a/src/common/copilot/PowerPagesCopilot.ts b/src/common/copilot/PowerPagesCopilot.ts index fbee6034..016903c3 100644 --- a/src/common/copilot/PowerPagesCopilot.ts +++ b/src/common/copilot/PowerPagesCopilot.ts @@ -15,7 +15,7 @@ import { IActiveFileParams, IActiveFileData, IOrgInfo } from './model'; import { escapeDollarSign, getLastThreePartsOfFileName, getNonce, getSelectedCode, getSelectedCodeLineRange, getUserName, openWalkthrough, showConnectedOrgMessage, showInputBoxAndGetOrgUrl, showProgressWithNotification } from "../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 } from "./telemetry/telemetryConstants"; +import { CopilotWalkthroughEvent, CopilotCopyCodeToClipboardEvent, CopilotInsertCodeToEditorEvent, CopilotLoadedEvent, CopilotOrgChangedEvent, CopilotUserFeedbackThumbsDownEvent, CopilotUserFeedbackThumbsUpEvent, CopilotUserPromptedEvent, CopilotCodeLineCountEvent, CopilotClearChatEvent, CopilotNotAvailable, CopilotExplainCode, CopilotExplainCodeSize, CopilotNotAvailableECSConfig } from "./telemetry/telemetryConstants"; import { sendTelemetryEvent } from "./telemetry/copilotTelemetry"; import { INTELLIGENCE_SCOPE_DEFAULT, PROVIDER_ID } from "../../web/client/common/constants"; import { getIntelligenceEndpoint } from "../ArtemisService"; @@ -212,13 +212,11 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { value: copilotStrings }); - console.log("copilot orgs 1", getDisabledOrgList(), orgID, tenantId, getDisabledTenantList()); if (this.aibEndpoint === COPILOT_UNAVAILABLE) { this.sendMessageToWebview({ type: 'Unavailable' }); return; } else if (getDisabledOrgList()?.includes(orgID) || getDisabledTenantList()?.includes(tenantId ?? "")) { - console.log("copilot not available"); - sendTelemetryEvent(this.telemetry, { eventName: CopilotNotAvailable, copilotSessionId: sessionID, orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotNotAvailableECSConfig, copilotSessionId: sessionID, orgId: orgID }); this.sendMessageToWebview({ type: 'Unavailable' }); return; } @@ -412,16 +410,12 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { this.aibEndpoint = intelligenceEndpoint; this.geoName = geoName; - console.log("copilot orgs 2", getDisabledOrgList(), orgID, tenantId, getDisabledTenantList()); if (this.aibEndpoint === COPILOT_UNAVAILABLE) { sendTelemetryEvent(this.telemetry, { eventName: CopilotNotAvailable, copilotSessionId: sessionID, orgId: orgID }); this.sendMessageToWebview({ type: 'Unavailable' }); - return; } else if (getDisabledOrgList()?.includes(orgID) || getDisabledTenantList()?.includes(tenantId ?? "")) { - console.log("copilot not available"); - sendTelemetryEvent(this.telemetry, { eventName: CopilotNotAvailable, copilotSessionId: sessionID, orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotNotAvailableECSConfig, copilotSessionId: sessionID, orgId: orgID }); this.sendMessageToWebview({ type: 'Unavailable' }); - return; } else { this.sendMessageToWebview({ type: 'Available' }); diff --git a/src/common/copilot/utils/copilotUtil.ts b/src/common/copilot/utils/copilotUtil.ts index 50cc70e6..232fba5b 100644 --- a/src/common/copilot/utils/copilotUtil.ts +++ b/src/common/copilot/utils/copilotUtil.ts @@ -3,14 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ +import { ECSFeaturesClient } from "../../ecs-features/ecsFeatureClient"; import { CopilotDisableList } from "../../ecs-features/ecsFeatureGates"; export function getDisabledOrgList() { - console.log("copilot orgs", CopilotDisableList.getConfig().disallowedProDevCopilotOrgs); - return CopilotDisableList.getConfig().disallowedProDevCopilotOrgs?.split(','); + return ECSFeaturesClient.getConfig(CopilotDisableList).disallowedProDevCopilotOrgs?.split(',').map(org => org.trim()); } export function getDisabledTenantList() { - console.log("Copilot tenant", CopilotDisableList.getConfig().disallowedProDevCopilotTenants); - return CopilotDisableList.getConfig().disallowedProDevCopilotTenants?.split(','); + return ECSFeaturesClient.getConfig(CopilotDisableList).disallowedProDevCopilotTenants?.split(',').map(tenant => tenant.trim()); } diff --git a/src/common/ecs-features/ecsFeatureClient.ts b/src/common/ecs-features/ecsFeatureClient.ts index 57b66da8..589aedd4 100644 --- a/src/common/ecs-features/ecsFeatureClient.ts +++ b/src/common/ecs-features/ecsFeatureClient.ts @@ -11,7 +11,6 @@ import { ECSAPIFeatureFlagFilters } from "./ecsFeatureFlagFilters"; export abstract class ECSFeaturesClient { private static _ecsConfig: Record; - private static _featuresConfig = {}; // Initialize ECSFeatureClient - any client config can be fetched with utility function like below // EnableMultifileVscodeWeb.getConfig().enableMultifileVscodeWeb @@ -41,10 +40,7 @@ export abstract class ECSFeaturesClient { public static getConfig, TeamName extends string>( feature: ECSFeatureProperties ) { - if (Object.keys(this._featuresConfig).length === 0) { - this._featuresConfig = this._ecsConfig && feature.extractECSFeatureFlagConfig?.(this._ecsConfig as TConfig); - } - - return Object.keys(this._featuresConfig).length === 0 ? feature.fallback : this._featuresConfig; + const featuresConfig = this._ecsConfig && feature.extractECSFeatureFlagConfig?.(this._ecsConfig as TConfig); + return { ...feature.fallback, ...featuresConfig }; } }