From 805dda86e9f4032ffd5733f3d27210fa8c893b81 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 24 Sep 2024 13:36:12 +0530 Subject: [PATCH 1/3] Refactor OrgChangeNotifier and Copilot Notification --- src/client/extension.ts | 54 ++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/client/extension.ts b/src/client/extension.ts index a97f6c2e..837798b9 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -187,6 +187,17 @@ export async function activate( _context.subscriptions.push(cli); _context.subscriptions.push(pacTerminal); + // Init OrgChangeNotifier instance + OrgChangeNotifier.createOrgChangeNotifierInstance(pacTerminal.getWrapper()); + + 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,30 +232,34 @@ export async function activate( } oneDSLoggerWrapper.getLogger().traceInfo(desktopTelemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT, initContext); } + + if (!copilotNotificationShown) { + 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' }); + } + + // 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()); vscode.workspace.onDidOpenTextDocument(didOpenTextDocument); vscode.workspace.textDocuments.forEach(didOpenTextDocument); @@ -253,7 +268,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); From bac7eed21f26a867bba78cb450b5e212cfda97b4 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Mon, 30 Sep 2024 12:38:59 +0530 Subject: [PATCH 2/3] Refactor OrgChangeNotifier and Copilot Notification --- src/client/extension.ts | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/client/extension.ts b/src/client/extension.ts index 837798b9..15dc7f03 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -187,9 +187,6 @@ export async function activate( _context.subscriptions.push(cli); _context.subscriptions.push(pacTerminal); - // Init OrgChangeNotifier instance - OrgChangeNotifier.createOrgChangeNotifierInstance(pacTerminal.getWrapper()); - let copilotNotificationShown = false; const workspaceFolders = @@ -234,24 +231,23 @@ export async function activate( } if (!copilotNotificationShown) { - 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' }); - } - - // Show Copilot notification after ECS initialization and workspace check - showNotificationForCopilot(_telemetry, telemetryData, listOfActivePortals.length.toString()); - copilotNotificationShown = true; + 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; + } }) @@ -261,6 +257,9 @@ export async function activate( if (workspaceContainsPortalConfigFolder(workspaceFolders)) { + // Init OrgChangeNotifier instance + OrgChangeNotifier.createOrgChangeNotifierInstance(pacTerminal.getWrapper()); + vscode.workspace.onDidOpenTextDocument(didOpenTextDocument); vscode.workspace.textDocuments.forEach(didOpenTextDocument); From 9a3dccc41a6ffbc8c690198a79587a5f9a5f8590 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Mon, 30 Sep 2024 12:45:58 +0530 Subject: [PATCH 3/3] Refactor extension.ts and remove unnecessary lines --- src/client/extension.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/client/extension.ts b/src/client/extension.ts index 15dc7f03..2f023c29 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -253,8 +253,6 @@ export async function activate( }) ); - - if (workspaceContainsPortalConfigFolder(workspaceFolders)) { // Init OrgChangeNotifier instance