fix build
This commit is contained in:
parent
f6de1cd18b
commit
4b1aae55c6
1 changed files with 26 additions and 2 deletions
|
@ -3,8 +3,8 @@ export type AptabaseOptions = {
|
||||||
appVersion?: string;
|
appVersion?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const locale = navigator?.languages && navigator?.languages.length ? navigator?.languages[0] : navigator?.language;
|
const locale = getBrowserLocale();
|
||||||
const isDebug = location?.hostname === 'localhost';
|
const isDebug = getIsDebug();
|
||||||
|
|
||||||
let _appKey = '';
|
let _appKey = '';
|
||||||
let _apiUrl = '';
|
let _apiUrl = '';
|
||||||
|
@ -83,3 +83,27 @@ export function trackEvent(eventName: string, props?: Record<string, string | nu
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBrowserLocale(): string | null {
|
||||||
|
if (typeof navigator === 'undefined') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (navigator.languages.length > 0) {
|
||||||
|
return navigator.languages[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return navigator.language;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIsDebug(): boolean {
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof location === 'undefined') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return location.hostname === 'localhost';
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue