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",
|
"lodash": "^4.16.3",
|
||||||
"log-timestamp": "^0.1.2",
|
"log-timestamp": "^0.1.2",
|
||||||
"memoizee": "^0.4.1",
|
"memoizee": "^0.4.1",
|
||||||
"mixpanel": "0.0.20",
|
"mixpanel": "https://github.com/balena-io-modules/mixpanel-node",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"mocha": "^5.1.1",
|
"mocha": "^5.1.1",
|
||||||
"mochainon": "^2.0.0",
|
"mochainon": "^2.0.0",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import * as Bluebird from 'bluebird';
|
import * as Bluebird from 'bluebird';
|
||||||
import { Transaction } from 'knex';
|
import { Transaction } from 'knex';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
import { URL } from 'url';
|
||||||
|
|
||||||
import Config = require('../config');
|
import Config = require('../config');
|
||||||
import supervisorVersion = require('../lib/supervisor-version');
|
import supervisorVersion = require('../lib/supervisor-version');
|
||||||
@ -107,7 +108,8 @@ export function createProviderFunctions(
|
|||||||
mixpanelHost: {
|
mixpanelHost: {
|
||||||
get: () => {
|
get: () => {
|
||||||
return config.get('apiEndpoint').then(apiEndpoint => {
|
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 {
|
interface InitArgs {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
offlineMode: boolean;
|
offlineMode: boolean;
|
||||||
mixpanelHost: string;
|
mixpanelHost: { host: string; path: string };
|
||||||
mixpanelToken: string;
|
mixpanelToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,10 @@ export class EventTracker {
|
|||||||
if (offlineMode) {
|
if (offlineMode) {
|
||||||
return;
|
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({
|
promise = @eventTrackerOffline.init({
|
||||||
offlineMode: true
|
offlineMode: true
|
||||||
uuid: 'foobar'
|
uuid: 'foobar'
|
||||||
|
mixpanelHost: { host: '', path: '' }
|
||||||
})
|
})
|
||||||
expect(promise).to.be.fulfilled
|
expect(promise).to.be.fulfilled
|
||||||
.then =>
|
.then =>
|
||||||
@ -40,6 +41,7 @@ describe 'EventTracker', ->
|
|||||||
promise = @eventTracker.init({
|
promise = @eventTracker.init({
|
||||||
mixpanelToken: 'someToken'
|
mixpanelToken: 'someToken'
|
||||||
uuid: 'barbaz'
|
uuid: 'barbaz'
|
||||||
|
mixpanelHost: { host: '', path: '' }
|
||||||
})
|
})
|
||||||
expect(promise).to.be.fulfilled
|
expect(promise).to.be.fulfilled
|
||||||
.then =>
|
.then =>
|
||||||
|
Loading…
Reference in New Issue
Block a user