Skip to content

Commit

Permalink
[Power pages Copilo] Updated user prompt telemetry event to include f… (
Browse files Browse the repository at this point in the history
#748)

* [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 <[email protected]>
Co-authored-by: tyaginidhi <[email protected]>

* Action icon buttons code path correction (#747)

---------

Co-authored-by: amitjoshi438 <[email protected]>
Co-authored-by: amitjoshi <[email protected]>
  • Loading branch information
3 people authored Oct 19, 2023
1 parent ad8f0be commit 2ca8722
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/common/copilot/PowerPagesCopilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
10 changes: 5 additions & 5 deletions src/common/copilot/assets/scripts/copilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -517,7 +517,7 @@
vscode.postMessage({ type: "walkthrough" });
}

function processUserInput(input) {
function processUserInput(input, isSuggestedPrompt = false) {
if (apiResponseInProgress) {
return;
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -592,7 +592,7 @@

function handleSuggestionsClick() {
const suggestedPrompt = this.innerText.trim();
processUserInput(suggestedPrompt);
processUserInput(suggestedPrompt, true);
}

chatInput.addEventListener('keydown', handleArrowKeys);
Expand Down
1 change: 1 addition & 0 deletions src/common/copilot/telemetry/ITelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export interface IProDevCopilotTelemetryData {
aibEndpoint?: string,
orgUrl?: string,
tokenSize?: string
isSuggestedPrompt?: string;
}
1 change: 1 addition & 0 deletions src/common/copilot/telemetry/copilotTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/web/client/webViews/powerPagesNavigationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ export class PowerPagesNode extends vscode.TreeItem {

getIconPath(svgFileName: string) {
return {
light: vscode.Uri.joinPath(WebExtensionContext.extensionUri, '..', '..', 'src', 'web', 'client', 'assets', svgFileName),
dark: vscode.Uri.joinPath(WebExtensionContext.extensionUri, '..', '..', 'src', 'web', 'client', 'assets', svgFileName)
light: vscode.Uri.joinPath(WebExtensionContext.extensionUri, 'src', 'web', 'client', 'assets', svgFileName),
dark: vscode.Uri.joinPath(WebExtensionContext.extensionUri, 'src', 'web', 'client', 'assets', svgFileName)
};
}
}
}

0 comments on commit 2ca8722

Please sign in to comment.