From 84a50710ef302d0b18b435a3fce111677241c65f Mon Sep 17 00:00:00 2001 From: Korbs Date: Thu, 20 Feb 2025 18:03:58 -0500 Subject: [PATCH] Remove Aptabase official servers and update `isDebug` function --- packages/shared.ts | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/packages/shared.ts b/packages/shared.ts index 4376ef0..d37a85e 100644 --- a/packages/shared.ts +++ b/packages/shared.ts @@ -1,27 +1,24 @@ let defaultLocale: string | undefined; -let defaultIsDebug: boolean | undefined; +let defaultIsDevelopment: boolean | undefined; const isInBrowser = true; let _sessionId = newSessionId(); let _lastTouched = new Date(); const _hosts: { [region: string]: string } = { - US: 'https://us.aptabase.com', - EU: 'https://eu.aptabase.com', - DEV: 'https://localhost:3000', - ZV: 'https://beta.events.sudovanilla.org', - SH: '' + ZV: 'https://events.sudovanilla.org', + SH: '', }; export type ZalvenaOptions = { - // Custom host for self-hosted Aptabase. + // Custom host for self-hosted Zalvena. host?: string; // Custom path for API endpoint. Useful when using reverse proxy. apiUrl?: string; // Defines the app version. appVersion?: string; - // Defines whether the app is running on debug mode. - isDebug?: boolean; + // Defines whether the app is running in development mode. + isDevelopment?: boolean; }; export function inMemorySessionId(timeout: number): string { @@ -47,7 +44,7 @@ export function newSessionId(): string { export function validateAppKey(appKey: string): boolean { const parts = appKey.split('-'); 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 true; @@ -73,7 +70,7 @@ export async function sendEvent(opts: { appKey?: string; sessionId: string; locale?: string; - isDebug?: boolean; + isDevelopment?: boolean; appVersion?: string; sdkVersion: string; eventName: string; @@ -103,7 +100,7 @@ export async function sendEvent(opts: { eventName: opts.eventName, systemProps: { locale: opts.locale ?? getBrowserLocale(), - isDebug: opts.isDebug ?? getIsDebug(), + isDebug: opts.isDevelopment ?? getIsDevelopment(), appVersion: opts.appVersion ?? '', sdkVersion: opts.sdkVersion, }, @@ -140,13 +137,13 @@ function getBrowserLocale(): string | undefined { } // If the environment is on the `localhost` URL, -// send debug data instead of release. -function getIsDebug(): boolean { +// send development data instead of production +function getIsDevelopment(): boolean { if (location.hostname === 'localhost') { - defaultIsDebug = true - return defaultIsDebug + defaultIsDevelopment = true; + return defaultIsDevelopment; } else { - defaultIsDebug = false - return defaultIsDebug + defaultIsDevelopment = false; + return defaultIsDevelopment; } }