Repository navigation
fix(cli): honor --telemetry=false opt-out - #421
jackie-greenbaum wants to merge 1 commit into
Conversation
|
✅ CLA satisfied. All contributors have signed the current CLA. The |
|
| util.GetStderrWriter = RootCmdStderrWriter | ||
| util.GetStdoutWriter = RootCmdStdoutWriter | ||
| cobra.OnInitialize(initLog, initLogOutput) | ||
| cobra.OnInitialize(initLog, initLogOutput, initTelemetry) |
There was a problem hiding this comment.
Opt-out lacks regression coverage
The fix has no automated test for the behavior it changes, so a later change could silently break the opt-out again. Add a test that executes a child command through Cobra with --telemetry=false and with no telemetry flag. Calling initTelemetry directly would miss the original flag-parsing bug.
Use a test key or an injected constructor: an empty POSTHOG_API_KEY_FOR_CLI makes NewTelemetry disable telemetry in both cases. This is a non-blocking recommendation.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Added automated regression test for the opt-out flag
Telemetry was initialized before Cobra parsed command-line flags, so --telemetry=false incorrectly used the default enabled value. Move telemetry initialization to a Cobra OnInitialize callback so the explicit opt-out is respected. Telemetry remains enabled by default.
Description 📣
Telemetry was initialized before Cobra parsed command-line flags, so --telemetry=false incorrectly used the default enabled value.
Move telemetry initialization to a Cobra OnInitialize callback so the explicit opt-out is respected. Telemetry remains enabled by default.
Type ✨
Tests 🛠️
go test ./packages/cmd/... -vet=off -count=2; all tests passed.Vet was disabled due to pre-existing nonconstant
Msgfformat-stringerrors.
confirmed that
--telemetry=falseis respected.