[go: up one dir, main page]

Skip to content

Commit

Permalink
goMain: prompt Go Nightly users with a welcome message and useful links
Browse files Browse the repository at this point in the history
We've created a few groups for Go Nightly users to form a community, so
prompt new users with some links to these resources. They should only
be prompted one time.

Also, update the documentation with some information about the different
groups and ways of providing feedback.

Fixes golang#817

Change-Id: Ibb1c3a3c4745086a552cdbc5bc87d8bf80a834ea
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/266419
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Suzy Mueller <suzmue@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
  • Loading branch information
stamblerre committed Nov 2, 2020
1 parent 99c4f74 commit eca110a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 10 deletions.
12 changes: 10 additions & 2 deletions docs/nightly.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ This master branch of this extension is built and published nightly through the

[Go Nightly] is the **preview** version of the Go extension, so it may be broken or unstable at times. The [Changelog](nightly/CHANGELOG.md) and [README](nightly/README.md) for [Go Nightly] can be found in the [docs/nightly](nightly/) directory.

If you try out [Go Nightly], please file issues when you notice bugs. You can also join the maintainers in the [#vscode-dev](https://gophers.slack.com/archives/CUWGEKH5Z) channel on the [Gophers Slack](https://invite.slack.golangbridge.org/).

## Installation

To use the [Go Nightly] extension (`golang.go-nightly`), you **must** first disable the standard Go extension (`golang.go`). The two are not compatible and will cause conflicts if enabled simultaneously.
Expand All @@ -16,6 +14,14 @@ Otherwise, you can disable it temporarily. To do so, open the Extensions view in

Once you have uninstalled or disabled the standard Go extension, search for [Go Nightly] in the VS Code Marketplace and install it instead.

## Feedback

If you use [Go Nightly], please share your feedback or bug reports by [filing an issue]. You can also speak to the maintainers directly in the [#vscode-dev](https://gophers.slack.com/archives/CUWGEKH5Z) channel on the [Gophers Slack].

### Community

Go Nightly users are encouraged to discuss issues and share feedback in the [#vscode-go-nightly](https://gophers.slack.com/archives/C01DQ2KBMNU) channel on [Gophers Slack] or on the [Go Nightly mailing list](https://groups.google.com/g/vscode-go-nightly). The VS Code Go maintainers may send communications to these channels to request feedback as well.

## Releases

A new version of [Go Nightly], based on the repository's current [`master` branch](https://go.googlesource.com/vscode-go/+/refs/heads/master), will be released at least once a day between Monday and Thursday. If there are no new commits at master, a new version **will not** be released.
Expand All @@ -33,3 +39,5 @@ Pre-releases of the Go extension will be made available on the [Releases page](h
**Note**: If you install an extension from a VSIX file, you will stop receiving automatic prompts when updates are released.

[Go Nightly]: https://marketplace.visualstudio.com/items?itemName=golang.go-nightly
[filing an issue]: https://github.com/golang/vscode-go/issues/new/choose
[Gophers Slack]: https://invite.slack.golangbridge.org/
1 change: 1 addition & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Default:{<br/>
&nbsp;&nbsp;`"options": "json=omitempty"`,<br/>
&nbsp;&nbsp;`"promptForTags": false`,<br/>
&nbsp;&nbsp;`"tags": "json"`,<br/>
&nbsp;&nbsp;`"template": ""`,<br/>
&nbsp;&nbsp;`"transform": "snakecase"`,<br/>
}

Expand Down
14 changes: 10 additions & 4 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ 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 = extensionId === 'golang.go-nightly';
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.
Expand Down Expand Up @@ -757,7 +757,7 @@ export const getTimestampForVersion = async (tool: Tool, version: semver.SemVer)
return time;
};

const acceptGoplsPrerelease = (extensionId === 'golang.go-nightly');
const acceptGoplsPrerelease = isNightly();

export const getLatestGoplsVersion = async (tool: Tool) => {
// If the user has a version of gopls that we understand,
Expand Down Expand Up @@ -983,7 +983,7 @@ export function shouldPromptForGoplsSurvey(now: Date, cfg: SurveyConfig): Survey
// We then randomly pick a day in the rest of the month on which to prompt
// the user.
let probability = 0.01; // lower probability for the regular extension
if (extensionId === 'golang.go-nightly') {
if (isNightly()) {
probability = 0.0275;
}
cfg.promptThisMonth = Math.random() < probability;
Expand All @@ -1000,6 +1000,12 @@ export function shouldPromptForGoplsSurvey(now: Date, cfg: SurveyConfig): Survey
return cfg;
}

// isNightly returns true if the extension ID is the extension ID for the
// Nightly extension.
export function isNightly(): boolean {
return extensionId === 'golang.go-nightly';
}

async function promptForSurvey(cfg: SurveyConfig, now: Date): Promise<SurveyConfig> {
const selected = await vscode.window.showInformationMessage(`Looks like you're using gopls, the Go language server.
Would you be willing to fill out a quick survey about your experience with gopls?`, 'Yes', 'Not now', 'Never');
Expand Down Expand Up @@ -1189,7 +1195,7 @@ function randomIntInRange(min: number, max: number): number {
return Math.floor(Math.random() * (high - low + 1)) + low;
}

const timeMinute = 1000 * 60;
export const timeMinute = 1000 * 60;
const timeHour = timeMinute * 60;
const timeDay = timeHour * 24;

Expand Down
45 changes: 41 additions & 4 deletions src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ import {
updateGoVarsFromConfig
} from './goInstallTools';
import {
isNightly,
languageServerIsRunning,
promptForLanguageServerDefaultChange, resetSurveyConfig, showServerOutputChannel,
showSurveyConfig, startLanguageServerWithFallback,
watchLanguageServerConfiguration
promptForLanguageServerDefaultChange,
resetSurveyConfig,
showServerOutputChannel,
showSurveyConfig,
startLanguageServerWithFallback, timeMinute, watchLanguageServerConfiguration
} from './goLanguageServer';
import { lintCode } from './goLint';
import { logVerbose, setLogConfig } from './goLogging';
Expand Down Expand Up @@ -87,8 +90,12 @@ export function activate(ctx: vscode.ExtensionContext) {
setWorkspaceState(ctx.workspaceState);
setEnvironmentVariableCollection(ctx.environmentVariableCollection);

if (extensionId === 'golang.go-nightly') {
if (isNightly()) {
promptForLanguageServerDefaultChange(cfg);

// For Nightly extension users, show a message directing them to forums
// to give feedback.
setTimeout(showGoNightlyWelcomeMessage, 10 * timeMinute);
}

const configGOROOT = getGoConfig()['goroot'];
Expand Down Expand Up @@ -523,6 +530,36 @@ export function activate(ctx: vscode.ExtensionContext) {
});
}

async function showGoNightlyWelcomeMessage() {
const shown = getFromGlobalState(goNightlyPromptKey, false);
if (shown === true) {
return;
}
const prompt = async () => {
const selected = await vscode.window.showInformationMessage(`Thank you for testing new features by using the Go Nightly extension!
We'd like to welcome you to share feedback and/or join our community of Go Nightly users and developers.`, 'Share feedback', 'Community resources');
switch (selected) {
case 'Share feedback':
await vscode.env.openExternal(vscode.Uri.parse('https://github.com/golang/vscode-go/blob/master/docs/nightly.md#feedback'));
break;
case 'Community resources':
await vscode.env.openExternal(vscode.Uri.parse('https://github.com/golang/vscode-go/blob/master/docs/nightly.md#community'));
break;
default:
return;
}
// Only prompt again if the user clicked one of the buttons.
// They may want to look at the other option.
prompt();
};
prompt();

// Update state to indicate that we've shown this message to the user.
updateGlobalState(goNightlyPromptKey, true);
}

const goNightlyPromptKey = 'goNightlyPrompt';

export function deactivate() {
return Promise.all([
cancelRunningTests(),
Expand Down

0 comments on commit eca110a

Please sign in to comment.