From 89ea096cda1c1430969f3f7b5bdf9aee8dbc3344 Mon Sep 17 00:00:00 2001 From: Emanuele Libralato Date: Mon, 13 Jan 2020 14:23:23 +0100 Subject: [PATCH] fix: force anlytics events queue flush --- garden-service/src/cli/cli.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/garden-service/src/cli/cli.ts b/garden-service/src/cli/cli.ts index 8bcfa2301b..f1b9b8b2e6 100644 --- a/garden-service/src/cli/cli.ts +++ b/garden-service/src/cli/cli.ts @@ -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 { @@ -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) @@ -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()