Skip to content

Commit

Permalink
fix: Skip sending 'Back' user choice to GA, closes #345
Browse files Browse the repository at this point in the history
  • Loading branch information
wnvko committed Aug 20, 2018
1 parent d779991 commit f69bc30
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions lib/PromptSession.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f69bc30

Please sign in to comment.