mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-07 19:40:47 +00:00
Log CLI events based on original command signature
Currently we log a CLI event with the passed command, however this might include usr params, like a uuid, and therefore cause thousands of different event names in Mixpanel.
This commit is contained in:
parent
4aa8362be9
commit
ca40d7ca65
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var Mixpanel, Promise, _, packageJSON, resin;
|
var Mixpanel, Promise, _, capitanoState, packageJSON, resin;
|
||||||
|
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
|
|
||||||
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
resin = require('resin-sdk');
|
resin = require('resin-sdk');
|
||||||
|
|
||||||
|
capitanoState = Promise.promisifyAll(require('capitano').state);
|
||||||
|
|
||||||
packageJSON = require('../package.json');
|
packageJSON = require('../package.json');
|
||||||
|
|
||||||
exports.getLoggerInstance = _.memoize(function() {
|
exports.getLoggerInstance = _.memoize(function() {
|
||||||
@ -21,15 +23,17 @@
|
|||||||
username: resin.auth.whoami(),
|
username: resin.auth.whoami(),
|
||||||
mixpanel: exports.getLoggerInstance()
|
mixpanel: exports.getLoggerInstance()
|
||||||
}).then(function(data) {
|
}).then(function(data) {
|
||||||
return data.mixpanel.track("[CLI] " + capitanoCommand.command, {
|
return capitanoState.getMatchCommandAsync(capitanoCommand.command).then(function(command) {
|
||||||
distinct_id: data.username,
|
return data.mixpanel.track("[CLI] " + (command.signature.toString()), {
|
||||||
argv: process.argv.join(' '),
|
distinct_id: data.username,
|
||||||
version: packageJSON.version,
|
argv: process.argv.join(' '),
|
||||||
node: process.version,
|
version: packageJSON.version,
|
||||||
arch: process.arch,
|
node: process.version,
|
||||||
resinUrl: data.resinUrl,
|
arch: process.arch,
|
||||||
platform: process.platform,
|
resinUrl: data.resinUrl,
|
||||||
command: capitanoCommand
|
platform: process.platform,
|
||||||
|
command: capitanoCommand
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@ _ = require('lodash')
|
|||||||
Mixpanel = require('mixpanel')
|
Mixpanel = require('mixpanel')
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
resin = require('resin-sdk')
|
resin = require('resin-sdk')
|
||||||
|
capitanoState = Promise.promisifyAll(require('capitano').state)
|
||||||
packageJSON = require('../package.json')
|
packageJSON = require('../package.json')
|
||||||
|
|
||||||
exports.getLoggerInstance = _.memoize ->
|
exports.getLoggerInstance = _.memoize ->
|
||||||
@ -13,12 +14,13 @@ exports.trackCommand = (capitanoCommand) ->
|
|||||||
username: resin.auth.whoami()
|
username: resin.auth.whoami()
|
||||||
mixpanel: exports.getLoggerInstance()
|
mixpanel: exports.getLoggerInstance()
|
||||||
.then (data) ->
|
.then (data) ->
|
||||||
data.mixpanel.track "[CLI] #{capitanoCommand.command}",
|
return capitanoState.getMatchCommandAsync(capitanoCommand.command).then (command) ->
|
||||||
distinct_id: data.username
|
data.mixpanel.track "[CLI] #{command.signature.toString()}",
|
||||||
argv: process.argv.join(' ')
|
distinct_id: data.username
|
||||||
version: packageJSON.version
|
argv: process.argv.join(' ')
|
||||||
node: process.version
|
version: packageJSON.version
|
||||||
arch: process.arch
|
node: process.version
|
||||||
resinUrl: data.resinUrl
|
arch: process.arch
|
||||||
platform: process.platform
|
resinUrl: data.resinUrl
|
||||||
command: capitanoCommand
|
platform: process.platform
|
||||||
|
command: capitanoCommand
|
||||||
|
Loading…
x
Reference in New Issue
Block a user