Skip to content

Commit 797a7ba

Browse files
committed
feat(analytics): make more structured event types and utils for events
1 parent cef1455 commit 797a7ba

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

bin/webpack.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
var path = require("path");
88
var Insight = require("insight");
99
var pkg = require("../package.json");
10-
var asyncLib = require("async");
10+
var insightEvents = require("../analytics/events.js");
1111

1212
var insight = new Insight({
1313
trackingCode: "UA-46921629-3",
@@ -334,17 +334,13 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
334334
}
335335
});
336336

337-
asyncLib.forEach(Object.keys(options), function(optionKey, cb) {
338-
insight.trackEvent("options", optionKey, JSON.stringify(options[optionKey]));
339-
cb();
340-
});
341-
342337
var webpack = require("../lib/webpack.js");
343338

344339
Error.stackTraceLimit = 30;
345340
var lastHash = null;
346341
var compiler;
347342
try {
343+
insightReporter.trackEvent(insightEvents.buildEvent({ action: "options-collected", label: JSON.stringify(options), value: 1 }));
348344
compiler = webpack(options);
349345
} catch(e) {
350346
var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError");
@@ -371,7 +367,7 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
371367
compiler.purgeInputFileSystem();
372368
}
373369

374-
insightReporter.trackEvent("compiler", "build-end");
370+
insightReporter.trackEvent(insightEvents.buildEvent({ action: "build-end", label: "compiler build end", value: 9999 }));
375371
if(err) {
376372
lastHash = null;
377373
console.error(err.stack || err);
@@ -402,7 +398,7 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
402398
compiler.watch(watchOptions, compilerCallback);
403399
console.log("\nWebpack is watching the files…\n");
404400
} else
405-
insightReporter.trackEvent("compiler", "build-start");
401+
insightReporter.trackEvent(insightEvents.buildEvent({ action: "build-start", label: "compiler build start", value: 2 }));
406402
compiler.run(compilerCallback);
407403
}
408404

@@ -413,5 +409,4 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
413409
} else {
414410
processOptions(options, insight);
415411
}
416-
417412
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"buildin/",
8888
"hot/",
8989
"web_modules/",
90-
"schemas/"
90+
"schemas/",
91+
"analytics/"
9192
],
9293
"scripts": {
9394
"test": "mocha test/*.test.js test/*.unittest.js --max-old-space-size=4096 --harmony --trace-deprecation --check-leaks",

0 commit comments

Comments
 (0)