src/goLanguageServer: enable user survey in stable version.

And, add gopls version and extension id to survey link to distinguish
results from nightly and stable extensions.

Adjust "showSurveyConfig' behavior for easier survey testing.
'Yes' try to prompt for survey, while 'Maybe' will try to run
the survey prompt config update (which maybe results in prompting
for survey).

Fixes golang/vscode-go#910

Change-Id: I5490620c3c17c6c71de8a9b9cf5e2b6e9a7c6e55
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/275880
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts
index 965544b..285c681 100644
--- a/src/goLanguageServer.ts
+++ b/src/goLanguageServer.ts
@@ -91,10 +91,6 @@
 // server.
 let restartCommand: vscode.Disposable;
 
-// When enabled, users may be prompted to fill out the gopls survey.
-// For now, we turn it on in the Nightly extension to test it.
-const goplsSurveyOn: boolean = isNightly();
-
 // lastUserAction is the time of the last user-triggered change.
 // A user-triggered change is a didOpen, didChange, didSave, or didClose event.
 let lastUserAction: Date = new Date();
@@ -147,7 +143,7 @@
 		setTimeout(survey, timeDay);
 
 		const cfg = buildLanguageServerConfig(getGoConfig());
-		if (!goplsSurveyOn || !cfg.enabled) {
+		if (!cfg.enabled) {
 			return;
 		}
 		maybePromptForGoplsSurvey();
@@ -870,6 +866,9 @@
 //
 // If this command has already been executed, it returns the saved result.
 export const getLocalGoplsVersion = async (cfg: LanguageServerConfig) => {
+	if (!cfg) {
+		return null;
+	}
 	if (cfg.version !== '') {
 		return cfg.version;
 	}
@@ -1089,8 +1088,8 @@
 		case 'Yes':
 			cfg.lastDateAccepted = now;
 			cfg.prompt = true;
-
-			await vscode.env.openExternal(vscode.Uri.parse(`https://google.qualtrics.com/jfe/form/SV_ekAdHVcVcvKUojX`));
+			const usersGoplsVersion = await getLocalGoplsVersion(latestConfig);
+			await vscode.env.openExternal(vscode.Uri.parse(`https://google.qualtrics.com/jfe/form/SV_ekAdHVcVcvKUojX?gopls=${usersGoplsVersion}&extid=${extensionId}`));
 			break;
 		case 'Not now':
 			cfg.prompt = true;
@@ -1127,7 +1126,7 @@
 			}
 			return value;
 		});
-		return cfg;
+		return cfg || {};
 	} catch (err) {
 		console.log(`Error parsing JSON from ${saved}: ${err}`);
 		return {};
@@ -1139,9 +1138,12 @@
 	outputChannel.appendLine(JSON.stringify(getSurveyConfig(), null, 2));
 	outputChannel.show();
 
-	const selected = await vscode.window.showInformationMessage(`Maybe prompt for survey?`, 'Yes', 'No');
+	const selected = await vscode.window.showInformationMessage(`Prompt for survey?`, 'Yes', 'Maybe', 'No');
 	switch (selected) {
 		case 'Yes':
+			promptForSurvey(getSurveyConfig(), new Date());
+			break;
+		case 'Maybe':
 			maybePromptForGoplsSurvey();
 			break;
 		default: