Skip to content

Commit

Permalink
fix: force anlytics events queue flush
Browse files Browse the repository at this point in the history
  • Loading branch information
10ko authored and eysi09 committed Jan 13, 2020
1 parent cc151a3 commit 89ea096
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion garden-service/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export interface ParseResults {

interface SywacParseResults extends ParseResults {
output: string
details: { logger: Logger; result?: CommandResult }
details: { logger: Logger; result?: CommandResult; analytics?: AnalyticsHandler }
}

export class GardenCli {
Expand Down Expand Up @@ -324,6 +324,8 @@ export class GardenCli {
const analytics = await AnalyticsHandler.init(garden, log)
analytics.trackCommand(command.getFullName())

cliContext.details.analytics = analytics

// tslint:disable-next-line: no-floating-promises
checkForUpdates(garden.globalConfigStore, headerLog)

Expand Down Expand Up @@ -411,6 +413,12 @@ export class GardenCli {
})
}

// Flushes the Analytics events queue in case there are some remaining events.
const { analytics } = details
if (analytics) {
await analytics.flush()
}

// --help or --version options were called so we log the cli output and exit
if (cliOutput && errors.length < 1) {
logger.stop()
Expand Down

0 comments on commit 89ea096

Please sign in to comment.