Merge pull request #334 from resin-io/fix/event-explosion

Log CLI events based on original command signature
This commit is contained in:
Juan Cruz Viotti 2016-03-29 11:29:17 -04:00
commit d9b4753690
2 changed files with 25 additions and 19 deletions

View File

@ -1,5 +1,5 @@
(function() {
var Mixpanel, Promise, _, packageJSON, resin;
var Mixpanel, Promise, _, capitanoState, packageJSON, resin;
_ = require('lodash');
@ -9,6 +9,8 @@
resin = require('resin-sdk');
capitanoState = Promise.promisifyAll(require('capitano').state);
packageJSON = require('../package.json');
exports.getLoggerInstance = _.memoize(function() {
@ -21,15 +23,17 @@
username: resin.auth.whoami(),
mixpanel: exports.getLoggerInstance()
}).then(function(data) {
return data.mixpanel.track("[CLI] " + capitanoCommand.command, {
distinct_id: data.username,
argv: process.argv.join(' '),
version: packageJSON.version,
node: process.version,
arch: process.arch,
resinUrl: data.resinUrl,
platform: process.platform,
command: capitanoCommand
return capitanoState.getMatchCommandAsync(capitanoCommand.command).then(function(command) {
return data.mixpanel.track("[CLI] " + (command.signature.toString()), {
distinct_id: data.username,
argv: process.argv.join(' '),
version: packageJSON.version,
node: process.version,
arch: process.arch,
resinUrl: data.resinUrl,
platform: process.platform,
command: capitanoCommand
});
});
});
};

View File

@ -2,6 +2,7 @@ _ = require('lodash')
Mixpanel = require('mixpanel')
Promise = require('bluebird')
resin = require('resin-sdk')
capitanoState = Promise.promisifyAll(require('capitano').state)
packageJSON = require('../package.json')
exports.getLoggerInstance = _.memoize ->
@ -13,12 +14,13 @@ exports.trackCommand = (capitanoCommand) ->
username: resin.auth.whoami()
mixpanel: exports.getLoggerInstance()
.then (data) ->
data.mixpanel.track "[CLI] #{capitanoCommand.command}",
distinct_id: data.username
argv: process.argv.join(' ')
version: packageJSON.version
node: process.version
arch: process.arch
resinUrl: data.resinUrl
platform: process.platform
command: capitanoCommand
return capitanoState.getMatchCommandAsync(capitanoCommand.command).then (command) ->
data.mixpanel.track "[CLI] #{command.signature.toString()}",
distinct_id: data.username
argv: process.argv.join(' ')
version: packageJSON.version
node: process.version
arch: process.arch
resinUrl: data.resinUrl
platform: process.platform
command: capitanoCommand