Skip to content

Commit

Permalink
src/goLanguageServer: enable user survey in stable version.
Browse files Browse the repository at this point in the history
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 #910

Change-Id: I5490620c3c17c6c71de8a9b9cf5e2b6e9a7c6e55
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/275880
Trust: Hyang-Ah Hana Kim <[email protected]>
Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Rebecca Stambler <[email protected]>
  • Loading branch information
hyangah committed Dec 8, 2020
1 parent 4e42d93 commit da0f1c6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ let defaultLanguageProviders: vscode.Disposable[] = [];
// 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();
Expand Down Expand Up @@ -147,7 +143,7 @@ function scheduleGoplsSuggestions(tool: Tool) {
setTimeout(survey, timeDay);

const cfg = buildLanguageServerConfig(getGoConfig());
if (!goplsSurveyOn || !cfg.enabled) {
if (!cfg.enabled) {
return;
}
maybePromptForGoplsSurvey();
Expand Down Expand Up @@ -870,6 +866,9 @@ export const getLatestGoplsVersion = async (tool: Tool) => {
//
// 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;
}
Expand Down Expand Up @@ -1089,8 +1088,8 @@ Would you be willing to fill out a quick survey about your experience with gopls
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;
Expand Down Expand Up @@ -1127,7 +1126,7 @@ function getSurveyConfig(surveyConfigKey = goplsSurveyConfig): SurveyConfig {
}
return value;
});
return cfg;
return cfg || {};
} catch (err) {
console.log(`Error parsing JSON from ${saved}: ${err}`);
return {};
Expand All @@ -1139,9 +1138,12 @@ export async function showSurveyConfig() {
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:
Expand Down

0 comments on commit da0f1c6

Please sign in to comment.