Merge pull request #1641 from balena-io/improve-events

Improve events
This commit is contained in:
Page- 2020-03-24 18:54:55 +00:00 committed by GitHub
commit c8275b52c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,10 +22,9 @@ import * as Mixpanel from 'mixpanel';
import * as packageJSON from '../package.json';
import { getBalenaSdk } from './utils/lazy';
const getMixpanel = _.once<any>(() => {
const settings = require('balena-settings-client');
const getMixpanel = _.once((balenaUrl: string) => {
return Mixpanel.init('balena-main', {
host: `api.${settings.get('balenaUrl')}`,
host: `api.${balenaUrl}`,
path: '/mixpanel',
protocol: 'https',
});
@ -47,10 +46,11 @@ const getMixpanel = _.once<any>(() => {
*/
export function trackCommand(commandSignature: string) {
const balena = getBalenaSdk();
const balenaUrlPromise = balena.settings.get('balenaUrl');
return Bluebird.props({
balenaUrl: balena.settings.get('balenaUrl'),
balenaUrl: balenaUrlPromise,
username: balena.auth.whoami().catchReturn(undefined),
mixpanel: getMixpanel(),
mixpanel: balenaUrlPromise.then(getMixpanel),
})
.then(({ username, balenaUrl, mixpanel }) => {
Sentry.configureScope(scope => {