Test-only methods - these wrap command execution with telemetry for testing purposes TrackCommand wraps command execution with telemetry (test-only method)
(ctx context.Context, commandInfo CommandInfo, fn func(context.Context) error)
| 270 | |
| 271 | // TrackCommand wraps command execution with telemetry (test-only method) |
| 272 | func (tc *Client) TrackCommand(ctx context.Context, commandInfo CommandInfo, fn func(context.Context) error) error { |
| 273 | if !tc.enabled { |
| 274 | return fn(ctx) |
| 275 | } |
| 276 | |
| 277 | ctx = WithClient(ctx, tc) |
| 278 | |
| 279 | // Send telemetry event immediately (optimistic approach) |
| 280 | commandEvent := CommandEvent{ |
| 281 | Action: commandInfo.Action, |
| 282 | Args: commandInfo.Args, |
| 283 | Success: true, // Assume success - we're tracking user intent, not outcome |
| 284 | } |
| 285 | |
| 286 | // Send the telemetry event immediately |
| 287 | tc.Track(ctx, &commandEvent) |
| 288 | |
| 289 | // Now run the command function |
| 290 | return fn(ctx) |
| 291 | } |
| 292 | |
| 293 | // TrackServerStart immediately sends telemetry for server startup, then runs the server function (test-only method) |
| 294 | // This is for long-running commands that may never exit (api, mcp, etc.) |
no test coverage detected