Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding the exitCode to the command result
Browse files Browse the repository at this point in the history
mkhq committed May 11, 2023

Verified

This commit was signed with the committer’s verified signature.
mkhq Mikael Högqvist Tabor
1 parent c6e8b85 commit 404daa9
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion core/src/analytics/analytics.ts
Original file line number Diff line number Diff line change
@@ -151,6 +151,7 @@ interface CommandResultEvent extends EventBase {
durationMsec: number
result: AnalyticsCommandResult
errors: string[] // list of GardenBaseError types
exitCode?: number
}
}

@@ -590,7 +591,7 @@ export class AnalyticsHandler {
/**
* Track a command result.
*/
trackCommandResult(commandName: string, errors: GardenBaseError[], startTime: Date) {
trackCommandResult(commandName: string, errors: GardenBaseError[], startTime: Date, exitCode?: number) {
const result: AnalyticsCommandResult = errors.length > 0 ? "failure" : "success"

const durationMsec = getDurationMsec(startTime, new Date())
@@ -602,6 +603,7 @@ export class AnalyticsHandler {
durationMsec,
result,
errors: errors.map((e) => e.type),
exitCode,
...this.getBasicAnalyticsProperties(),
},
})
2 changes: 1 addition & 1 deletion core/src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -678,7 +678,7 @@ ${renderCommands(commands)}

const gardenErrors: GardenBaseError[] = errors.map(toGardenError)

analytics?.trackCommandResult(command.getFullName(), gardenErrors, commandStartTime)
analytics?.trackCommandResult(command.getFullName(), gardenErrors, commandStartTime, commandResult.exitCode)

// Flushes the Analytics events queue in case there are some remaining events.
if (analytics) {

0 comments on commit 404daa9

Please sign in to comment.