@@ -75,8 +75,11 @@ func (f *debugFlags) loadTeam(ctx context.Context, agentFilename string, opts ..
7575 return t , nil
7676}
7777
78- func (f * debugFlags ) runDebugConfigCommand (cmd * cobra.Command , args []string ) error {
78+ func (f * debugFlags ) runDebugConfigCommand (cmd * cobra.Command , args []string ) ( commandErr error ) {
7979 telemetry .TrackCommand (cmd .Context (), "debug" , append ([]string {"config" }, args ... ))
80+ defer func () { // do not inline this defer so that commandErr is not resolved early
81+ telemetry .TrackCommandError (cmd .Context (), "debug" , append ([]string {"config" }, args ... ), commandErr )
82+ }()
8083
8184 agentSource , err := config .Resolve (args [0 ], f .runConfig .EnvProvider ())
8285 if err != nil {
@@ -91,8 +94,11 @@ func (f *debugFlags) runDebugConfigCommand(cmd *cobra.Command, args []string) er
9194 return yaml .NewEncoder (cmd .OutOrStdout ()).Encode (cfg )
9295}
9396
94- func (f * debugFlags ) runDebugToolsetsCommand (cmd * cobra.Command , args []string ) error {
97+ func (f * debugFlags ) runDebugToolsetsCommand (cmd * cobra.Command , args []string ) ( commandErr error ) {
9598 telemetry .TrackCommand (cmd .Context (), "debug" , append ([]string {"toolsets" }, args ... ))
99+ defer func () { // do not inline this defer so that commandErr is not resolved early
100+ telemetry .TrackCommandError (cmd .Context (), "debug" , append ([]string {"toolsets" }, args ... ), commandErr )
101+ }()
96102
97103 ctx := cmd .Context ()
98104
@@ -131,8 +137,11 @@ func (f *debugFlags) runDebugToolsetsCommand(cmd *cobra.Command, args []string)
131137 return nil
132138}
133139
134- func (f * debugFlags ) runDebugTitleCommand (cmd * cobra.Command , args []string ) error {
140+ func (f * debugFlags ) runDebugTitleCommand (cmd * cobra.Command , args []string ) ( commandErr error ) {
135141 telemetry .TrackCommand (cmd .Context (), "debug" , append ([]string {"title" }, args ... ))
142+ defer func () { // do not inline this defer so that commandErr is not resolved early
143+ telemetry .TrackCommandError (cmd .Context (), "debug" , append ([]string {"title" }, args ... ), commandErr )
144+ }()
136145
137146 ctx := cmd .Context ()
138147
0 commit comments