Handle empty apiEndpoint when detecting mixpanel host

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2018-11-26 16:34:53 +00:00
parent 940d8c9862
commit dfa9034fe9
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
2 changed files with 5 additions and 2 deletions

View File

@ -108,6 +108,9 @@ export function createProviderFunctions(
mixpanelHost: {
get: () => {
return config.get('apiEndpoint').then(apiEndpoint => {
if (!apiEndpoint) {
return null;
}
const url = new URL(apiEndpoint as string);
return { host: url.host, path: '/mixpanel' };
});

View File

@ -12,7 +12,7 @@ export type EventTrackProperties = Dictionary<any>;
interface InitArgs {
uuid: string;
offlineMode: boolean;
mixpanelHost: { host: string; path: string };
mixpanelHost: { host: string; path: string } | null;
mixpanelToken: string;
}
@ -52,7 +52,7 @@ export class EventTracker {
uuid,
supervisorVersion,
};
if (offlineMode) {
if (offlineMode || mixpanelHost == null) {
return;
}
this.client = Mixpanel.init(mixpanelToken, {