mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +00:00
events: Correctly proxy mixpanel events
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
a0841b18f6
commit
f48e85095b
@ -65,7 +65,7 @@
|
||||
"lodash": "^4.16.3",
|
||||
"log-timestamp": "^0.1.2",
|
||||
"memoizee": "^0.4.1",
|
||||
"mixpanel": "0.0.20",
|
||||
"mixpanel": "https://github.com/balena-io-modules/mixpanel-node",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^5.1.1",
|
||||
"mochainon": "^2.0.0",
|
||||
|
@ -1,6 +1,7 @@
|
||||
import * as Bluebird from 'bluebird';
|
||||
import { Transaction } from 'knex';
|
||||
import * as _ from 'lodash';
|
||||
import { URL } from 'url';
|
||||
|
||||
import Config = require('../config');
|
||||
import supervisorVersion = require('../lib/supervisor-version');
|
||||
@ -107,7 +108,8 @@ export function createProviderFunctions(
|
||||
mixpanelHost: {
|
||||
get: () => {
|
||||
return config.get('apiEndpoint').then(apiEndpoint => {
|
||||
return `${apiEndpoint}/mixpanel`;
|
||||
const url = new URL(apiEndpoint as string);
|
||||
return { host: url.host, path: '/mixpanel' };
|
||||
});
|
||||
},
|
||||
},
|
||||
|
@ -12,7 +12,7 @@ export type EventTrackProperties = Dictionary<any>;
|
||||
interface InitArgs {
|
||||
uuid: string;
|
||||
offlineMode: boolean;
|
||||
mixpanelHost: string;
|
||||
mixpanelHost: { host: string; path: string };
|
||||
mixpanelToken: string;
|
||||
}
|
||||
|
||||
@ -55,7 +55,10 @@ export class EventTracker {
|
||||
if (offlineMode) {
|
||||
return;
|
||||
}
|
||||
this.client = Mixpanel.init(mixpanelToken, { host: mixpanelHost });
|
||||
this.client = Mixpanel.init(mixpanelToken, {
|
||||
host: mixpanelHost.host,
|
||||
path: mixpanelHost.path,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ describe 'EventTracker', ->
|
||||
promise = @eventTrackerOffline.init({
|
||||
offlineMode: true
|
||||
uuid: 'foobar'
|
||||
mixpanelHost: { host: '', path: '' }
|
||||
})
|
||||
expect(promise).to.be.fulfilled
|
||||
.then =>
|
||||
@ -40,6 +41,7 @@ describe 'EventTracker', ->
|
||||
promise = @eventTracker.init({
|
||||
mixpanelToken: 'someToken'
|
||||
uuid: 'barbaz'
|
||||
mixpanelHost: { host: '', path: '' }
|
||||
})
|
||||
expect(promise).to.be.fulfilled
|
||||
.then =>
|
||||
|
Loading…
Reference in New Issue
Block a user