Skip to content

Commit 9bac573

Browse files
committed
Send ssh version info in telemetry
Fixes gitpod-io/gitpod#12477
1 parent 63a4f3c commit 9bac573

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/remoteConnector.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { untildify } from './common/files';
3232
import { ExperimentalSettings, isUserOverrideSetting } from './experiments';
3333
import { ISyncExtension, NoSettingsSyncSession, NoSyncStoreError, parseSyncData, SettingsSync, SyncResource } from './settingsSync';
3434
import { retry } from './common/async';
35+
import { getOpenSSHVersion } from './ssh/sshVersion';
3536

3637
interface SSHConnectionParams {
3738
workspaceId: string;
@@ -791,8 +792,9 @@ export default class RemoteConnector extends Disposable {
791792
const userOverride = isUserOverrideSetting('gitpod.remote.useLocalApp');
792793
let sshDestination: string | undefined;
793794
if (!forceUseLocalApp) {
795+
const openSSHVersion = await getOpenSSHVersion();
794796
try {
795-
this.telemetry.sendRawTelemetryEvent('vscode_desktop_ssh', { kind: 'gateway', status: 'connecting', ...params, gitpodVersion: gitpodVersion.raw, userOverride });
797+
this.telemetry.sendRawTelemetryEvent('vscode_desktop_ssh', { kind: 'gateway', status: 'connecting', ...params, gitpodVersion: gitpodVersion.raw, userOverride, openSSHVersion });
796798

797799
const { destination, password } = await this.getWorkspaceSSHDestination(session.accessToken, params);
798800
sshDestination = destination;
@@ -801,9 +803,9 @@ export default class RemoteConnector extends Disposable {
801803
await this.showSSHPasswordModal(password, params);
802804
}
803805

804-
this.telemetry.sendRawTelemetryEvent('vscode_desktop_ssh', { kind: 'gateway', status: 'connected', ...params, gitpodVersion: gitpodVersion.raw, auth: password ? 'password' : 'key', userOverride });
806+
this.telemetry.sendRawTelemetryEvent('vscode_desktop_ssh', { kind: 'gateway', status: 'connected', ...params, gitpodVersion: gitpodVersion.raw, auth: password ? 'password' : 'key', userOverride, openSSHVersion});
805807
} catch (e) {
806-
this.telemetry.sendRawTelemetryEvent('vscode_desktop_ssh', { kind: 'gateway', status: 'failed', reason: e.toString(), ...params, gitpodVersion: gitpodVersion.raw, userOverride });
808+
this.telemetry.sendRawTelemetryEvent('vscode_desktop_ssh', { kind: 'gateway', status: 'failed', reason: e.toString(), ...params, gitpodVersion: gitpodVersion.raw, userOverride, openSSHVersion});
807809
if (e instanceof NoSSHGatewayError) {
808810
this.logger.error('No SSH gateway:', e);
809811
vscode.window.showWarningMessage(`${e.host} does not support [direct SSH access](https://github.com/gitpod-io/gitpod/blob/main/install/installer/docs/workspace-ssh-access.md), connecting via the deprecated SSH tunnel over WebSocket.`);

src/ssh/sshVersion.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Gitpod. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as cp from 'child_process';
7+
import * as util from 'util';
8+
import * as vscode from 'vscode';
9+
10+
const exec = util.promisify(cp.exec);
11+
12+
let version: string | undefined;
13+
export async function getOpenSSHVersion(): Promise<string | undefined> {
14+
if (version) {
15+
return version;
16+
}
17+
18+
try {
19+
const sshPath = vscode.workspace.getConfiguration('remote.SSH').get<string>('path');
20+
const { stdout, stderr } = await exec(`${sshPath || 'ssh'} -V`, { timeout: 3000 });
21+
const match = /\bOpenSSH[A-Za-z0-9_\-\.]+\b/.exec(stderr.trim() || stdout.trim());
22+
if (match) {
23+
version = match[0];
24+
return version;
25+
}
26+
} catch {
27+
}
28+
return undefined;
29+
}

0 commit comments

Comments
 (0)