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>
(cherry picked from commit 944d4e73348ae74b6210ecbc066b8676d536f3a7)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/542156
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/gopls/go.mod b/gopls/go.mod
index 1947b9f..d21c5a8 100644
--- a/gopls/go.mod
+++ b/gopls/go.mod
@@ -7,10 +7,10 @@
 	github.com/jba/printsrc v0.2.2
 	github.com/jba/templatecheck v0.6.0
 	github.com/sergi/go-diff v1.1.0
-	golang.org/x/mod v0.13.0
+	golang.org/x/mod v0.14.0
 	golang.org/x/sync v0.4.0
-	golang.org/x/sys v0.13.0
-	golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052
+	golang.org/x/sys v0.14.0
+	golang.org/x/telemetry v0.0.0-20231114163143-69313e640400
 	golang.org/x/text v0.13.0
 	golang.org/x/tools v0.14.1-0.20231026192422-8b5abd452b28
 	golang.org/x/vuln v1.0.1
diff --git a/gopls/go.sum b/gopls/go.sum
index f638c71..2f3b6e4 100644
--- a/gopls/go.sum
+++ b/gopls/go.sum
@@ -30,15 +30,15 @@
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
 golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
-golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
-golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
+golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
 golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
-golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
-golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052 h1:1baVNneD/IRxmu8JQdBuki78zUqBtZxq8smZXQj0X2Y=
-golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052/go.mod h1:6p4ScoNeC2dhpQ1nSSMmkZ7mEj5JQUSCyc0uExBp5T4=
+golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
+golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/telemetry v0.0.0-20231114163143-69313e640400 h1:brbkEFfGwNGAEkykUOcryE/JiHUMMJouzE0fWWmz/QU=
+golang.org/x/telemetry v0.0.0-20231114163143-69313e640400/go.mod h1:P6hMdmAcoG7FyATwqSr6R/U0n7yeXNP/QXeRlxb1szE=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
 golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
diff --git a/gopls/internal/lsp/prompt.go b/gopls/internal/lsp/prompt.go
index 976f7c6..6a3788f 100644
--- a/gopls/internal/lsp/prompt.go
+++ b/gopls/internal/lsp/prompt.go
@@ -62,7 +62,7 @@
 		if data, err := os.ReadFile(fake); err == nil {
 			return string(data)
 		}
-		return "off"
+		return "local"
 	}
 	return telemetry.Mode()
 }
@@ -95,8 +95,8 @@
 		return // prompt is disabled
 	}
 
-	if s.telemetryMode() == "on" {
-		// Telemetry is already on -- nothing to ask about.
+	if s.telemetryMode() == "on" || s.telemetryMode() == "off" {
+		// Telemetry is already on or explicitly off -- nothing to ask about.
 		return
 	}
 
@@ -262,9 +262,9 @@
 
 To disable telemetry uploading, run %s.
 `
-	var runCmd = "`go run golang.org/x/telemetry/cmd/gotelemetry@latest off`"
+	var runCmd = "`go run golang.org/x/telemetry/cmd/gotelemetry@latest local`"
 	if linkify {
-		runCmd = "[gotelemetry off](https://golang.org/x/telemetry/cmd/gotelemetry)"
+		runCmd = "[gotelemetry local](https://golang.org/x/telemetry/cmd/gotelemetry)"
 	}
 	return fmt.Sprintf(format, runCmd)
 }
diff --git a/gopls/internal/regtest/misc/prompt_test.go b/gopls/internal/regtest/misc/prompt_test.go
index 7a262ad..eba8777 100644
--- a/gopls/internal/regtest/misc/prompt_test.go
+++ b/gopls/internal/regtest/misc/prompt_test.go
@@ -33,7 +33,7 @@
 
 	for _, enabled := range []bool{true, false} {
 		t.Run(fmt.Sprintf("telemetryPrompt=%v", enabled), func(t *testing.T) {
-			for _, initialMode := range []string{"", "off", "on"} {
+			for _, initialMode := range []string{"", "local", "off", "on"} {
 				t.Run(fmt.Sprintf("initial_mode=%s", initialMode), func(t *testing.T) {
 					modeFile := filepath.Join(t.TempDir(), "mode")
 					if initialMode != "" {
@@ -51,7 +51,7 @@
 							"telemetryPrompt": enabled,
 						},
 					).Run(t, src, func(t *testing.T, env *Env) {
-						wantPrompt := enabled && (initialMode == "" || initialMode == "off")
+						wantPrompt := enabled && (initialMode == "" || initialMode == "local")
 						expectation := ShownMessageRequest(".*Would you like to enable Go telemetry?")
 						if !wantPrompt {
 							expectation = Not(expectation)