Remove Aptabase official servers and update isDebug
function
This commit is contained in:
parent
b063577663
commit
84a50710ef
1 changed files with 15 additions and 18 deletions
|
@ -1,27 +1,24 @@
|
||||||
let defaultLocale: string | undefined;
|
let defaultLocale: string | undefined;
|
||||||
let defaultIsDebug: boolean | undefined;
|
let defaultIsDevelopment: boolean | undefined;
|
||||||
const isInBrowser = true;
|
const isInBrowser = true;
|
||||||
|
|
||||||
let _sessionId = newSessionId();
|
let _sessionId = newSessionId();
|
||||||
let _lastTouched = new Date();
|
let _lastTouched = new Date();
|
||||||
|
|
||||||
const _hosts: { [region: string]: string } = {
|
const _hosts: { [region: string]: string } = {
|
||||||
US: 'https://us.aptabase.com',
|
ZV: 'https://events.sudovanilla.org',
|
||||||
EU: 'https://eu.aptabase.com',
|
SH: '',
|
||||||
DEV: 'https://localhost:3000',
|
|
||||||
ZV: 'https://beta.events.sudovanilla.org',
|
|
||||||
SH: ''
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ZalvenaOptions = {
|
export type ZalvenaOptions = {
|
||||||
// Custom host for self-hosted Aptabase.
|
// Custom host for self-hosted Zalvena.
|
||||||
host?: string;
|
host?: string;
|
||||||
// Custom path for API endpoint. Useful when using reverse proxy.
|
// Custom path for API endpoint. Useful when using reverse proxy.
|
||||||
apiUrl?: string;
|
apiUrl?: string;
|
||||||
// Defines the app version.
|
// Defines the app version.
|
||||||
appVersion?: string;
|
appVersion?: string;
|
||||||
// Defines whether the app is running on debug mode.
|
// Defines whether the app is running in development mode.
|
||||||
isDebug?: boolean;
|
isDevelopment?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function inMemorySessionId(timeout: number): string {
|
export function inMemorySessionId(timeout: number): string {
|
||||||
|
@ -47,7 +44,7 @@ export function newSessionId(): string {
|
||||||
export function validateAppKey(appKey: string): boolean {
|
export function validateAppKey(appKey: string): boolean {
|
||||||
const parts = appKey.split('-');
|
const parts = appKey.split('-');
|
||||||
if (parts.length !== 3 || _hosts[parts[1]] === undefined) {
|
if (parts.length !== 3 || _hosts[parts[1]] === undefined) {
|
||||||
console.warn(`The Aptabase App Key "${appKey}" is invalid. Tracking will be disabled.`);
|
console.warn(`The Zalvena App Key "${appKey}" is invalid. Tracking will be disabled.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -73,7 +70,7 @@ export async function sendEvent(opts: {
|
||||||
appKey?: string;
|
appKey?: string;
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
locale?: string;
|
locale?: string;
|
||||||
isDebug?: boolean;
|
isDevelopment?: boolean;
|
||||||
appVersion?: string;
|
appVersion?: string;
|
||||||
sdkVersion: string;
|
sdkVersion: string;
|
||||||
eventName: string;
|
eventName: string;
|
||||||
|
@ -103,7 +100,7 @@ export async function sendEvent(opts: {
|
||||||
eventName: opts.eventName,
|
eventName: opts.eventName,
|
||||||
systemProps: {
|
systemProps: {
|
||||||
locale: opts.locale ?? getBrowserLocale(),
|
locale: opts.locale ?? getBrowserLocale(),
|
||||||
isDebug: opts.isDebug ?? getIsDebug(),
|
isDebug: opts.isDevelopment ?? getIsDevelopment(),
|
||||||
appVersion: opts.appVersion ?? '',
|
appVersion: opts.appVersion ?? '',
|
||||||
sdkVersion: opts.sdkVersion,
|
sdkVersion: opts.sdkVersion,
|
||||||
},
|
},
|
||||||
|
@ -140,13 +137,13 @@ function getBrowserLocale(): string | undefined {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the environment is on the `localhost` URL,
|
// If the environment is on the `localhost` URL,
|
||||||
// send debug data instead of release.
|
// send development data instead of production
|
||||||
function getIsDebug(): boolean {
|
function getIsDevelopment(): boolean {
|
||||||
if (location.hostname === 'localhost') {
|
if (location.hostname === 'localhost') {
|
||||||
defaultIsDebug = true
|
defaultIsDevelopment = true;
|
||||||
return defaultIsDebug
|
return defaultIsDevelopment;
|
||||||
} else {
|
} else {
|
||||||
defaultIsDebug = false
|
defaultIsDevelopment = false;
|
||||||
return defaultIsDebug
|
return defaultIsDevelopment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue