From 7d574cd9ec9eaf3d6fa3724bcc8637e64ed7af5e Mon Sep 17 00:00:00 2001 From: amitjoshi438 <54068463+amitjoshi438@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:32:16 +0530 Subject: [PATCH] [Power pages Copilo] Updated user prompt telemetry event to include flag for suggested prompt (#744) * getting info about selected code * showing label for selected lines of code * add flag to disable feature * updated responsiveness * code formatting fix * removed log statement * handles empty selections * passing and showing user selected code to copilot * setting fixed vertical height for user code * removed redundant code * added comment * added const for explainCode msg * sending localized string to copilot webview * gpt-tokenizer integration * user prompt with selected code and 'explain' check * showing context cmd only when copilot registered * update handling of empty snippet * updated when clause * moved code to skip in a const * Added telemetry * flag for suggested prompt and user icon update * suggested telemetry * removed comment --------- Co-authored-by: amitjoshi Co-authored-by: tyaginidhi --- package-lock.json | 4 ++-- src/common/copilot/PowerPagesCopilot.ts | 4 ++-- src/common/copilot/assets/scripts/copilot.js | 10 +++++----- src/common/copilot/telemetry/ITelemetry.ts | 1 + src/common/copilot/telemetry/copilotTelemetry.ts | 1 + 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 77840cfb..8ba39bcf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "powerplatform-vscode", - "version": "1.0.1-dev", + "version": "22.2.22", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "powerplatform-vscode", - "version": "1.0.1-dev", + "version": "22.2.22", "license": "SEE LICENSE IN LICENSE", "dependencies": { "@microsoft/generator-powerpages": "1.21.19", diff --git a/src/common/copilot/PowerPagesCopilot.ts b/src/common/copilot/PowerPagesCopilot.ts index 3f8a76c9..3a110d56 100644 --- a/src/common/copilot/PowerPagesCopilot.ts +++ b/src/common/copilot/PowerPagesCopilot.ts @@ -216,11 +216,11 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { break; } case "newUserPrompt": { - sendTelemetryEvent(this.telemetry, { eventName: CopilotUserPromptedEvent, copilotSessionId: sessionID, aibEndpoint: this.aibEndpoint ?? '', orgId: orgID }); //TODO: Add active Editor info + sendTelemetryEvent(this.telemetry, { eventName: CopilotUserPromptedEvent, copilotSessionId: sessionID, aibEndpoint: this.aibEndpoint ?? '', orgId: orgID, isSuggestedPrompt: String(data.value.isSuggestedPrompt) }); //TODO: Add active Editor info orgID ? (async () => { const { activeFileParams } = this.getActiveEditorContent(); - await this.authenticateAndSendAPIRequest(data.value, activeFileParams, orgID, this.telemetry); + await this.authenticateAndSendAPIRequest(data.value.userPrompt, activeFileParams, orgID, this.telemetry); })() : (() => { this.sendMessageToWebview({ type: 'apiResponse', value: AuthProfileNotFound }); diff --git a/src/common/copilot/assets/scripts/copilot.js b/src/common/copilot/assets/scripts/copilot.js index c521548e..5d24ecb1 100644 --- a/src/common/copilot/assets/scripts/copilot.js +++ b/src/common/copilot/assets/scripts/copilot.js @@ -495,10 +495,10 @@ vscode.postMessage({ type: "login" }); } - function getApiResponse(userPrompt) { + function getApiResponse(userPrompt, isSuggestedPrompt) { apiResponseHandler = handleAPIResponse(); apiResponseHandler.updateThinking("Working on it..."); - vscode.postMessage({ type: "newUserPrompt", value: userPrompt }); + vscode.postMessage({ type: "newUserPrompt", value: {userPrompt: userPrompt, isSuggestedPrompt: isSuggestedPrompt} }); } function insertCode(code) { @@ -517,7 +517,7 @@ vscode.postMessage({ type: "walkthrough" }); } - function processUserInput(input) { + function processUserInput(input, isSuggestedPrompt = false) { if (apiResponseInProgress) { return; } @@ -527,7 +527,7 @@ chatInput.disabled = true; saveInputToHistory(input); apiResponseInProgress = true; - getApiResponse(userPrompt); //TODO: userPrompt object should be passed + getApiResponse(userPrompt, isSuggestedPrompt); chatInput.value = ""; chatInput.focus(); } @@ -592,7 +592,7 @@ function handleSuggestionsClick() { const suggestedPrompt = this.innerText.trim(); - processUserInput(suggestedPrompt); + processUserInput(suggestedPrompt, true); } chatInput.addEventListener('keydown', handleArrowKeys); diff --git a/src/common/copilot/telemetry/ITelemetry.ts b/src/common/copilot/telemetry/ITelemetry.ts index 506c5913..8f69e998 100644 --- a/src/common/copilot/telemetry/ITelemetry.ts +++ b/src/common/copilot/telemetry/ITelemetry.ts @@ -19,4 +19,5 @@ export interface IProDevCopilotTelemetryData { aibEndpoint?: string, orgUrl?: string, tokenSize?: string + isSuggestedPrompt?: string; } diff --git a/src/common/copilot/telemetry/copilotTelemetry.ts b/src/common/copilot/telemetry/copilotTelemetry.ts index af5e328e..219883b7 100644 --- a/src/common/copilot/telemetry/copilotTelemetry.ts +++ b/src/common/copilot/telemetry/copilotTelemetry.ts @@ -26,6 +26,7 @@ export function sendTelemetryEvent(telemetry: ITelemetry, telemetryData: IProDev telemetryDataProperties.dataverseEntity = telemetryData.dataverseEntity ? telemetryData.dataverseEntity : ''; telemetryDataProperties.responseStatus = telemetryData.responseStatus ? telemetryData.responseStatus : ''; telemetryDataProperties.tokenSize = telemetryData.tokenSize ? telemetryData.tokenSize : ''; + telemetryDataProperties.isSuggestedPrompt = telemetryData.isSuggestedPrompt ? telemetryData.isSuggestedPrompt : ''; if (telemetryData.error) { telemetryDataProperties.eventName = telemetryData.eventName;