UNPKG

unified-video-framework

Version:

Cross-platform video player framework supporting iOS, Android, Web, Smart TVs (Samsung/LG), Roku, and more

63 lines 2.21 kB
export class TelemetryManager { constructor() { this.endpoint = 'https://videonexs-player.flicknexs.com/ping'; this.initialized = false; } static getInstance() { if (!TelemetryManager.instance) { TelemetryManager.instance = new TelemetryManager(); } return TelemetryManager.instance; } async initialize(platform, version) { if (this.initialized) return; this.initialized = true; console.log(`[Telemetry] Initializing for ${platform} v${version}`); const data = this.collectData(platform, version); await this.sendPing(data); } collectData(platform, version) { return { domain: typeof window !== 'undefined' ? window.location.hostname : 'node-server', platform, version, timestamp: Date.now(), status: 'init', userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : 'unknown' }; } async sendPing(data) { try { const body = JSON.stringify(data); console.log('[Telemetry] Sending ping...', data); if (typeof fetch !== 'undefined') { const response = await fetch(this.endpoint, { method: 'POST', mode: 'cors', headers: { 'Content-Type': 'application/json' }, body }); if (response.ok) { console.log('[Telemetry] Ping sent successfully'); return; } else { console.warn(`[Telemetry] Ping failed with status: ${response.status}`); } } if (typeof navigator !== 'undefined' && navigator.sendBeacon) { const blob = new Blob([body], { type: 'application/json' }); navigator.sendBeacon(this.endpoint, blob); } } catch (e) { console.error('[Telemetry] Error sending ping:', e); } } stop() { } } //# sourceMappingURL=TelemetryManager.js.map