Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor OrgChangeNotifier and Copilot Notification #1044

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

Expand All @@ -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);
Expand Down
Loading