diff --git a/src/client/extension.ts b/src/client/extension.ts index a97f6c2e..2f023c29 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -187,6 +187,14 @@ export async function activate( _context.subscriptions.push(cli); _context.subscriptions.push(pacTerminal); + let copilotNotificationShown = false; + + const workspaceFolders = + vscode.workspace.workspaceFolders?.map( + (fl) => ({ ...fl, uri: fl.uri.fsPath } as WorkspaceFolder) + ) || []; + + _context.subscriptions.push( orgChangeEvent(async (orgDetails: ActiveOrgOutput) => { const orgID = orgDetails.OrgId; @@ -221,28 +229,32 @@ export async function activate( } oneDSLoggerWrapper.getLogger().traceInfo(desktopTelemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT, initContext); } + + if (!copilotNotificationShown) { + let telemetryData = ''; + let listOfActivePortals = []; + try { + listOfActivePortals = getPortalsOrgURLs(workspaceFolders, _telemetry); + telemetryData = JSON.stringify(listOfActivePortals); + _telemetry.sendTelemetryEvent("VscodeDesktopUsage", { listOfActivePortals: telemetryData, countOfActivePortals: listOfActivePortals.length.toString() }); + oneDSLoggerWrapper.getLogger().traceInfo("VscodeDesktopUsage", { listOfActivePortals: telemetryData, countOfActivePortals: listOfActivePortals.length.toString() }); + } catch (exception) { + const exceptionError = exception as Error; + _telemetry.sendTelemetryException(exceptionError, { eventName: 'VscodeDesktopUsage' }); + oneDSLoggerWrapper.getLogger().traceError(exceptionError.name, exceptionError.message, exceptionError, { eventName: 'VscodeDesktopUsage' }); + } + + // Show Copilot notification after ECS initialization and workspace check + showNotificationForCopilot(_telemetry, telemetryData, listOfActivePortals.length.toString()); + copilotNotificationShown = true; + + } + }) ); - - const workspaceFolders = - vscode.workspace.workspaceFolders?.map( - (fl) => ({ ...fl, uri: fl.uri.fsPath } as WorkspaceFolder) - ) || []; - // TODO: Handle for VSCode.dev also if (workspaceContainsPortalConfigFolder(workspaceFolders)) { - let telemetryData = ''; - let listOfActivePortals = []; - try { - listOfActivePortals = getPortalsOrgURLs(workspaceFolders, _telemetry); - telemetryData = JSON.stringify(listOfActivePortals); - _telemetry.sendTelemetryEvent("VscodeDesktopUsage", { listOfActivePortals: telemetryData, countOfActivePortals: listOfActivePortals.length.toString() }); - oneDSLoggerWrapper.getLogger().traceInfo("VscodeDesktopUsage", { listOfActivePortals: telemetryData, countOfActivePortals: listOfActivePortals.length.toString() }); - } catch (exception) { - const exceptionError = exception as Error; - _telemetry.sendTelemetryException(exceptionError, { eventName: 'VscodeDesktopUsage' }); - oneDSLoggerWrapper.getLogger().traceError(exceptionError.name, exceptionError.message, exceptionError, { eventName: 'VscodeDesktopUsage' }); - } + // Init OrgChangeNotifier instance OrgChangeNotifier.createOrgChangeNotifierInstance(pacTerminal.getWrapper()); @@ -253,7 +265,6 @@ export async function activate( oneDSLoggerWrapper.getLogger().traceInfo("PowerPagesWebsiteYmlExists"); vscode.commands.executeCommand('setContext', 'powerpages.websiteYmlExists', true); initializeGenerator(_context, cliContext, _telemetry); // Showing the create command only if website.yml exists - showNotificationForCopilot(_telemetry, telemetryData, listOfActivePortals.length.toString()); } else { vscode.commands.executeCommand('setContext', 'powerpages.websiteYmlExists', false);