]> source.dussan.org Git - jquery.git/commitdiff
Build: try insight package to get info about custom builds
authorOleg Gaidarenko <markelog@gmail.com>
Sat, 12 Mar 2016 14:48:37 +0000 (17:48 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Mon, 14 Mar 2016 18:13:05 +0000 (21:13 +0300)
Fixes gh-2890
Closes gh-2988

build/tasks/build.js
package.json

index 2ebb4c47e7bd97013dc87edac6f11ae044a90494..1e1c6bb3769c22f057a1d8385d9159385283a558 100644 (file)
@@ -10,6 +10,8 @@ module.exports = function( grunt ) {
 
        var fs = require( "fs" ),
                requirejs = require( "requirejs" ),
+               Insight = require( "insight" ),
+               pkg = require( "../../package.json" ),
                srcFolder = __dirname + "/../../src/",
                rdefineEnd = /\}\s*?\);[^}\w]*$/,
                read = function( fileName ) {
@@ -312,10 +314,47 @@ module.exports = function( grunt ) {
        //   grunt build:*:*:+ajax:-dimensions:-effects:-offset
        grunt.registerTask( "custom", function() {
                var args = this.args,
-                       modules = args.length ? args[ 0 ].replace( /,/g, ":" ) : "";
+                       modules = args.length ? args[ 0 ].replace( /,/g, ":" ) : "",
+                       done = this.async(),
+                       insight = new Insight( {
+                               trackingCode: "UA-1076265-4",
+                               pkg: pkg
+                       } );
+
+               function exec( trackingAllowed ) {
+                       var tracks = args.length ? args[ 0 ].split( "," ) : [];
+                       var defaultPath = [ "build", "custom" ];
+
+                       tracks = tracks.map( function( track ) {
+                               return track.replace( /\//g, "+" );
+                       } );
+
+                       if ( trackingAllowed ) {
+
+                               // Track individuals
+                               tracks.forEach( function( module ) {
+                                       var path = defaultPath.concat( [ "individual" ], module );
+
+                                       insight.track.apply( insight, path );
+                               } );
+
+                               // Track full command
+                               insight.track.apply( insight, defaultPath.concat( [ "full" ], tracks ) );
+                       }
+
+                       grunt.task.run( [ "build:*:*" + ( modules ? ":" + modules : "" ), "uglify", "dist" ] );
+                       done();
+               }
 
                grunt.log.writeln( "Creating custom build...\n" );
 
-               grunt.task.run( [ "build:*:*" + ( modules ? ":" + modules : "" ), "uglify", "dist" ] );
+               // Ask for permission the first time
+               if ( insight.optOut === undefined ) {
+                       insight.askPermission( null, function( error, result ) {
+                               exec( result );
+                       } );
+               } else {
+                       exec( !insight.optOut );
+               }
        } );
 };
index ef450590c47fe7d73250f5c123fd9f0e77f94f95..30ff931fc817d221962cd4840d20a8dd7231f6b4 100644 (file)
@@ -43,6 +43,7 @@
     "grunt-npmcopy": "0.1.0",
     "gzip-js": "0.3.2",
     "husky": "0.11.3",
+    "insight": "0.7.0",
     "jsdom": "5.6.1",
     "load-grunt-tasks": "3.4.0",
     "native-promise-only": "0.8.1",