Include the username used in Sentry errors, to help us debug them

This commit is contained in:
Tim Perry 2017-05-12 11:42:09 +02:00
parent 3a44782c38
commit a5b535753f
No known key found for this signature in database
GPG Key ID: 0DDE38AFD3AF94F0
2 changed files with 24 additions and 9 deletions

View File

@ -1,10 +1,12 @@
// Generated by CoffeeScript 1.12.5
var Mixpanel, Promise, _, packageJSON, resin;
var Mixpanel, Promise, Raven, _, packageJSON, resin;
_ = require('lodash');
Mixpanel = require('mixpanel');
Raven = require('raven');
Promise = require('bluebird');
resin = require('resin-sdk-preconfigured');
@ -22,15 +24,23 @@ exports.trackCommand = function(capitanoCommand) {
resinUrl: resin.settings.get('resinUrl'),
username: resin.auth.whoami(),
mixpanel: exports.getLoggerInstance()
}).then(function(data) {
}).then(function(arg) {
var mixpanel, resinUrl, username;
username = arg.username, resinUrl = arg.resinUrl, mixpanel = arg.mixpanel;
return capitanoStateGetMatchCommandAsync(capitanoCommand.command).then(function(command) {
return data.mixpanel.track("[CLI] " + (command.signature.toString()), {
distinct_id: data.username,
Raven.mergeContext({
user: {
id: username,
username: username
}
});
return mixpanel.track("[CLI] " + (command.signature.toString()), {
distinct_id: username,
argv: process.argv.join(' '),
version: packageJSON.version,
node: process.version,
arch: process.arch,
resinUrl: data.resinUrl,
resinUrl: resinUrl,
platform: process.platform,
command: capitanoCommand
});

View File

@ -1,5 +1,6 @@
_ = require('lodash')
Mixpanel = require('mixpanel')
Raven = require('raven')
Promise = require('bluebird')
resin = require('resin-sdk-preconfigured')
packageJSON = require('../package.json')
@ -14,14 +15,18 @@ exports.trackCommand = (capitanoCommand) ->
resinUrl: resin.settings.get('resinUrl')
username: resin.auth.whoami()
mixpanel: exports.getLoggerInstance()
.then (data) ->
.then ({ username, resinUrl, mixpanel }) ->
return capitanoStateGetMatchCommandAsync(capitanoCommand.command).then (command) ->
data.mixpanel.track "[CLI] #{command.signature.toString()}",
distinct_id: data.username
Raven.mergeContext(user: {
id: username,
username
})
mixpanel.track "[CLI] #{command.signature.toString()}",
distinct_id: username
argv: process.argv.join(' ')
version: packageJSON.version
node: process.version
arch: process.arch
resinUrl: data.resinUrl
resinUrl: resinUrl
platform: process.platform
command: capitanoCommand