Skip to content

Commit

Permalink
Refactor telemetry constants and add GitHub Copilot integration and e…
Browse files Browse the repository at this point in the history
…xternal link event (#1045)

Co-authored-by: amitjoshi <[email protected]>
  • Loading branch information
amitjoshi438 and amitjoshi authored Oct 3, 2024
1 parent 7eb4100 commit 87a43b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/common/copilot/PowerPagesCopilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IOrgInfo } from './model';
import { checkCopilotAvailability, escapeDollarSign, getActiveEditorContent, getNonce, getSelectedCode, getSelectedCodeLineRange, getUserName, openWalkthrough, showConnectedOrgMessage, showInputBoxAndGetOrgUrl, showProgressWithNotification } from "../utilities/Utils";
import { CESUserFeedback } from "./user-feedback/CESSurvey";
import { ActiveOrgOutput } from "../../client/pac/PacTypes";
import { CopilotWalkthroughEvent, CopilotCopyCodeToClipboardEvent, CopilotInsertCodeToEditorEvent, CopilotLoadedEvent, CopilotOrgChangedEvent, CopilotUserFeedbackThumbsDownEvent, CopilotUserFeedbackThumbsUpEvent, CopilotUserPromptedEvent, CopilotCodeLineCountEvent, CopilotClearChatEvent, CopilotExplainCode, CopilotExplainCodeSize, CopilotNotAvailableECSConfig, CopilotPanelTryGitHubCopilotClicked } from "./telemetry/telemetryConstants";
import { CopilotWalkthroughEvent, CopilotCopyCodeToClipboardEvent, CopilotInsertCodeToEditorEvent, CopilotLoadedEvent, CopilotOrgChangedEvent, CopilotUserFeedbackThumbsDownEvent, CopilotUserFeedbackThumbsUpEvent, CopilotUserPromptedEvent, CopilotCodeLineCountEvent, CopilotClearChatEvent, CopilotExplainCode, CopilotExplainCodeSize, CopilotNotAvailableECSConfig, CopilotPanelTryGitHubCopilotClicked, VSCodeExtensionGitHubChatPanelOpened, VSCodeExtensionGitHubChatNotFound } from "./telemetry/telemetryConstants";
import { sendTelemetryEvent } from "./telemetry/copilotTelemetry";
import TelemetryReporter from "@vscode/extension-telemetry";
import { getEntityColumns, getEntityName, getFormXml } from "./dataverseMetadata";
Expand Down Expand Up @@ -297,8 +297,10 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider {
//Open the GitHub Copilot Chat with @powerpages if GitHub Copilot Chat is installed
sendTelemetryEvent(this.telemetry, { eventName: CopilotPanelTryGitHubCopilotClicked, copilotSessionId: sessionID, orgId: orgID, userId: userID });
if (vscode.extensions.getExtension(GITHUB_COPILOT_CHAT_EXT)) {
sendTelemetryEvent(this.telemetry, { eventName: VSCodeExtensionGitHubChatPanelOpened, copilotSessionId: sessionID, orgId: orgID, userId: userID });
vscode.commands.executeCommand('workbench.action.chat.open', PowerPagesParticipantPrompt);
} else {
sendTelemetryEvent(this.telemetry, { eventName: VSCodeExtensionGitHubChatNotFound, copilotSessionId: sessionID, orgId: orgID, userId: userID });
vscode.env.openExternal(vscode.Uri.parse(PowerPagesParticipantDocLink));
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/common/copilot/telemetry/telemetryConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ export const CopilotExplainCodeSize = 'CopilotExplainCodeSize';
export const CopilotNpsAuthenticationCompleted = "CopilotNpsAuthenticationCompleted";
export const CopilotNotificationTryGitHubCopilotClicked = 'CopilotNotificationTryGitHubCopilotClicked';
export const CopilotPanelTryGitHubCopilotClicked = 'CopilotPanelTryGitHubCopilotClicked ';
export const VSCodeExtensionGitHubChatPanelOpened = 'VSCodeExtensionGitHubChatPanelOpened';
export const VSCodeExtensionGitHubChatNotFound = 'VSCodeExtensionGitHubChatNotFound';

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from "vscode";
import { getNonce } from "../../utilities/Utils";
import TelemetryReporter from "@vscode/extension-telemetry";
import { CopilotNotificationDoNotShowChecked, CopilotTryNotificationClickedEvent, CopilotNotificationDoNotShowUnchecked, CopilotNotificationTryGitHubCopilotClicked } from "../telemetry/telemetryConstants";
import { CopilotNotificationDoNotShowChecked, CopilotTryNotificationClickedEvent, CopilotNotificationDoNotShowUnchecked, CopilotNotificationTryGitHubCopilotClicked, VSCodeExtensionGitHubChatPanelOpened, VSCodeExtensionGitHubChatNotFound } from "../telemetry/telemetryConstants";
import { COPILOT_IN_POWERPAGES, COPILOT_NOTIFICATION_DISABLED, PowerPagesParticipantDocLink, PowerPagesParticipantPrompt } from "../constants";
import { oneDSLoggerWrapper } from "../../OneDSLoggerTelemetry/oneDSLoggerWrapper";

Expand Down Expand Up @@ -59,8 +59,12 @@ export async function copilotNotificationPanel(context: vscode.ExtensionContext,
telemetry.sendTelemetryEvent(CopilotNotificationTryGitHubCopilotClicked, { listOfOrgs: telemetryData, countOfActivePortals: countOfActivePortals as string });
oneDSLoggerWrapper.getLogger().traceInfo(CopilotNotificationTryGitHubCopilotClicked, { listOfOrgs: telemetryData, countOfActivePortals: countOfActivePortals as string });
if (isGitHubCopilotPresent) {
telemetry.sendTelemetryEvent(VSCodeExtensionGitHubChatPanelOpened, { listOfOrgs: telemetryData, countOfActivePortals: countOfActivePortals as string });
oneDSLoggerWrapper.getLogger().traceInfo(VSCodeExtensionGitHubChatPanelOpened, { listOfOrgs: telemetryData, countOfActivePortals: countOfActivePortals as string });
vscode.commands.executeCommand('workbench.action.chat.open', PowerPagesParticipantPrompt);
} else {
telemetry.sendTelemetryEvent(VSCodeExtensionGitHubChatNotFound, { listOfOrgs: telemetryData, countOfActivePortals: countOfActivePortals as string });
oneDSLoggerWrapper.getLogger().traceInfo(VSCodeExtensionGitHubChatNotFound, { listOfOrgs: telemetryData, countOfActivePortals: countOfActivePortals as string });
vscode.env.openExternal(vscode.Uri.parse(PowerPagesParticipantDocLink));
}
}
Expand Down

0 comments on commit 87a43b3

Please sign in to comment.