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 <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Hana (Hyang-Ah) Kim 2024-06-03 11:47:24 -04:00 коммит произвёл Gopher Robot
Родитель 35d7f2837a
Коммит 25699c3720
2 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -256,7 +256,11 @@ func (h *commandHandler) Packages(ctx context.Context, args command.PackagesArgs
} }
func (h *commandHandler) MaybePromptForTelemetry(ctx context.Context) error { 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 return nil
} }

Просмотреть файл

@ -162,6 +162,7 @@ func (s *server) maybePromptForTelemetry(ctx context.Context, enabled bool) {
// v0.17 ~: must have all four fields. // v0.17 ~: must have all four fields.
} else { } else {
state, attempts, creationTime, token = pUnknown, 0, 0, 0 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)) errorf("malformed prompt result %q", string(content))
} }
} else if !os.IsNotExist(err) { } else if !os.IsNotExist(err) {