Skip to content

Commit 944d4e7

Browse files
committed
gopls: upgrade x/telemetry and account for new mode logic
Upgrade x/telemetry to pick up the new (on|off|local) mode logic. In this new schema, when the mode is explicitly "off" we should assume that the user doesn't want to be prompted about enabling telemetry. Update our internal logic and tests accordingly. For golang/go#63832 Change-Id: I7b9c0840c48c680110ffa84c59bce2d5249942dd Reviewed-on: https://go-review.googlesource.com/c/tools/+/542317 Reviewed-by: Peter Weinberger <pjw@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 38fc9a2 commit 944d4e7

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

gopls/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ require (
99
github.com/sergi/go-diff v1.1.0
1010
golang.org/x/mod v0.14.0
1111
golang.org/x/sync v0.5.0
12-
golang.org/x/sys v0.14.0
13-
golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052
12+
golang.org/x/telemetry v0.0.0-20231114163143-69313e640400
1413
golang.org/x/text v0.14.0
1514
golang.org/x/tools v0.13.1-0.20230920233436-f9b8da7b22be
1615
golang.org/x/vuln v1.0.1
@@ -24,6 +23,7 @@ require (
2423
github.com/BurntSushi/toml v1.2.1 // indirect
2524
github.com/google/safehtml v0.1.0 // indirect
2625
golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338 // indirect
26+
golang.org/x/sys v0.14.0 // indirect
2727

2828
)
2929

gopls/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4444
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4545
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
4646
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
47-
golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052 h1:1baVNneD/IRxmu8JQdBuki78zUqBtZxq8smZXQj0X2Y=
48-
golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052/go.mod h1:6p4ScoNeC2dhpQ1nSSMmkZ7mEj5JQUSCyc0uExBp5T4=
47+
golang.org/x/telemetry v0.0.0-20231114163143-69313e640400 h1:brbkEFfGwNGAEkykUOcryE/JiHUMMJouzE0fWWmz/QU=
48+
golang.org/x/telemetry v0.0.0-20231114163143-69313e640400/go.mod h1:P6hMdmAcoG7FyATwqSr6R/U0n7yeXNP/QXeRlxb1szE=
4949
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
5050
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
5151
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

gopls/internal/lsp/prompt.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *server) telemetryMode() string {
6262
if data, err := os.ReadFile(fake); err == nil {
6363
return string(data)
6464
}
65-
return "off"
65+
return "local"
6666
}
6767
return telemetry.Mode()
6868
}
@@ -95,8 +95,8 @@ func (s *server) maybePromptForTelemetry(ctx context.Context, enabled bool) {
9595
return // prompt is disabled
9696
}
9797

98-
if s.telemetryMode() == "on" {
99-
// Telemetry is already on -- nothing to ask about.
98+
if s.telemetryMode() == "on" || s.telemetryMode() == "off" {
99+
// Telemetry is already on or explicitly off -- nothing to ask about.
100100
return
101101
}
102102

@@ -262,9 +262,9 @@ func telemetryOnMessage(linkify bool) string {
262262
263263
To disable telemetry uploading, run %s.
264264
`
265-
var runCmd = "`go run golang.org/x/telemetry/cmd/gotelemetry@latest off`"
265+
var runCmd = "`go run golang.org/x/telemetry/cmd/gotelemetry@latest local`"
266266
if linkify {
267-
runCmd = "[gotelemetry off](https://golang.org/x/telemetry/cmd/gotelemetry)"
267+
runCmd = "[gotelemetry local](https://golang.org/x/telemetry/cmd/gotelemetry)"
268268
}
269269
return fmt.Sprintf(format, runCmd)
270270
}

gopls/internal/regtest/misc/prompt_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func main() {
3333

3434
for _, enabled := range []bool{true, false} {
3535
t.Run(fmt.Sprintf("telemetryPrompt=%v", enabled), func(t *testing.T) {
36-
for _, initialMode := range []string{"", "off", "on"} {
36+
for _, initialMode := range []string{"", "local", "off", "on"} {
3737
t.Run(fmt.Sprintf("initial_mode=%s", initialMode), func(t *testing.T) {
3838
modeFile := filepath.Join(t.TempDir(), "mode")
3939
if initialMode != "" {
@@ -51,7 +51,7 @@ func main() {
5151
"telemetryPrompt": enabled,
5252
},
5353
).Run(t, src, func(t *testing.T, env *Env) {
54-
wantPrompt := enabled && (initialMode == "" || initialMode == "off")
54+
wantPrompt := enabled && (initialMode == "" || initialMode == "local")
5555
expectation := ShownMessageRequest(".*Would you like to enable Go telemetry?")
5656
if !wantPrompt {
5757
expectation = Not(expectation)

0 commit comments

Comments
 (0)