TrackCommand records a command event using automatic telemetry initialization
(ctx context.Context, action string, args []string)
| 8 | |
| 9 | // TrackCommand records a command event using automatic telemetry initialization |
| 10 | func TrackCommand(ctx context.Context, action string, args []string) { |
| 11 | // Automatically initialize telemetry if not already done |
| 12 | EnsureGlobalTelemetryInitialized(ctx) |
| 13 | |
| 14 | if globalToolTelemetryClient != nil { |
| 15 | commandEvent := CommandEvent{ |
| 16 | Action: action, |
| 17 | Args: args, |
| 18 | Success: true, // We're tracking user intent, not outcome |
| 19 | } |
| 20 | globalToolTelemetryClient.Track(ctx, &commandEvent) |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // TrackCommandError records a command eventerror, send telemetry synchronously to ensure it is sent before the process exits after error |
| 25 | // do nothing if err == nil |