From d8822ae3cc6ecd4ae21f2b05cce719da4b344115 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Thu, 5 Sep 2024 15:01:47 +0530 Subject: [PATCH 1/3] feat: Telemetry event updates --- .../powerpages/PowerPagesChatParticipant.ts | 22 ++++++++++++-- .../PowerPagesChatParticipantConstants.ts | 7 ++++- .../PowerPagesChatParticipantUtils.ts | 3 ++ src/common/copilot/PowerPagesCopilot.ts | 30 +++++++++---------- src/common/copilot/constants.ts | 1 + .../copilot/telemetry/copilotTelemetry.ts | 1 + src/common/ecs-features/ecsFeatureClient.ts | 3 ++ src/common/utilities/Utils.ts | 2 ++ 8 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts index 419cdffe..dd2284a4 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts @@ -12,7 +12,7 @@ import { sendApiRequest } from '../../copilot/IntelligenceApiService'; import { PacWrapper } from '../../../client/pac/PacWrapper'; import { intelligenceAPIAuthentication } from '../../services/AuthenticationProvider'; import { ActiveOrgOutput } from '../../../client/pac/PacTypes'; -import { AUTHENTICATION_FAILED_MSG, COPILOT_NOT_AVAILABLE_MSG, DISCLAIMER_MESSAGE, INVALID_RESPONSE, NO_PROMPT_MESSAGE, PAC_AUTH_INPUT, PAC_AUTH_NOT_FOUND, POWERPAGES_CHAT_PARTICIPANT_ID, RESPONSE_AWAITED_MSG, RESPONSE_SCENARIOS, SKIP_CODES, STATER_PROMPTS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO, WELCOME_MESSAGE, WELCOME_PROMPT } from './PowerPagesChatParticipantConstants'; +import { AUTHENTICATION_FAILED_MSG, COPILOT_NOT_AVAILABLE_MSG, DISCLAIMER_MESSAGE, INVALID_RESPONSE, NO_PROMPT_MESSAGE, PAC_AUTH_INPUT, PAC_AUTH_NOT_FOUND, POWERPAGES_CHAT_PARTICIPANT_ID, RESPONSE_AWAITED_MSG, RESPONSE_SCENARIOS, SKIP_CODES, STATER_PROMPTS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WEBPAGE_RELATED_FILES, VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT, WELCOME_MESSAGE, WELCOME_PROMPT } from './PowerPagesChatParticipantConstants'; import { ORG_DETAILS_KEY, handleOrgChangeSuccess, initializeOrgDetails } from '../../utilities/OrgHandlerUtils'; import { createAndReferenceLocation, getComponentInfo, getEndpoint, provideChatParticipantFollowups, handleChatParticipantFeedback, createErrorResult, createSuccessResult, removeChatVariables } from './PowerPagesChatParticipantUtils'; import { checkCopilotAvailability, fetchRelatedFiles, getActiveEditorContent } from '../../utilities/Utils'; @@ -20,6 +20,7 @@ import { IIntelligenceAPIEndpointInformation } from '../../services/Interfaces'; import { v4 as uuidv4 } from 'uuid'; import { orgChangeErrorEvent, orgChangeEvent } from '../../../client/OrgChangeNotifier'; import { ADX_WEBPAGE, IApiRequestParams, IRelatedFiles } from '../../constants'; +import { oneDSLoggerWrapper } from '../../OneDSLoggerTelemetry/oneDSLoggerWrapper'; export class PowerPagesChatParticipant { private static instance: PowerPagesChatParticipant | null = null; @@ -88,6 +89,7 @@ export class PowerPagesChatParticipant { ): Promise => { try { this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, { sessionId: this.powerPagesAgentSessionId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED, { sessionId: this.powerPagesAgentSessionId }); if (!this.isOrgDetailsInitialized) { stream.progress(PAC_AUTH_INPUT); @@ -98,10 +100,12 @@ export class PowerPagesChatParticipant { if (!this.orgID || !this.environmentID) { this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND, { sessionId: this.powerPagesAgentSessionId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND, { sessionId: this.powerPagesAgentSessionId }); return createErrorResult(PAC_AUTH_NOT_FOUND, RESPONSE_SCENARIOS.PAC_AUTH_NOT_FOUND, ''); } this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, { orgID: this.orgID, environmentID: this.environmentID, sessionId: this.powerPagesAgentSessionId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS, { orgID: this.orgID, environmentID: this.environmentID, sessionId: this.powerPagesAgentSessionId }); const intelligenceApiAuthResponse = await intelligenceAPIAuthentication(this.telemetry, this.powerPagesAgentSessionId, this.orgID, true); @@ -110,6 +114,7 @@ export class PowerPagesChatParticipant { } const intelligenceApiToken = intelligenceApiAuthResponse.accessToken; + const userId = intelligenceApiAuthResponse.userId; const intelligenceAPIEndpointInfo = await getEndpoint(this.orgID, this.environmentID, this.telemetry, this.cachedEndpoint, this.powerPagesAgentSessionId); const copilotAvailabilityStatus = checkCopilotAvailability(intelligenceAPIEndpointInfo.intelligenceEndpoint, this.orgID, this.telemetry, this.powerPagesAgentSessionId); @@ -122,11 +127,18 @@ export class PowerPagesChatParticipant { userPrompt = removeChatVariables(userPrompt); + this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT, {sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT, {sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); + if (userPrompt === WELCOME_PROMPT) { stream.markdown(WELCOME_MESSAGE); + this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT, {sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT, {sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); return createSuccessResult(STATER_PROMPTS, RESPONSE_SCENARIOS.WELCOME_PROMPT, this.orgID); } else if (!userPrompt) { stream.markdown(NO_PROMPT_MESSAGE); + this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT, {sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT, {sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); return createSuccessResult('', RESPONSE_SCENARIOS.NO_PROMPT, this.orgID); } @@ -137,6 +149,8 @@ export class PowerPagesChatParticipant { //TODO: Handle command scenarios } else { if (location) { + this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED, { sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED, { sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); stream.reference(location); } @@ -146,6 +160,8 @@ export class PowerPagesChatParticipant { switch (activeFileParams.dataverseEntity) { case ADX_WEBPAGE: if (activeFileUri) { + this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WEBPAGE_RELATED_FILES, { sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WEBPAGE_RELATED_FILES, { sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); const files = await fetchRelatedFiles(activeFileUri, activeFileParams.dataverseEntity, activeFileParams.fieldType, this.telemetry, this.powerPagesAgentSessionId); relatedFiles.push(...files); } @@ -175,7 +191,8 @@ export class PowerPagesChatParticipant { const scenario = llmResponse.length > 1 ? llmResponse[llmResponse.length - 1] : llmResponse[0].displayText; - this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO, { scenario: scenario, sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID }); + this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO, { scenario: scenario, sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO, { scenario: scenario, sessionId: this.powerPagesAgentSessionId, orgId: this.orgID, environmentId: this.environmentID, userId: userId }); llmResponse.forEach((response: { displayText: string | vscode.MarkdownString; code: string; }) => { if (response.displayText) { @@ -195,6 +212,7 @@ export class PowerPagesChatParticipant { return createSuccessResult('', '', this.orgID); } catch (error) { this.telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR, { sessionId: this.powerPagesAgentSessionId, error: error as string }); + oneDSLoggerWrapper.getLogger().traceError(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR, error as string, error as Error, { sessionId: this.powerPagesAgentSessionId }, {}); return createErrorResult(INVALID_RESPONSE, RESPONSE_SCENARIOS.INVALID_RESPONSE, this.orgID ? this.orgID : ''); } }; diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts index f332dab7..8465f6ee 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts @@ -25,7 +25,7 @@ export const RESPONSE_SCENARIOS = { WEB_API_PROMPT: 'WEB_API_PROMPT', WELCOME_PROMPT: 'WELCOME_PROMPT' }; - + // Localized strings export const EXPLAIN_CODE_PROMPT = vscode.l10n.t('Explain the following code {% include \'Page Copy\'%}'); export const WEB_API_PROMPT = vscode.l10n.t('Write web API code to query active contact records.'); @@ -49,5 +49,10 @@ export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO = 'GitHubPowerPa export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSUP = 'GitHubPowerPagesAgentScenarioFeedbackThumbsUp'; export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSDOWN = 'GitHubPowerPagesAgentScenarioFeedbackThumbsDown'; export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR = 'GitHubPowerPagesAgentError'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WEBPAGE_RELATED_FILES = 'GitHubPowerPagesAgentWebpageRelatedFiles'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED = 'GitHubPowerPagesAgentLocationReferenced'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT = 'GitHubPowerPagesAgentNoPrompt'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT = 'GitHubPowerPagesAgentWelcomePrompt'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT = 'GitHubPowerPagesAgentSuccessfulPrompt'; diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipantUtils.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipantUtils.ts index 74380a74..23ccd9cb 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipantUtils.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipantUtils.ts @@ -6,6 +6,7 @@ import { ADX_ENTITYFORM } from "../../copilot/constants"; import { getEntityColumns, getEntityName, getFormXml } from "../../copilot/dataverseMetadata"; import { IActiveFileParams } from "../../copilot/model"; +import { oneDSLoggerWrapper } from "../../OneDSLoggerTelemetry/oneDSLoggerWrapper"; import { ITelemetry } from "../../OneDSLoggerTelemetry/telemetry/ITelemetry"; import { ArtemisService } from "../../services/ArtemisService"; import { dataverseAuthentication } from "../../services/AuthenticationProvider"; @@ -62,8 +63,10 @@ export function handleChatParticipantFeedback (feedback: vscode.ChatResultFeedba const orgId = feedback.result.metadata?.orgId; if (feedback.kind === 1) { telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSUP, { feedback: feedback.kind.toString(), scenario: scenario, orgId:orgId, sessionId: sessionId }); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSUP, { feedback: feedback.kind.toString(), scenario: scenario, orgId: orgId, sessionId: sessionId }); } else if (feedback.kind === 0) { telemetry.sendTelemetryEvent(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSDOWN, { feedback: feedback.kind.toString(), scenario: scenario, orgId: orgId, sessionId: sessionId}); + oneDSLoggerWrapper.getLogger().traceInfo(VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSDOWN, { feedback: feedback.kind.toString(), scenario: scenario, orgId: orgId, sessionId: sessionId }); } } export function createAndReferenceLocation(activeFileUri: vscode.Uri, startLine: number, endLine: number): vscode.Location { diff --git a/src/common/copilot/PowerPagesCopilot.ts b/src/common/copilot/PowerPagesCopilot.ts index d57b5fa7..e53fe7d5 100644 --- a/src/common/copilot/PowerPagesCopilot.ts +++ b/src/common/copilot/PowerPagesCopilot.ts @@ -10,7 +10,7 @@ import { dataverseAuthentication, getOIDFromToken, intelligenceAPIAuthentication import { v4 as uuidv4 } from 'uuid' import { PacWrapper } from "../../client/pac/PacWrapper"; import { ITelemetry } from "../OneDSLoggerTelemetry/telemetry/ITelemetry"; -import { ADX_ENTITYFORM, ADX_ENTITYLIST, AUTH_CREATE_FAILED, AUTH_CREATE_MESSAGE, AuthProfileNotFound, COPILOT_IN_POWERPAGES, COPILOT_UNAVAILABLE, CopilotStylePathSegments, EXPLAIN_CODE, GITHUB_COPILOT_CHAT_EXT, PowerPagesParticipantPrompt, SELECTED_CODE_INFO, SELECTED_CODE_INFO_ENABLED, THUMBS_DOWN, THUMBS_UP, WebViewMessage, sendIconSvg } from "./constants"; +import { ADX_ENTITYFORM, ADX_ENTITYLIST, AUTH_CREATE_FAILED, AUTH_CREATE_MESSAGE, AuthProfileNotFound, COPILOT_IN_POWERPAGES, COPILOT_UNAVAILABLE, CopilotStylePathSegments, EXPLAIN_CODE, GITHUB_COPILOT_CHAT_EXT, PowerPagesParticipantDocLink, PowerPagesParticipantPrompt, SELECTED_CODE_INFO, SELECTED_CODE_INFO_ENABLED, THUMBS_DOWN, THUMBS_UP, WebViewMessage, sendIconSvg } from "./constants"; 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"; @@ -65,7 +65,7 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { this._disposables.push( vscode.commands.registerCommand("powerpages.copilot.clearConversation", () => { if (userName && orgID) { - sendTelemetryEvent(this.telemetry, { eventName: CopilotClearChatEvent, copilotSessionId: sessionID, orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotClearChatEvent, copilotSessionId: sessionID, orgId: orgID, userId: userID }); this.sendMessageToWebview({ type: "clearConversation" }); sessionID = uuidv4(); } @@ -91,7 +91,7 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { const withinTokenLimit = isWithinTokenLimit(selectedCode, 1000); if (commandType === EXPLAIN_CODE) { const tokenSize = encode(selectedCode).length; - sendTelemetryEvent(this.telemetry, { eventName: CopilotExplainCodeSize, copilotSessionId: sessionID, orgId: orgID, codeLineCount: String(selectedCodeLineRange.end - selectedCodeLineRange.start), tokenSize: String(tokenSize) }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotExplainCodeSize, copilotSessionId: sessionID, orgId: orgID, userId: userID, codeLineCount: String(selectedCodeLineRange.end - selectedCodeLineRange.start), tokenSize: String(tokenSize) }); if (withinTokenLimit === false) { return; } @@ -104,7 +104,7 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { ); this._disposables.push( - vscode.commands.registerCommand("powerpages.copilot.explain", () => { sendTelemetryEvent(this.telemetry, { eventName: CopilotExplainCode, copilotSessionId: sessionID, orgId: orgID }); this.show(); handleSelectionChange(EXPLAIN_CODE) }) + vscode.commands.registerCommand("powerpages.copilot.explain", () => { sendTelemetryEvent(this.telemetry, { eventName: CopilotExplainCode, copilotSessionId: sessionID, orgId: orgID, userId: userID }); this.show(); handleSelectionChange(EXPLAIN_CODE) }) ); } this._disposables.push( @@ -210,12 +210,12 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { this.sendMessageToWebview({ type: 'Unavailable' }); return; } else if (getDisabledOrgList()?.includes(orgID) || getDisabledTenantList()?.includes(tenantId ?? "")) { - sendTelemetryEvent(this.telemetry, { eventName: CopilotNotAvailableECSConfig, copilotSessionId: sessionID, orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotNotAvailableECSConfig, copilotSessionId: sessionID, orgId: orgID, userId: userID }); this.sendMessageToWebview({ type: 'Unavailable' }); return; } - sendTelemetryEvent(this.telemetry, { eventName: CopilotLoadedEvent, copilotSessionId: sessionID, orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotLoadedEvent, copilotSessionId: sessionID, orgId: orgID, userId: userID }); this.sendMessageToWebview({ type: 'env' }); await this.checkAuthentication(); if (orgID && userName) { @@ -233,7 +233,7 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { break; } case "newUserPrompt": { - sendTelemetryEvent(this.telemetry, { eventName: CopilotUserPromptedEvent, copilotSessionId: sessionID, aibEndpoint: this.aibEndpoint ?? '', orgId: orgID, isSuggestedPrompt: String(data.value.isSuggestedPrompt), crossGeoDataMovementEnabledPPACFlag: this.crossGeoDataMovementEnabledPPACFlag }); //TODO: Add active Editor info + sendTelemetryEvent(this.telemetry, { eventName: CopilotUserPromptedEvent, copilotSessionId: sessionID, aibEndpoint: this.aibEndpoint ?? '', orgId: orgID, userId: userID, isSuggestedPrompt: String(data.value.isSuggestedPrompt), crossGeoDataMovementEnabledPPACFlag: this.crossGeoDataMovementEnabledPPACFlag }); //TODO: Add active Editor info orgID ? (async () => { await this.authenticateAndSendAPIRequest(data.value.userPrompt, orgID, this.telemetry); @@ -253,14 +253,14 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { vscode.window.activeTextEditor?.insertSnippet( new vscode.SnippetString(`${escapedSnippet}`) ); - sendTelemetryEvent(this.telemetry, { eventName: CopilotInsertCodeToEditorEvent, copilotSessionId: sessionID, orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotInsertCodeToEditorEvent, copilotSessionId: sessionID, orgId: orgID, userId: userID }); break; } case "copyCodeToClipboard": { vscode.env.clipboard.writeText(data.value); vscode.window.showInformationMessage(vscode.l10n.t('Copied to clipboard!')) - sendTelemetryEvent(this.telemetry, { eventName: CopilotCopyCodeToClipboardEvent, copilotSessionId: sessionID, orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotCopyCodeToClipboardEvent, copilotSessionId: sessionID, orgId: orgID, userId: userID }); break; } case "clearChat": { @@ -275,22 +275,22 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { if (feedbackValue === THUMBS_UP) { - sendTelemetryEvent(this.telemetry, { eventName: CopilotUserFeedbackThumbsUpEvent, copilotSessionId: sessionID, orgId: orgID, subScenario: String(messageScenario) }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotUserFeedbackThumbsUpEvent, copilotSessionId: sessionID, orgId: orgID, userId: userID, subScenario: String(messageScenario) }); CESUserFeedback(this._extensionContext, sessionID, userID, THUMBS_UP, this.telemetry, this.geoName as string, messageScenario, tenantId) } else if (feedbackValue === THUMBS_DOWN) { - sendTelemetryEvent(this.telemetry, { eventName: CopilotUserFeedbackThumbsDownEvent, copilotSessionId: sessionID, orgId: orgID, subScenario: String(messageScenario) }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotUserFeedbackThumbsDownEvent, copilotSessionId: sessionID, orgId: orgID, userId: userID, subScenario: String(messageScenario) }); CESUserFeedback(this._extensionContext, sessionID, userID, THUMBS_DOWN, this.telemetry, this.geoName as string, messageScenario, tenantId) } break; } case "walkthrough": { - sendTelemetryEvent(this.telemetry, { eventName: CopilotWalkthroughEvent, copilotSessionId: sessionID, orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotWalkthroughEvent, copilotSessionId: sessionID, orgId: orgID, userId: userID }); openWalkthrough(this._extensionUri); break; } case "codeLineCount": { - sendTelemetryEvent(this.telemetry, { eventName: CopilotCodeLineCountEvent, copilotSessionId: sessionID, codeLineCount: String(data.value), orgId: orgID }); + sendTelemetryEvent(this.telemetry, { eventName: CopilotCodeLineCountEvent, copilotSessionId: sessionID, codeLineCount: String(data.value), orgId: orgID, userId: userID }); break; } case "openGitHubCopilotLink": { @@ -298,7 +298,7 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { if (vscode.extensions.getExtension(GITHUB_COPILOT_CHAT_EXT)) { vscode.commands.executeCommand('workbench.action.chat.open', PowerPagesParticipantPrompt); } else { - vscode.env.openExternal(vscode.Uri.parse('https://go.microsoft.com/fwlink/?linkid=2276973')); + vscode.env.openExternal(vscode.Uri.parse(PowerPagesParticipantDocLink)); } } } @@ -416,7 +416,7 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { orgID = activeOrg.OrgId; environmentName = activeOrg.FriendlyName; - userID = activeOrg.UserId; + // userID = activeOrg.UserId; activeOrgUrl = activeOrg.OrgUrl; environmentId = activeOrg.EnvironmentId diff --git a/src/common/copilot/constants.ts b/src/common/copilot/constants.ts index 7ca0fcde..2a1b577f 100644 --- a/src/common/copilot/constants.ts +++ b/src/common/copilot/constants.ts @@ -73,6 +73,7 @@ export const ControlClassIdMap = new Map([ export const GITHUB_COPILOT_CHAT_EXT = 'github.copilot-chat'; export const PowerPagesParticipantPrompt = '@powerpages how can you help with coding for my website?' +export const PowerPagesParticipantDocLink = 'https://go.microsoft.com/fwlink/?linkid=2276973'; export const AuthProfileNotFound = [{ displayText: "Active auth profile is not found or has expired. Create an Auth profile to start chatting with Copilot again.", code: '' }]; export const NetworkError = [{ displayText: "There was an issue connecting to the server. Please check your internet connection and try again.", code: '' }]; diff --git a/src/common/copilot/telemetry/copilotTelemetry.ts b/src/common/copilot/telemetry/copilotTelemetry.ts index 65da1cc8..838b2cc2 100644 --- a/src/common/copilot/telemetry/copilotTelemetry.ts +++ b/src/common/copilot/telemetry/copilotTelemetry.ts @@ -29,6 +29,7 @@ export function sendTelemetryEvent(telemetry: ITelemetry, telemetryData: IProDev telemetryDataProperties.tokenSize = telemetryData.tokenSize ? telemetryData.tokenSize : ''; telemetryDataProperties.isSuggestedPrompt = telemetryData.isSuggestedPrompt ? telemetryData.isSuggestedPrompt : ''; telemetryDataProperties.subScenario = telemetryData.subScenario ? telemetryData.subScenario : ''; + telemetryDataProperties.userId = telemetryData.userId ? telemetryData.userId : ''; if (telemetryData.error) { telemetryDataProperties.eventName = telemetryData.eventName; diff --git a/src/common/ecs-features/ecsFeatureClient.ts b/src/common/ecs-features/ecsFeatureClient.ts index 2cae4c8b..38df90b2 100644 --- a/src/common/ecs-features/ecsFeatureClient.ts +++ b/src/common/ecs-features/ecsFeatureClient.ts @@ -9,6 +9,7 @@ import { createECSRequestURL } from "./ecsFeatureUtil"; import { ECSFeatureDefinition as ECSFeatureProperties } from "./ecsFeatureProperties"; import { ECSAPIFeatureFlagFilters } from "./ecsFeatureFlagFilters"; import { ECSConfigFailedInit, ECSConfigSuccessfulInit } from "./ecsTelemetryConstants"; +import { oneDSLoggerWrapper } from "../OneDSLoggerTelemetry/oneDSLoggerWrapper"; export abstract class ECSFeaturesClient { private static _ecsConfig: Record; @@ -33,10 +34,12 @@ export abstract class ECSFeaturesClient { // capture telemetry telemetry.sendTelemetryEvent(ECSConfigSuccessfulInit, { clientName: clientName, configFlagCount: Object.keys(this._ecsConfig).length.toString() }); + oneDSLoggerWrapper.getLogger().traceInfo(ECSConfigSuccessfulInit, { clientName: clientName, configFlagCount: Object.keys(this._ecsConfig).length.toString() }); } catch (error) { const message = (error as Error)?.message; // Log error telemetry.sendTelemetryErrorEvent(ECSConfigFailedInit, { error: message }); + oneDSLoggerWrapper.getLogger().traceError(ECSConfigFailedInit, message, error as Error); } } diff --git a/src/common/utilities/Utils.ts b/src/common/utilities/Utils.ts index 48b22fbb..2555bf91 100644 --- a/src/common/utilities/Utils.ts +++ b/src/common/utilities/Utils.ts @@ -13,6 +13,7 @@ import { sendTelemetryEvent } from "../copilot/telemetry/copilotTelemetry"; import { getDisabledOrgList, getDisabledTenantList } from "../copilot/utils/copilotUtil"; import { CopilotNotAvailable, CopilotNotAvailableECSConfig } from "../copilot/telemetry/telemetryConstants"; import path from "path"; +import { oneDSLoggerWrapper } from "../OneDSLoggerTelemetry/oneDSLoggerWrapper"; export function getSelectedCode(editor: vscode.TextEditor): string { if (!editor) { @@ -285,6 +286,7 @@ export async function fetchRelatedFiles(activeFileUri: vscode.Uri, componentType } catch (error) { const message = (error as Error)?.message; telemetry.sendTelemetryErrorEvent(COPILOT_RELATED_FILES_FETCH_FAILED, { error: message, sessionId: sessionId }); + oneDSLoggerWrapper.getLogger().traceError(COPILOT_RELATED_FILES_FETCH_FAILED, message, error as Error, { sessionId:sessionId }, {}); return []; } } From 0c6df29cfdfaf885813ff3c77af3c69e2159930c Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Mon, 9 Sep 2024 10:37:08 +0530 Subject: [PATCH 2/3] refactor: Remove commented code for PAC USER ID --- src/common/copilot/PowerPagesCopilot.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/copilot/PowerPagesCopilot.ts b/src/common/copilot/PowerPagesCopilot.ts index e53fe7d5..00579965 100644 --- a/src/common/copilot/PowerPagesCopilot.ts +++ b/src/common/copilot/PowerPagesCopilot.ts @@ -416,7 +416,6 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { orgID = activeOrg.OrgId; environmentName = activeOrg.FriendlyName; - // userID = activeOrg.UserId; activeOrgUrl = activeOrg.OrgUrl; environmentId = activeOrg.EnvironmentId From a83530a3765c534680397c97dc054bac40f73cd8 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Mon, 9 Sep 2024 14:52:11 +0530 Subject: [PATCH 3/3] refactor: Update telemetry event names for GitHub Power Pages agent --- .../PowerPagesChatParticipantConstants.ts | 24 +++++++++---------- src/common/constants.ts | 2 +- src/common/utilities/Utils.ts | 6 ++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts index 8465f6ee..454f07ca 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipantConstants.ts @@ -42,17 +42,17 @@ export const NO_PROMPT_MESSAGE = vscode.l10n.t('Hi! Power Pages lets you build s export const PAC_AUTH_INPUT = vscode.l10n.t("Checking for active auth profile..."); // Telemetry Event Names -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED = 'GitHubPowerPagesAgentInvoked'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS = 'GitHubPowerPagesAgentOrgDetails'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND = 'GitHubPowerPagesAgentOrgDetailsNotFound'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO = 'GitHubPowerPagesAgentScenario'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSUP = 'GitHubPowerPagesAgentScenarioFeedbackThumbsUp'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSDOWN = 'GitHubPowerPagesAgentScenarioFeedbackThumbsDown'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR = 'GitHubPowerPagesAgentError'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WEBPAGE_RELATED_FILES = 'GitHubPowerPagesAgentWebpageRelatedFiles'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED = 'GitHubPowerPagesAgentLocationReferenced'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT = 'GitHubPowerPagesAgentNoPrompt'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT = 'GitHubPowerPagesAgentWelcomePrompt'; -export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT = 'GitHubPowerPagesAgentSuccessfulPrompt'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_INVOKED = 'VSCodeExtensionGitHubPowerPagesAgentInvoked'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS = 'VSCodeExtensionGitHubPowerPagesAgentOrgDetails'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ORG_DETAILS_NOT_FOUND = 'VSCodeExtensionGitHubPowerPagesAgentOrgDetailsNotFound'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO = 'VSCodeExtensionGitHubPowerPagesAgentScenario'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSUP = 'VSCodeExtensionGitHubPowerPagesAgentScenarioFeedbackThumbsUp'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SCENARIO_FEEDBACK_THUMBSDOWN = 'VSCodeExtensionGitHubPowerPagesAgentScenarioFeedbackThumbsDown'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_ERROR = 'VSCodeExtensionGitHubPowerPagesAgentError'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WEBPAGE_RELATED_FILES = 'VSCodeExtensionGitHubPowerPagesAgentWebpageRelatedFiles'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_LOCATION_REFERENCED = 'VSCodeExtensionGitHubPowerPagesAgentLocationReferenced'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_NO_PROMPT = 'VSCodeExtensionGitHubPowerPagesAgentNoPrompt'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_WELCOME_PROMPT = 'VSCodeExtensionGitHubPowerPagesAgentWelcomePrompt'; +export const VSCODE_EXTENSION_GITHUB_POWER_PAGES_AGENT_SUCCESSFUL_PROMPT = 'VSCodeExtensionGitHubPowerPagesAgentSuccessfulPrompt'; diff --git a/src/common/constants.ts b/src/common/constants.ts index 94b29a6b..e9984293 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -85,5 +85,5 @@ export interface IApiRequestParams { relatedFiles?: IRelatedFiles[]; } -export const COPILOT_RELATED_FILES_FETCH_FAILED = "CopilotRelatedFilesFetchFailed"; +export const VSCODE_EXTENSION_COPILOT_CONTEXT_RELATED_FILES_FETCH_FAILED = "VSCodeExtensionCopilotContextRelatedFilesFetchFailed"; export const ADX_WEBPAGE = 'adx_webpage' diff --git a/src/common/utilities/Utils.ts b/src/common/utilities/Utils.ts index 2555bf91..86887253 100644 --- a/src/common/utilities/Utils.ts +++ b/src/common/utilities/Utils.ts @@ -4,7 +4,7 @@ */ import * as vscode from "vscode"; -import { componentTypeSchema, COPILOT_RELATED_FILES_FETCH_FAILED, EXTENSION_ID, EXTENSION_NAME, IRelatedFiles, relatedFilesSchema, SETTINGS_EXPERIMENTAL_STORE_NAME } from "../constants"; +import { componentTypeSchema, EXTENSION_ID, EXTENSION_NAME, IRelatedFiles, relatedFilesSchema, SETTINGS_EXPERIMENTAL_STORE_NAME, VSCODE_EXTENSION_COPILOT_CONTEXT_RELATED_FILES_FETCH_FAILED } from "../constants"; import { CUSTOM_TELEMETRY_FOR_POWER_PAGES_SETTING_NAME } from "../OneDSLoggerTelemetry/telemetryConstants"; import { COPILOT_UNAVAILABLE, DataverseEntityNameMap, EntityFieldMap, FieldTypeMap } from "../copilot/constants"; import { IActiveFileData } from "../copilot/model"; @@ -285,8 +285,8 @@ export async function fetchRelatedFiles(activeFileUri: vscode.Uri, componentType return files; } catch (error) { const message = (error as Error)?.message; - telemetry.sendTelemetryErrorEvent(COPILOT_RELATED_FILES_FETCH_FAILED, { error: message, sessionId: sessionId }); - oneDSLoggerWrapper.getLogger().traceError(COPILOT_RELATED_FILES_FETCH_FAILED, message, error as Error, { sessionId:sessionId }, {}); + telemetry.sendTelemetryErrorEvent(VSCODE_EXTENSION_COPILOT_CONTEXT_RELATED_FILES_FETCH_FAILED, { error: message, sessionId: sessionId }); + oneDSLoggerWrapper.getLogger().traceError(VSCODE_EXTENSION_COPILOT_CONTEXT_RELATED_FILES_FETCH_FAILED, message, error as Error, { sessionId:sessionId }, {}); return []; } }