@@ -12,21 +12,28 @@ import { IHostService } from './hostService';
1212import SSHConfiguration from '../ssh/sshConfig' ;
1313import { isWindows } from '../common/platform' ;
1414import { getLocalSSHDomain } from '../remote' ;
15- import { ITelemetryService } from './telemetryService' ;
15+ import { ITelemetryService , UserFlowTelemetry } from './telemetryService' ;
16+ import { ISessionService } from './sessionService' ;
17+ import { WrapError } from '../common/utils' ;
1618
1719export interface ILocalSSHService {
20+ flow ?: UserFlowTelemetry ;
1821 isSupportLocalSSH : boolean ;
1922 initialized : Promise < void > ;
2023}
2124
25+ type FailedToInitializeCode = 'Unknown' | string ;
26+
2227export class LocalSSHService extends Disposable implements ILocalSSHService {
2328 public isSupportLocalSSH : boolean = false ;
2429 public initialized : Promise < void > ;
30+ public flow ?: UserFlowTelemetry ;
2531 constructor (
2632 private readonly context : vscode . ExtensionContext ,
2733 private readonly hostService : IHostService ,
2834 private readonly telemetryService : ITelemetryService ,
29- private readonly logService : ILogService
35+ private readonly sessionService : ISessionService ,
36+ private readonly logService : ILogService ,
3037 ) {
3138 super ( ) ;
3239
@@ -53,18 +60,26 @@ export class LocalSSHService extends Disposable implements ILocalSSHService {
5360 }
5461
5562 private async initialize ( ) {
63+ let failureCode : FailedToInitializeCode | undefined ;
64+ const useLocalAPP = String ( Configuration . getUseLocalApp ( ) ) ;
5665 try {
5766 const locations = await this . copyProxyScript ( ) ;
5867 await this . configureSettings ( locations ) ;
5968 this . isSupportLocalSSH = true ;
6069 } catch ( e ) {
61- this . logService . error ( e , 'failed to copy local ssh client.js' ) ;
62- if ( e . message ) {
63- e . message = `Failed to copy local ssh client.js: ${ e . message } ` ;
70+ this . logService . error ( e , 'failed to initialize' ) ;
71+ failureCode = 'Unknown' ;
72+ if ( e ?. code ) {
73+ failureCode = e . code ;
74+ }
75+ if ( e ?. message ) {
76+ e . message = `Failed to initialize: ${ e . message } ` ;
6477 }
65- this . telemetryService . sendTelemetryException ( this . hostService . gitpodHost , e ) ;
78+ this . telemetryService . sendTelemetryException ( this . hostService . gitpodHost , e , { useLocalAPP } ) ;
6679 this . isSupportLocalSSH = false ;
6780 }
81+ const flowData = this . flow ? this . flow : { gitpodHost : this . hostService . gitpodHost , userId : this . sessionService . safeGetUserId ( ) } ;
82+ this . telemetryService . sendUserFlowStatus ( this . isSupportLocalSSH ? 'success' : 'failure' , { ...flowData , flow : 'local_ssh_config' , failureCode, useLocalAPP } ) ;
6883 }
6984
7085 private async configureSettings ( { proxyScript, launcher } : { proxyScript : string ; launcher : string } ) {
@@ -85,14 +100,18 @@ export class LocalSSHService extends Disposable implements ILocalSSHService {
85100 }
86101
87102 private async copyProxyScript ( ) {
88- const [ proxyScript , launcher ] = await Promise . all ( [
89- this . copyFileToGlobalStorage ( 'out/local-ssh/proxy.js' , 'sshproxy/proxy.js' ) ,
90- isWindows ? this . copyFileToGlobalStorage ( 'out/local-ssh/proxylauncher.bat' , 'sshproxy/proxylauncher.bat' ) : this . copyFileToGlobalStorage ( 'out/local-ssh/proxylauncher.sh' , 'sshproxy/proxylauncher.sh' )
91- ] ) ;
92- if ( ! isWindows ) {
93- await fsp . chmod ( launcher , 0o755 ) ;
103+ try {
104+ const [ proxyScript , launcher ] = await Promise . all ( [
105+ this . copyFileToGlobalStorage ( 'out/local-ssh/proxy.js' , 'sshproxy/proxy.js' ) ,
106+ isWindows ? this . copyFileToGlobalStorage ( 'out/local-ssh/proxylauncher.bat' , 'sshproxy/proxylauncher.bat' ) : this . copyFileToGlobalStorage ( 'out/local-ssh/proxylauncher.sh' , 'sshproxy/proxylauncher.sh' )
107+ ] ) ;
108+ if ( ! isWindows ) {
109+ await fsp . chmod ( launcher , 0o755 ) ;
110+ }
111+ return { proxyScript, launcher } ;
112+ } catch ( e ) {
113+ throw new WrapError ( 'Failed to copy local ssh proxy scripts' , e ) ;
94114 }
95- return { proxyScript, launcher } ;
96115 }
97116
98117 private async copyFileToGlobalStorage ( filepath : string , destPath : string ) {
0 commit comments