From 25699c37208fc2df8528300c9cbcab116a7a3123 Mon Sep 17 00:00:00 2001 From: "Hana (Hyang-Ah) Kim" Date: Mon, 3 Jun 2024 11:47:24 -0400 Subject: [PATCH] internal/server: make MaybePromptForTelemetry no-op For the transition of vscode go extension users who explicitly trigger prompting using the command, make the command no-op if the telemetry prompt setting is already true. For golang/go#67821 Change-Id: I648c5a8e4449eeb15fb28c71879c967975363a79 Reviewed-on: https://go-review.googlesource.com/c/tools/+/589836 Auto-Submit: Hyang-Ah Hana Kim LUCI-TryBot-Result: Go LUCI Reviewed-by: Robert Findley --- gopls/internal/server/command.go | 6 +++++- gopls/internal/server/prompt.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gopls/internal/server/command.go b/gopls/internal/server/command.go index 403eadf0d..2489a9d89 100644 --- a/gopls/internal/server/command.go +++ b/gopls/internal/server/command.go @@ -256,7 +256,11 @@ func (h *commandHandler) Packages(ctx context.Context, args command.PackagesArgs } func (h *commandHandler) MaybePromptForTelemetry(ctx context.Context) error { - go h.s.maybePromptForTelemetry(ctx, true) + // if the server's TelemetryPrompt is true, it's likely the server already + // handled prompting for it. Don't try to prompt again. + if !h.s.options.TelemetryPrompt { + go h.s.maybePromptForTelemetry(ctx, true) + } return nil } diff --git a/gopls/internal/server/prompt.go b/gopls/internal/server/prompt.go index 7eb400cfb..37f591487 100644 --- a/gopls/internal/server/prompt.go +++ b/gopls/internal/server/prompt.go @@ -162,6 +162,7 @@ func (s *server) maybePromptForTelemetry(ctx context.Context, enabled bool) { // v0.17 ~: must have all four fields. } else { state, attempts, creationTime, token = pUnknown, 0, 0, 0 + // TODO(hyangah): why do we want to present this as an error to user? errorf("malformed prompt result %q", string(content)) } } else if !os.IsNotExist(err) {