From f69bc30cef71ce1c44f534996d3c15064d4d45a4 Mon Sep 17 00:00:00 2001 From: wnvko Date: Mon, 20 Aug 2018 10:34:34 +0300 Subject: [PATCH] fix: Skip sending 'Back' user choice to GA, closes #345 --- lib/PromptSession.ts | 56 +++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/PromptSession.ts b/lib/PromptSession.ts index 8b1fb66e5..e8fe1a840 100644 --- a/lib/PromptSession.ts +++ b/lib/PromptSession.ts @@ -1,5 +1,4 @@ import * as inquirer from "inquirer"; -import * as path from "path"; import { default as add } from "./commands/add"; import { default as start } from "./commands/start"; import { GoogleAnalytics } from "./GoogleAnalytics"; @@ -116,29 +115,29 @@ export class PromptSession { break; } case "Complete & Run": - const config = ProjectConfig.getConfig(); - const defaultPort = config.project.defaultPort; - let port; - let userPort: boolean; - while (!userPort) { - // tslint:disable-next-line:prefer-const - port = (await inquirer.prompt({ - default: defaultPort, - message: "Choose app host port:", - name: "port", - type: "input" - }))["port"]; - - if (!Number(port)) { - Util.log(`port should be a number. Input valid port or use the suggested default port`, "yellow"); - } else { - userPort = true; + const config = ProjectConfig.getConfig(); + const defaultPort = config.project.defaultPort; + let port; + let userPort: boolean; + while (!userPort) { + // tslint:disable-next-line:prefer-const + port = (await inquirer.prompt({ + default: defaultPort, + message: "Choose app host port:", + name: "port", + type: "input" + }))["port"]; + + if (!Number(port)) { + Util.log(`port should be a number. Input valid port or use the suggested default port`, "yellow"); + } else { + userPort = true; + } } - } default: { await PackageManager.flushQueue(true); if (true) { // TODO: Make conditional? - await start.start({port}); + await start.start({ port }); return; } } @@ -375,13 +374,16 @@ export class PromptSession { const result = userInput[options.name] as string; - GoogleAnalytics.post({ - cd1: result, - ea: `${options.name}: ${result}`, - ec: "$ig wizard", - el: options.message, - t: "event" - }); + // post to GA everything but 'Back' user choice + if (!withBackChoice || result !== this.WIZARD_BACK_OPTION) { + GoogleAnalytics.post({ + cd1: result, + ea: `${options.name}: ${result}`, + ec: "$ig wizard", + el: options.message, + t: "event" + }); + } return result; }