Skip to content

Commit

Permalink
fix: send analytics on successful commands
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah committed Feb 9, 2022
1 parent 5d15322 commit 51f37de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ if (require.main === module) {
const program = createMainCommand()

// eslint-disable-next-line promise/prefer-await-to-then
program.parseAsync(process.argv).catch((error_) => program.onEnd(error_))
program
.parseAsync(process.argv)
.then(() => {
program.onEnd()
})
.catch((error_) => program.onEnd(error_))
}
7 changes: 4 additions & 3 deletions src/commands/base-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,14 @@ class BaseCommand extends Command {
const duration = getDuration(startTime)
const status = error_ === undefined ? 'success' : 'error'

debug(`${this.name()}:onEnd`)(`Status: ${status}`)
debug(`${this.name()}:onEnd`)(`Duration: ${duration}ms`)
const command = Array.isArray(this.args) ? this.args[0] : this.name()

debug(`${this.name()}:onEnd`)(`Command: ${command}. Status: ${status}. Duration: ${duration}ms`)

try {
await track('command', {
...payload,
command: this.name(),
command,
duration,
status,
})
Expand Down

0 comments on commit 51f37de

Please sign in to comment.