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

Add cloud shell telemetry #945

Merged
merged 2 commits into from
Oct 28, 2024
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
19 changes: 18 additions & 1 deletion src/commands/cloudShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { IActionContext, parseError } from '@microsoft/vscode-azext-utils';
import { callWithTelemetryAndErrorHandling, IActionContext, parseError } from '@microsoft/vscode-azext-utils';
import { exec } from 'child_process';
import * as vscode from 'vscode';
import { ext } from '../extensionVariables';
Expand All @@ -21,9 +21,18 @@ function delay(ms: number) {
interface MaintainCloudShellConnectionOptions {
consoleUri: string;
terminalId: string;
templateUrl?: string;
}

export async function maintainCloudShellConnection(_context: IActionContext, options: MaintainCloudShellConnectionOptions) {

try {
await recordTelemetry({ templateUrl: options.templateUrl });
} catch (e) {
// Don't crash if telemetry fails
ext.outputChannel.error(parseError(e).message);
}

while (true) {
try {
await refreshDevTunnelAccessToken();
Expand Down Expand Up @@ -122,3 +131,11 @@ async function cloudShellSize(consoleUri: string, terminalId: string): Promise<v
ext.outputChannel.error(await sizeResponse.text());
}
}

async function recordTelemetry(options: { templateUrl?: string }) {
await callWithTelemetryAndErrorHandling('vscode-dev-azure.cloudShellConnection', async (context) => {
if (options.templateUrl) {
context.telemetry.properties.templateUrl = options.templateUrl;
}
});
}
Loading