Skip to content

Commit

Permalink
Loading Copilot Notification Panel Ext. Version Update (#1034)
Browse files Browse the repository at this point in the history
* Loading panel on new update

* refactor: Update COPILOT_NOT_AVAILABLE_MSG with disabled AI features message

---------

Co-authored-by: amitjoshi <[email protected]>
  • Loading branch information
amitjoshi438 and amitjoshi authored Sep 10, 2024
1 parent afc98a2 commit 5db529f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
18 changes: 16 additions & 2 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ 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";
import { desktopTelemetryEventNames } from "../common/OneDSLoggerTelemetry/client/desktopExtensionTelemetryEventNames";
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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
Expand Down
1 change: 1 addition & 0 deletions src/common/copilot/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 17 additions & 2 deletions src/web/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 5db529f

Please sign in to comment.