diff --git a/src/client/extension.ts b/src/client/extension.ts index df44d599..b4abbc16 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -33,7 +33,7 @@ import { disposeDiagnostics } from "./power-pages/validationDiagnostics"; 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 { COPILOT_NOTIFICATION_DISABLED, EXTENSION_VERSION_KEY } from "../common/copilot/constants"; import { oneDSLoggerWrapper } from "../common/OneDSLoggerTelemetry/oneDSLoggerWrapper"; import { OrgChangeNotifier, orgChangeEvent } from "./OrgChangeNotifier"; import { ActiveOrgOutput } from "./pac/PacTypes"; @@ -41,7 +41,7 @@ import { desktopTelemetryEventNames } from "../common/OneDSLoggerTelemetry/clien import { ArtemisService } from "../common/services/ArtemisService"; import { workspaceContainsPortalConfigFolder } from "../common/utilities/PathFinderUtil"; import { getPortalsOrgURLs } from "../common/utilities/WorkspaceInfoFinderUtil"; -import { SUCCESS } from "../common/constants"; +import { EXTENSION_ID, SUCCESS } from "../common/constants"; import { AadIdKey } from "../common/OneDSLoggerTelemetry/telemetryConstants"; let client: LanguageClient; @@ -419,6 +419,20 @@ function showNotificationForCopilot(telemetry: TelemetryReporter, telemetryData: return; } + const currentVersion = vscode.extensions.getExtension(EXTENSION_ID)?.packageJSON.version; + const storedVersion = _context.globalState.get(EXTENSION_VERSION_KEY); + + if (!storedVersion || storedVersion !== currentVersion) { + // Show notification panel for the first load or after an update + telemetry.sendTelemetryEvent(CopilotNotificationShown, { listOfOrgs: telemetryData, countOfActivePortals }); + oneDSLoggerWrapper.getLogger().traceInfo(CopilotNotificationShown, { listOfOrgs: telemetryData, countOfActivePortals }); + copilotNotificationPanel(_context, telemetry, telemetryData, countOfActivePortals); + + // Update the stored version to the current version + _context.globalState.update(EXTENSION_VERSION_KEY, currentVersion); + return; + } + const isCopilotNotificationDisabled = _context.globalState.get(COPILOT_NOTIFICATION_DISABLED, false); if (!isCopilotNotificationDisabled) { diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts index 454f07ca..6d4e9e31 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts @@ -34,7 +34,7 @@ export const LIST_PROMPT = vscode.l10n.t('Write JavaScript code to highlight the export const WELCOME_MESSAGE = vscode.l10n.t('Hi! @powerpages can help you write, edit, and even summarize your website code.') export const RESPONSE_AWAITED_MSG = vscode.l10n.t('Working on it...'); export const AUTHENTICATION_FAILED_MSG = vscode.l10n.t('Authentication failed. Please try again.'); -export const COPILOT_NOT_AVAILABLE_MSG = vscode.l10n.t('Copilot is not available. Please contact your administrator.'); +export const COPILOT_NOT_AVAILABLE_MSG = vscode.l10n.t('AI features have been disabled by your organization. Contact your admin for details. [Learn more](https://go.microsoft.com/fwlink/?linkid=2285848)'); export const PAC_AUTH_NOT_FOUND = vscode.l10n.t('Active auth profile is not found or has expired. Please try again.'); export const INVALID_RESPONSE = vscode.l10n.t('Something went wrong. Don’t worry, you can try again.'); export const DISCLAIMER_MESSAGE = vscode.l10n.t('Make sure AI-generated content is accurate and appropriate before using. [Learn more](https://go.microsoft.com/fwlink/?linkid=2240145) | [View terms](https://go.microsoft.com/fwlink/?linkid=2189520)'); diff --git a/src/common/copilot/constants.ts b/src/common/copilot/constants.ts index 2a1b577f..6ff4072a 100644 --- a/src/common/copilot/constants.ts +++ b/src/common/copilot/constants.ts @@ -36,6 +36,7 @@ export const ATTRIBUTE_DATAFIELD_NAME = 'datafieldname'; export const ATTRIBUTE_CLASSID = 'classid'; export const SYSTEFORMS_API_PATH = 'api/data/v9.2/systemforms'; export const COPILOT_IN_POWERPAGES = 'Copilot In Power Pages' +export const EXTENSION_VERSION_KEY = 'extensionVersion'; export type WebViewMessage = { type: string; diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index 73f5fb36..b135a292 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -33,7 +33,7 @@ import { PowerPagesNavigationProvider } from "./webViews/powerPagesNavigationPro 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 { COPILOT_NOTIFICATION_DISABLED, EXTENSION_VERSION_KEY } from "../../common/copilot/constants"; import * as Constants from "./common/constants" import { oneDSLoggerWrapper } from "../../common/OneDSLoggerTelemetry/oneDSLoggerWrapper"; import { GeoNames } from "../../common/OneDSLoggerTelemetry/telemetryConstants"; @@ -44,6 +44,7 @@ import { IPortalWebExtensionInitQueryParametersTelemetryData } from "../../commo import { ArtemisService } from "../../common/services/ArtemisService"; import { showErrorDialog } from "../../common/utilities/errorHandlerUtil"; import { ServiceEndpointCategory } from "../../common/services/Constants"; +import { EXTENSION_ID } from "../../common/constants"; export function activate(context: vscode.ExtensionContext): void { // setup telemetry @@ -623,11 +624,25 @@ function showNotificationForCopilot(context: vscode.ExtensionContext, orgId: str return; } + const currentVersion = vscode.extensions.getExtension(EXTENSION_ID)?.packageJSON.version; + const storedVersion = context.globalState.get(EXTENSION_VERSION_KEY); + + if (!storedVersion || storedVersion !== currentVersion) { + // Show notification panel for the first load or after an update + WebExtensionContext.telemetry.sendInfoTelemetry(webExtensionTelemetryEventNames.WEB_EXTENSION_WEB_COPILOT_NOTIFICATION_SHOWN, + { orgId: orgId }); + const telemetryData = JSON.stringify({ orgId: orgId }); + copilotNotificationPanel(context, WebExtensionContext.telemetry.getTelemetryReporter(), telemetryData); + + // Update the stored version to the current version + context.globalState.update(EXTENSION_VERSION_KEY, currentVersion); + return; + } + const isCopilotNotificationDisabled = context.globalState.get(COPILOT_NOTIFICATION_DISABLED, false); if (!isCopilotNotificationDisabled) { WebExtensionContext.telemetry.sendInfoTelemetry(webExtensionTelemetryEventNames.WEB_EXTENSION_WEB_COPILOT_NOTIFICATION_SHOWN, { orgId: orgId }); - const telemetryData = JSON.stringify({ orgId: orgId }); copilotNotificationPanel(context, WebExtensionContext.telemetry.getTelemetryReporter(), telemetryData); }