Skip to content

Commit 1163e5d

Browse files
authored
Remove insight module for now (#771)
This is a quick solution to fix #753
1 parent 1fe6ad1 commit 1163e5d

23 files changed

+188
-812
lines changed

lib/cli.js

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const fs = require('fs');
44
const path = require('path');
55
const chalk = require('chalk');
66
const updateNotifier = require('update-notifier');
7-
const Insight = require('insight');
87
const yosay = require('yosay');
98
const stringLength = require('string-length');
109
const rootCheck = require('root-check');
@@ -51,11 +50,6 @@ const cli = gens.map(gen => {
5150
const firstCmd = cli[0] || {opts: {}, args: {}};
5251
const cmd = firstCmd.args[0];
5352

54-
const insight = new Insight({
55-
trackingCode: 'UA-31537568-1',
56-
pkg
57-
});
58-
5953
function updateCheck() {
6054
const notifier = updateNotifier({pkg});
6155
const message = [];
@@ -173,8 +167,7 @@ function init() {
173167
}
174168

175169
function runYo(env) {
176-
const router = new Router(env, insight);
177-
router.insight.track('yoyo', 'init');
170+
const router = new Router(env);
178171
router.registerRoute('help', require('./routes/help'));
179172
router.registerRoute('update', require('./routes/update'));
180173
router.registerRoute('run', require('./routes/run'));
@@ -191,30 +184,6 @@ function runYo(env) {
191184

192185
rootCheck('\n' + chalk.red('Easy with the `sudo`. Yeoman is the master around here.') + '\n\nSince yo is a user command, there is no need to execute it with root\npermissions. If you\'re having permission errors when using yo without sudo,\nplease spend a few minutes learning more about how your system should work\nand make any necessary repairs.\n\nA quick solution would be to change where npm stores global packages by\nputting ~/npm/bin in your PATH and running:\n' + chalk.blue('npm config set prefix ~/npm') + '\n\nSee: https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md');
193186

194-
const insightMessage = chalk.gray('==========================================================================') +
195-
chalk.yellow('\nWe\'re constantly looking for ways to make ') + chalk.bold.red(pkg.name) +
196-
chalk.yellow(
197-
' better! \nMay we anonymously report usage statistics to improve the tool over time? \n' +
198-
'More info: https://github.com/yeoman/insight & http://yeoman.io'
199-
) +
200-
chalk.gray('\n==========================================================================');
201-
202-
if (firstCmd.opts.insight === false) {
203-
insight.config.set('optOut', true);
204-
} else if (firstCmd.opts.insight) {
205-
insight.config.set('optOut', false);
206-
}
187+
updateCheck();
207188

208-
if (firstCmd.opts.insight !== false && insight.optOut === undefined) {
209-
insight.optOut = insight.config.get('optOut');
210-
insight.track('downloaded');
211-
insight.askPermission(insightMessage, pre);
212-
} else {
213-
if (firstCmd.opts.insight !== false) {
214-
// Only track the two first subcommands
215-
insight.track(...firstCmd.args.slice(0, 2));
216-
}
217-
218-
updateCheck();
219-
pre();
220-
}
189+
pre();

lib/router.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ const {namespaceToName} = require('yeoman-environment');
1111
* The router is in charge of handling `yo` different screens.
1212
* @constructor
1313
* @param {Environment} env A yeoman environment instance
14-
* @param {Insight} insight An insight instance
1514
* @param {Configstore} [conf] An optional config store instance
1615
*/
1716
class Router {
18-
constructor(env, insight, conf) {
17+
constructor(env, conf) {
1918
const pkg = require('../package.json');
2019
this.routes = {};
2120
this.env = env;
22-
this.insight = insight;
2321
this.conf = conf || new Configstore(pkg.name, {
2422
generatorRunCount: {}
2523
});

lib/routes/clear-config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ const {namespaceToName} = require('yeoman-environment');
66
const globalConfig = require('../utils/global-config');
77

88
module.exports = async app => {
9-
app.insight.track('yoyo', 'clearGlobalConfig');
10-
119
const defaultChoices = [
1210
{
1311
name: 'Take me back home, Yo!',
@@ -55,8 +53,6 @@ module.exports = async app => {
5553
defaultChoices
5654
])
5755
}]).then(answer => {
58-
app.insight.track('yoyo', 'clearGlobalConfig', answer);
59-
6056
if (answer.whatNext === 'home') {
6157
return app.navigate('home');
6258
}

lib/routes/exit.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
'use strict';
22
const yosay = require('yosay');
33

4-
module.exports = async app => {
5-
app.insight.track('yoyo', 'exit');
6-
4+
module.exports = async () => {
75
const PADDING = 5;
86
const url = 'http://yeoman.io';
97
const maxLength = url.length + PADDING;

lib/routes/help.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const inquirer = require('inquirer');
33
const open = require('open');
44

55
module.exports = async app => {
6-
app.insight.track('yoyo', 'help');
7-
86
return inquirer.prompt([{
97
name: 'whereTo',
108
type: 'list',
@@ -23,8 +21,6 @@ module.exports = async app => {
2321
value: 'home'
2422
}]
2523
}]).then(async answer => {
26-
app.insight.track('yoyo', 'help', answer);
27-
2824
if (answer.whereTo === 'home') {
2925
console.log('I get it, you like learning on your own. I respect that.');
3026
return app.navigate('home');

lib/routes/home.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ module.exports = async app => {
5252
});
5353
}
5454

55-
app.insight.track('yoyo', 'home');
56-
5755
return fullname().then(name => {
5856
const allo = (name && isString(name)) ? `'Allo ${name.split(' ')[0]}! ` : '\'Allo! ';
5957

lib/routes/install.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ const OFFICIAL_GENERATORS = new Set([
3131
]);
3232

3333
module.exports = app => {
34-
app.insight.track('yoyo', 'install');
35-
3634
return inquirer.prompt([{
3735
name: 'searchTerm',
3836
message: 'Search npm for generators:'
@@ -131,16 +129,11 @@ function promptInstallOptions(app, choices) {
131129
}
132130

133131
function installGenerator(app, pkgName) {
134-
app.insight.track('yoyo', 'install', pkgName);
135-
136132
return spawn('npm', ['install', '--global', pkgName], {stdio: 'inherit'})
137133
.on('error', error => {
138-
app.insight.track('yoyo:err', 'install', pkgName);
139134
throw error;
140135
})
141136
.on('close', () => {
142-
app.insight.track('yoyo', 'installed', pkgName);
143-
144137
console.log(
145138
'\nI just installed a generator by running:\n' +
146139
chalk.blue.bold('\n npm install -g ' + pkgName + '\n')

lib/routes/run.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const {namespaceToName} = require('yeoman-environment');
44

55
module.exports = async (app, name) => {
66
const baseName = namespaceToName(name);
7-
app.insight.track('yoyo', 'run', baseName);
87

98
console.log(
109
chalk.yellow('\nMake sure you are in the directory you want to scaffold into.') +

lib/routes/update.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const successMessage = 'I\'ve just updated your generators. Remember, you can up
77
chalk.magenta('\n npm install -g generator-_______');
88

99
function updateSuccess(app) {
10-
app.insight.track('yoyo', 'updated');
1110
console.log(`\n${chalk.cyan(successMessage)}\n`);
1211
app.env.lookup();
1312
app.updateAvailableGenerators();
@@ -20,8 +19,6 @@ function updateGenerators(app, pkgs) {
2019
}
2120

2221
module.exports = app => {
23-
app.insight.track('yoyo', 'update');
24-
2522
return inquirer.prompt([{
2623
name: 'generators',
2724
message: 'Generators to update',

lib/usage.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ General options:
55
-f, --force # Overwrite files that already exist
66
--version # Print version
77
--no-color # Disable colors
8-
--[no-]insight # Toggle anonymous tracking
98
--generators # Print available generators
109
--local-only # Disable lookup of globally-installed generators
1110

0 commit comments

Comments
 (0)