|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
| 6 | +import { v4 as uuid } from 'uuid'; |
6 | 7 | import { AutoTunnelRequest, ResolveSSHConnectionRequest, ResolveSSHConnectionResponse } from '@gitpod/local-app-api-grpcweb/lib/localapp_pb';
|
7 | 8 | import { LocalAppClient } from '@gitpod/local-app-api-grpcweb/lib/localapp_pb_service';
|
8 | 9 | import { NodeHttpTransport } from '@improbable-eng/grpc-web-node-http-transport';
|
@@ -970,48 +971,84 @@ export default class RemoteConnector extends Disposable {
|
970 | 971 | }
|
971 | 972 | }
|
972 | 973 |
|
973 |
| - private async initializeRemoteExtensions(flow: UserFlowTelemetry) { |
| 974 | + private async initializeRemoteExtensions(flow: UserFlowTelemetry & { quiet: boolean, flowId: string }) { |
| 975 | + this.telemetry.sendUserFlowStatus('enabled', flow); |
974 | 976 | let syncData: { ref: string; content: string } | undefined;
|
975 | 977 | try {
|
976 | 978 | syncData = await this.settingsSync.readResource(SyncResource.Extensions);
|
977 | 979 | } catch (e) {
|
978 | 980 | if (e instanceof NoSyncStoreError) {
|
979 |
| - const addSyncProvider = 'Settings Sync: Enable Sign In with Gitpod'; |
980 |
| - const action = await this.notifications.showInformationMessage(`Could not install local extensions on remote workspace. Please enable [Settings Sync](https://www.gitpod.io/docs/ides-and-editors/settings-sync#enabling-settings-sync-in-vs-code-desktop) with Gitpod.`, { flow, id: 'no_sync_store' }, addSyncProvider); |
981 |
| - if (action === addSyncProvider) { |
982 |
| - vscode.commands.executeCommand('gitpod.syncProvider.add'); |
| 981 | + const msg = `Could not install local extensions on remote workspace. Please enable [Settings Sync](https://www.gitpod.io/docs/ides-and-editors/settings-sync#enabling-settings-sync-in-vs-code-desktop) with Gitpod.`; |
| 982 | + this.logger.error(msg); |
| 983 | + |
| 984 | + const status = 'no_sync_store'; |
| 985 | + if (flow.quiet) { |
| 986 | + this.telemetry.sendUserFlowStatus(status, flow); |
| 987 | + } else { |
| 988 | + const addSyncProvider = 'Settings Sync: Enable Sign In with Gitpod'; |
| 989 | + const action = await this.notifications.showInformationMessage(msg, { flow, id: status }, addSyncProvider); |
| 990 | + if (action === addSyncProvider) { |
| 991 | + vscode.commands.executeCommand('gitpod.syncProvider.add'); |
| 992 | + } |
983 | 993 | }
|
984 | 994 | } else if (e instanceof NoSettingsSyncSession) {
|
985 |
| - const enableSettingsSync = 'Enable Settings Sync'; |
986 |
| - const action = await this.notifications.showInformationMessage(`Could not install local extensions on remote workspace. Please enable [Settings Sync](https://www.gitpod.io/docs/ides-and-editors/settings-sync#enabling-settings-sync-in-vs-code-desktop).`, { flow, id: 'no_settings_sync' }, enableSettingsSync); |
987 |
| - if (action === enableSettingsSync) { |
988 |
| - vscode.commands.executeCommand('workbench.userDataSync.actions.turnOn'); |
| 995 | + const msg = `Could not install local extensions on remote workspace. Please enable [Settings Sync](https://www.gitpod.io/docs/ides-and-editors/settings-sync#enabling-settings-sync-in-vs-code-desktop) with Gitpod.`; |
| 996 | + this.logger.error(msg); |
| 997 | + |
| 998 | + const status = 'no_settings_sync'; |
| 999 | + if (flow.quiet) { |
| 1000 | + this.telemetry.sendUserFlowStatus(status, flow); |
| 1001 | + } else { |
| 1002 | + const enableSettingsSync = 'Enable Settings Sync'; |
| 1003 | + const action = await this.notifications.showInformationMessage(msg, { flow, id: status }, enableSettingsSync); |
| 1004 | + if (action === enableSettingsSync) { |
| 1005 | + vscode.commands.executeCommand('workbench.userDataSync.actions.turnOn'); |
| 1006 | + } |
989 | 1007 | }
|
990 | 1008 | } else {
|
991 | 1009 | this.logger.error('Error while fetching settings sync extension data:', e);
|
992 | 1010 |
|
993 |
| - const seeLogs = 'See Logs'; |
994 |
| - const action = await this.notifications.showErrorMessage(`Error while fetching settings sync extension data.`, { flow, id: 'failed_to_fetch' }, seeLogs); |
995 |
| - if (action === seeLogs) { |
996 |
| - this.logger.show(); |
| 1011 | + const status = 'failed_to_fetch'; |
| 1012 | + if (flow.quiet) { |
| 1013 | + this.telemetry.sendUserFlowStatus(status, flow); |
| 1014 | + } else { |
| 1015 | + const seeLogs = 'See Logs'; |
| 1016 | + const action = await this.notifications.showErrorMessage(`Error while fetching settings sync extension data.`, { flow, id: status }, seeLogs); |
| 1017 | + if (action === seeLogs) { |
| 1018 | + this.logger.show(); |
| 1019 | + } |
997 | 1020 | }
|
998 | 1021 | }
|
999 | 1022 | return;
|
1000 | 1023 | }
|
1001 | 1024 |
|
1002 | 1025 | const syncDataContent = parseSyncData(syncData.content);
|
1003 | 1026 | if (!syncDataContent) {
|
1004 |
| - this.telemetry.sendUserFlowStatus('failed_to_parse_content', flow); |
1005 |
| - this.logger.error('Error while parsing sync data'); |
| 1027 | + const msg = `Error while parsing settings sync extension data.`; |
| 1028 | + this.logger.error(msg); |
| 1029 | + |
| 1030 | + const status = 'failed_to_parse_content'; |
| 1031 | + if (flow.quiet) { |
| 1032 | + this.telemetry.sendUserFlowStatus(status, flow); |
| 1033 | + } else { |
| 1034 | + await this.notifications.showErrorMessage(msg, { flow, id: status }); |
| 1035 | + } |
1006 | 1036 | return;
|
1007 | 1037 | }
|
1008 | 1038 |
|
1009 | 1039 | let extensions: ISyncExtension[];
|
1010 | 1040 | try {
|
1011 | 1041 | extensions = JSON.parse(syncDataContent.content);
|
1012 | 1042 | } catch {
|
1013 |
| - this.telemetry.sendUserFlowStatus('failed_to_parse_json', flow); |
1014 |
| - this.logger.error('Error while parsing settings sync extension data, malformed json'); |
| 1043 | + const msg = `Error while parsing settings sync extension data, malformed JSON.`; |
| 1044 | + this.logger.error(msg); |
| 1045 | + |
| 1046 | + const status = 'failed_to_parse_json'; |
| 1047 | + if (flow.quiet) { |
| 1048 | + this.telemetry.sendUserFlowStatus(status, flow); |
| 1049 | + } else { |
| 1050 | + await this.notifications.showErrorMessage(msg, { flow, id: status }); |
| 1051 | + } |
1015 | 1052 | return;
|
1016 | 1053 | }
|
1017 | 1054 |
|
@@ -1039,10 +1076,18 @@ export default class RemoteConnector extends Disposable {
|
1039 | 1076 | });
|
1040 | 1077 | this.telemetry.sendUserFlowStatus('synced', flow);
|
1041 | 1078 | } catch {
|
1042 |
| - const seeLogs = 'See Logs'; |
1043 |
| - const action = await this.notifications.showErrorMessage(`Error while installing local extensions on remote.`, { flow, id: 'failed' }, seeLogs); |
1044 |
| - if (action === seeLogs) { |
1045 |
| - this.logger.show(); |
| 1079 | + const msg = `Error while installing local extensions on remote.`; |
| 1080 | + this.logger.error(msg); |
| 1081 | + |
| 1082 | + const status = 'failed'; |
| 1083 | + if (flow.quiet) { |
| 1084 | + this.telemetry.sendUserFlowStatus(status, flow); |
| 1085 | + } else { |
| 1086 | + const seeLogs = 'See Logs'; |
| 1087 | + const action = await this.notifications.showErrorMessage(msg, { flow, id: status }, seeLogs); |
| 1088 | + if (action === seeLogs) { |
| 1089 | + this.logger.show(); |
| 1090 | + } |
1046 | 1091 | }
|
1047 | 1092 | }
|
1048 | 1093 | }
|
@@ -1085,13 +1130,13 @@ export default class RemoteConnector extends Disposable {
|
1085 | 1130 | this.logger.warn(`Local heartbeat not supported in ${connectionInfo.gitpodHost}, using version ${gitpodVersion.raw}`);
|
1086 | 1131 | }
|
1087 | 1132 |
|
1088 |
| - const syncExtensions = (await this.experiments.get<boolean>('gitpod.remote.syncExtensions', session.account.id, { gitpodHost: connectionInfo.gitpodHost }))!; |
1089 |
| - const userOverride = String(isUserOverrideSetting('gitpod.remote.syncExtensions')); |
1090 |
| - const syncExtFlow = { ...connectionInfo, gitpodVersion: gitpodVersion.raw, userId: session.account.id, flow: 'sync_local_extensions', userOverride }; |
1091 |
| - this.telemetry.sendUserFlowStatus(syncExtensions ? 'enabled' : 'disabled', syncExtFlow); |
1092 |
| - if (syncExtensions) { |
1093 |
| - this.initializeRemoteExtensions(syncExtFlow); |
1094 |
| - } |
| 1133 | + const syncExtFlow = { ...connectionInfo, gitpodVersion: gitpodVersion.raw, userId: session.account.id, flow: 'sync_local_extensions' }; |
| 1134 | + this.initializeRemoteExtensions({ ...syncExtFlow, quiet: true, flowId: uuid() }); |
| 1135 | + this.context.subscriptions.push(vscode.commands.registerCommand("gitpod.installLocalExtensions", () => { |
| 1136 | + this.initializeRemoteExtensions({ ...syncExtFlow, quiet: false, flowId: uuid() }); |
| 1137 | + })); |
| 1138 | + |
| 1139 | + vscode.commands.executeCommand('setContext', 'gitpod.inWorkspace', true); |
1095 | 1140 | }
|
1096 | 1141 |
|
1097 | 1142 | public override async dispose(): Promise<void> {
|
|
0 commit comments