fix: telemetry now blocks until message is acknowledged instead of closing #312
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



The important part of this PR is the new blocking behavior of the telemetry track function. This leverages the analytics SDK's Callback support to wait until the event delivery completes (successfully or not). This avoids the need to close the client in a defer call, which can potentially cause race conditions with a client still resolving DNS.
Copilot summary
This pull request refactors how telemetry is imported and managed throughout the CLI codebase. The main focus is to simplify telemetry usage by removing the intermediate
cli/internal/cmd/telemetrypackage and updating the telemetry implementation to be more robust and testable. Additionally, the telemetry enabling/disabling logic is streamlined, and some error handling and configuration edge cases are addressed.The most important changes include:
Telemetry Import Refactor:
cli/internal/cmd/telemetryare replaced with direct imports ofcli/internal/telemetryacross all command files, simplifying the dependency structure and usage of telemetry utilities. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]Telemetry Implementation Improvements:
telemetrystruct with support for custom clients, HTTP transport, and operation timeouts, improving testability and reliability. A new callback mechanism is introduced to allow blocking until telemetry events are confirmed sent or failed, with proper error handling and timeouts.Command Telemetry Utilities Cleanup:
cli/internal/cmd/telemetry/utils.gofile is deleted, removing the oldTrackCommandhelper and related types/constants.Telemetry Enable/Disable Logic Update:
Configuration Handling:
updateConfigfunction incli/internal/config/config.gonow checks if the config file is set before attempting to read it, preventing errors when no config file is present.These changes collectively improve the maintainability, testability, and reliability of telemetry in the CLI.
🔒 Scanned for secrets using gitleaks 8.28.0