@@ -5,6 +5,7 @@ import path from 'path';
55import chalk from 'chalk' ;
66import { Base } from 'yeoman-generator' ;
77import { genBase } from '../generator-base' ;
8+ import insight from '../insight-init' ;
89
910export default class Generator extends Base {
1011
@@ -28,13 +29,30 @@ export default class Generator extends Base {
2829
2930 get initializing ( ) {
3031 return {
31-
3232 init : function ( ) {
33+ var cb = this . async ( ) ;
34+
3335 this . config . set ( 'generatorVersion' , this . rootGeneratorVersion ( ) ) ;
3436 this . filters = { } ;
3537
3638 // init shared generator properies and methods
3739 genBase ( this ) ;
40+
41+ if ( insight . optOut === undefined ) {
42+ insight . askPermission ( null , ( err , optIn ) => {
43+ if ( err || ! optIn ) return cb ( ) ;
44+ insight . track ( 'generatorVersion' , this . rootGeneratorVersion ( ) ) ;
45+ insight . track ( 'node' , process . version ) ;
46+ exec ( 'npm --version' , ( err , stdin , stderr ) => {
47+ if ( err || stderr . length > 0 ) return insight . track ( 'npm' , 'error' ) ;
48+ else return insight . track ( 'npm' , stdin . toString ( ) . trim ( ) ) ;
49+ } ) ;
50+ insight . track ( 'platform' , process . platform ) ;
51+ return cb ( ) ;
52+ } ) ;
53+ } else {
54+ return cb ( ) ;
55+ }
3856 } ,
3957
4058 info : function ( ) {
@@ -55,7 +73,8 @@ export default class Generator extends Base {
5573 } ] , function ( answers ) {
5674 this . skipConfig = answers . skipConfig ;
5775
58- if ( this . skipConfig ) {
76+ if ( this . skipConfig ) {
77+ insight . track ( 'skipConfig' , 'true' ) ;
5978 this . filters = existingFilters ;
6079
6180 this . scriptExt = this . filters . ts ? 'ts' : 'js' ;
@@ -65,6 +84,7 @@ export default class Generator extends Base {
6584 this . filters . stylus ? 'styl' :
6685 'css' ;
6786 } else {
87+ insight . track ( 'skipConfig' , 'false' ) ;
6888 this . filters = { } ;
6989 this . forceConfig = true ;
7090 this . config . set ( 'filters' , this . filters ) ;
@@ -77,7 +97,6 @@ export default class Generator extends Base {
7797 cb ( ) ;
7898 }
7999 }
80-
81100 } ;
82101 }
83102
@@ -133,14 +152,24 @@ export default class Generator extends Base {
133152 return answers . bootstrap ;
134153 }
135154 } ] , function ( answers ) {
136-
137155 this . filters . js = true ;
138156 this . filters [ answers . transpiler ] = true ;
157+ insight . track ( 'transpiler' , answers . transpiler ) ;
158+
139159 this . filters [ answers . markup ] = true ;
160+ insight . track ( 'markup' , answers . markup ) ;
161+
140162 this . filters [ answers . stylesheet ] = true ;
163+ insight . track ( 'stylesheet' , answers . stylesheet ) ;
164+
141165 this . filters [ answers . router ] = true ;
166+ insight . track ( 'router' , answers . router ) ;
167+
142168 this . filters . bootstrap = ! ! answers . bootstrap ;
169+ insight . track ( 'bootstrap' , ! ! answers . bootstrap ) ;
170+
143171 this . filters . uibootstrap = ! ! answers . uibootstrap ;
172+ insight . track ( 'uibootstrap' , ! ! answers . uibootstrap ) ;
144173
145174 this . scriptExt = answers . transpiler === 'ts' ? 'ts' : 'js' ;
146175 this . templateExt = answers . markup ;
@@ -228,7 +257,11 @@ export default class Generator extends Base {
228257 default : true
229258 } ] , function ( answers ) {
230259 if ( answers . socketio ) this . filters . socketio = true ;
260+ insight . track ( 'socketio' , ! ! answers . socketio ) ;
261+
231262 if ( answers . auth ) this . filters . auth = true ;
263+ insight . track ( 'auth' , ! ! answers . auth ) ;
264+
232265 if ( answers . odms && answers . odms . length > 0 ) {
233266 var models ;
234267 if ( ! answers . models ) {
@@ -241,15 +274,26 @@ export default class Generator extends Base {
241274 answers . odms . forEach ( function ( odm ) {
242275 this . filters [ odm ] = true ;
243276 } . bind ( this ) ) ;
277+ insight . track ( 'oauth' , ! ! answers . oauth ) ;
244278 } else {
245279 this . filters . noModels = true ;
246280 }
281+ insight . track ( 'odms' , answers . odms && answers . odms . length > 0 ) ;
282+ insight . track ( 'mongoose' , ! ! this . filters . mongoose ) ;
283+ insight . track ( 'mongooseModels' , ! ! this . filters . mongooseModels ) ;
284+ insight . track ( 'sequelize' , ! ! this . filters . sequelize ) ;
285+ insight . track ( 'sequelizeModels' , ! ! this . filters . sequelizeModels ) ;
286+
247287 if ( answers . oauth ) {
248288 if ( answers . oauth . length ) this . filters . oauth = true ;
249289 answers . oauth . forEach ( function ( oauthStrategy ) {
250290 this . filters [ oauthStrategy ] = true ;
251291 } . bind ( this ) ) ;
252292 }
293+ insight . track ( 'oauth' , ! ! this . filters . oauth ) ;
294+ insight . track ( 'google-oauth' , ! ! this . filters [ 'googleAuth' ] ) ;
295+ insight . track ( 'facebook-oauth' , ! ! this . filters [ 'facebookAuth' ] ) ;
296+ insight . track ( 'twitter-oauth' , ! ! this . filters [ 'twitterAuth' ] ) ;
253297
254298 cb ( ) ;
255299 } . bind ( this ) ) ;
@@ -295,13 +339,16 @@ export default class Generator extends Base {
295339 }
296340 } ] , function ( answers ) {
297341 this . filters [ answers . buildtool ] = true ;
342+ insight . track ( 'buildtool' , answers . buildtool ) ;
298343
299344 this . filters [ answers . testing ] = true ;
345+ insight . track ( 'testing' , answers . testing ) ;
300346 if ( answers . testing === 'mocha' ) {
301347 this . filters . jasmine = false ;
302348 this . filters . should = false ;
303349 this . filters . expect = false ;
304350 this . filters [ answers . chai ] = true ;
351+ insight . track ( 'chai-assertions' , answers . chai ) ;
305352 }
306353 if ( answers . testing === 'jasmine' ) {
307354 this . filters . mocha = false ;
0 commit comments