File size: 1,958 Bytes
94193b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | export const TELEMETRY_ENDPOINT =
process.env.NEXT_PUBLIC_ANALYTICS_ENDPOINT || 'https://stats.oswstudio.com/collect';
export const TELEMETRY_TOKEN =
process.env.NEXT_PUBLIC_ANALYTICS_TOKEN || 'gcBLEeGjdx8gbUMoAAlksvoKSREZlJ4l+GwKieTW2Og=';
export const TELEMETRY_ENABLED =
process.env.NEXT_PUBLIC_TELEMETRY_ENABLED !== 'false';
export const TELEMETRY_DEBUG =
process.env.NEXT_PUBLIC_TELEMETRY_DEBUG === 'true';
export const FLUSH_INTERVAL_MS = 30_000;
export const MAX_BATCH_SIZE = 50;
export const MAX_RETRIES = 3;
export const RETRY_BASE_MS = 1_000;
export const HEARTBEAT_INTERVAL_MS = 300_000;
export function detectDeploymentType(): 'hf_space' | 'desktop' | 'managed' | 'server' | 'browser' {
if (typeof window !== 'undefined') {
const hostname = window.location.hostname;
if (hostname.includes('hf.space') || hostname.includes('huggingface.co')) {
return 'hf_space';
}
}
if (process.env.NEXT_PUBLIC_DESKTOP === 'true') {
return 'desktop';
}
if (process.env.NEXT_PUBLIC_SERVER_MODE === 'true') {
if (process.env.NEXT_PUBLIC_GATEWAY_URL) {
return 'managed';
}
return 'server';
}
return 'browser';
}
export function getManagedContext(): Record<string, string> | null {
if (detectDeploymentType() !== 'managed') return null;
const ctx: Record<string, string> = {};
if (process.env.NEXT_PUBLIC_INSTANCE_ID) ctx.instance_id = process.env.NEXT_PUBLIC_INSTANCE_ID;
if (process.env.NEXT_PUBLIC_GATEWAY_URL) ctx.gateway_url = process.env.NEXT_PUBLIC_GATEWAY_URL;
return ctx;
}
import pkg from '@/package.json';
export function getAppVersion(): string {
return pkg.version;
}
export function detectOsPlatform(): string {
if (typeof navigator === 'undefined') return 'unknown';
const ua = navigator.userAgent.toLowerCase();
if (ua.includes('win')) return 'windows';
if (ua.includes('mac')) return 'macos';
if (ua.includes('linux')) return 'linux';
return 'unknown';
}
|