Skip to content

Conversation

@fxenik
Copy link
Member

@fxenik fxenik commented Dec 2, 2025

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/telemetry package 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:

  • All imports of cli/internal/cmd/telemetry are replaced with direct imports of cli/internal/telemetry across 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:

  • The telemetry system is reimplemented to use a telemetry struct 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.
  • The global logger for analytics is now explicitly initialized and assigned to a variable for clarity.

Command Telemetry Utilities Cleanup:

  • The now-unnecessary cli/internal/cmd/telemetry/utils.go file is deleted, removing the old TrackCommand helper and related types/constants.

Telemetry Enable/Disable Logic Update:

  • The enable/disable commands for telemetry are simplified to directly set the configuration flag, rather than calling helper functions in the telemetry package. [1] [2]

Configuration Handling:

  • The updateConfig function in cli/internal/config/config.go now 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

…osing

🔒 Scanned for secrets using gitleaks 8.28.0
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 2, 2025

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 74.35897% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.02%. Comparing base (a375541) to head (551fdc7).

Files with missing lines Patch % Lines
cli/internal/telemetry/telemetry.go 77.10% 15 Missing and 4 partials ⚠️
cli/internal/telemetry/utils.go 76.66% 4 Missing and 3 partials ⚠️
cli/internal/cmd/telemetry/telemetry.go 0.00% 2 Missing ⚠️
cli/internal/config/config.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #312      +/-   ##
==========================================
+ Coverage   45.48%   46.02%   +0.53%     
==========================================
  Files         179      179              
  Lines       12876    12943      +67     
==========================================
+ Hits         5857     5957     +100     
+ Misses       6484     6443      -41     
- Partials      535      543       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant