Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Insight

  • Loading branch information...
commit d55006b33fab78f6e5a7db90cc7e61689d8fb117 1 parent 6fc9b89
@sindresorhus sindresorhus authored
Showing with 38 additions and 6 deletions.
  1. +35 −4 cli/bin/yeoman
  2. +3 −2 cli/package.json
View
39 cli/bin/yeoman
@@ -9,20 +9,45 @@ var _ = require('lodash');
var pkg = require('../package.json');
var findup = require('findup-sync');
var updateNotifier = require('update-notifier');
+var Insight = require('insight');
+var helpScreen = _.template(fs.readFileSync(path.join(__dirname, 'help.txt'), 'utf8'));
var args = process.argv.slice(2);
var flags = nopt({}, {}, process.argv, 2);
var cmd = args[0];
-var helpScreen = _.template(fs.readFileSync(path.join(__dirname, 'help.txt'), 'utf8'));
+var insight = new Insight({
+ trackingCode: 'UA-31537568-1',
+ packageName: pkg.name,
+ packageVersion: pkg.version
+});
+
+/*jshint multistr:true */
+var insightMsg = '\
+=========================================================================='.grey + '\n\
+We\'re constantly looking for ways to make '.yellow + pkg.name.bold.red + ' better! \n\
+May we anonymously report usage statistics to improve the tool over time? \n\
+More info: yeoman.io/insight.html & http://yeoman.io'.yellow + '\n\
+=========================================================================='.grey;
+
+// selective tracking since we don't want to track all the bad grammar
+function track() {
+ if (!process.env.yeoman_test && flags.insight !== false) {
+ // only track the two first subcommands
+ // TODO: Enable this before release
+ // insight.track.apply(insight, args.slice(0, 2));
+ }
+}
function runInit() {
// TODO: Init the specified generator
+ track();
}
function runGrunt() {
var gruntfile = findup('Gruntfile.{js,coffee}', {nocase: true});
var dir = path.resolve(gruntfile, '../node_modules/grunt');
+ track();
require(dir).cli();
}
@@ -32,20 +57,25 @@ function runBower() {
// Should Bower be local dep?
// + users can decide to upgrade whenever
// - one more local dep we have to add to each generator
+ track();
require('bower').commands[cmd].line(process.argv)
.on('error', console.error)
.on('data', console.log);
}
// TODO: Update docs to flag `--no-insight`
-if (!process.env.yeoman_test || flags.insight !== false) {
-
+if (!process.env.yeoman_test && flags.insight !== false && insight.optOut === undefined) {
+ insight.optOut = false;
+ insight.track('downloaded');
+ insight.askPermission(insightMsg);
+ return;
}
// TODO: Update docs to flag `--no-update-notifier`
-if (!process.env.yeoman_test || flags['update-notifier'] !== false) {
+if (!process.env.yeoman_test && flags['update-notifier'] !== false) {
var notifier = updateNotifier({
packagePath: '../package',
+ // TODO: remove before release:
packageName: 'yeoman',
packageVersion: '0.9.3'
});
@@ -65,6 +95,7 @@ if (cmd === '--help') {
switch (cmd) {
case 'help':
+ track();
console.log(helpScreen());
break;
case 'init':
View
5 cli/package.json
@@ -1,6 +1,6 @@
{
"name": "yeoman",
- "version": "0.10.0",
+ "version": "0.10.0pre",
"description": "The Yeoman CLI presents a command line interface for creating, building, maintaining, and shipping a project",
"keywords": [
"front-end",
@@ -38,7 +38,8 @@
"optimist": "~0.3.5",
"lodash": "~0.10.0",
"findup-sync": "~0.1.1",
- "update-notifier": "~0.1.0"
+ "update-notifier": "~0.1.0",
+ "insight": "git://github.com/yeoman/insight.git#224a86af93bb654d70f4e2bac498c27feb3dd8cd"
},
"devDependencies": {
"mocha": "~1.7.3",
Please sign in to comment.
Something went wrong with that request. Please try again.