Files
BizGaze_Remote/desktop/preload.js
T
Sravan 899770ed02 feat: Windows download link + self-served update feed + install tracking
Downloads/updates:
- config: DOWNLOADS_DIR (override to a mounted volume in prod).
- static.js: serves /downloads/* (installer, latest.yml, .blockmap) with range support for
  resumable + differential auto-updates; /download/windows redirects to the current .exe
  (stable link). Landing page gets a "Download the Windows desktop app" button (hidden in-app).

Install tracking (who installed the app):
- db app_installs + repos.appInstalls (upsert by install_id, fills in the user on sign-in).
- POST /api/v1/telemetry/install (records install + user once authenticated);
  GET /api/v1/admin/installs (admin: list installs with user/version/os/last-seen).
- desktop main.js: stable per-install id in userData, exposed via preload
  (bizConnectNative.installId/version/os); home.html reportInstall() posts it after login.
- e2e: +2 checks (telemetry recorded, admin sees it). 119/119. build batch20.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 21:28:53 +05:30

23 lines
1.2 KiB
JavaScript

// Minimal, safe bridge into the web UI. Runs with contextIsolation, so it only exposes a
// frozen marker the web app can feature-detect against (e.g. to hide the PWA install prompt
// or prefer native push). No Node APIs are exposed to page JS.
const { contextBridge, ipcRenderer } = require('electron');
// Pull the stable install id + version/os from main (synchronous, one-time at preload).
let info = { installId: '', appVersion: '', os: '' };
try { info = ipcRenderer.sendSync('get-install-info') || info; } catch (_) {}
contextBridge.exposeInMainWorld('__NATIVE__', 'desktop');
contextBridge.exposeInMainWorld('bizConnectNative', Object.freeze({
platform: 'desktop',
version: info.appVersion || '0.1.0',
installId: info.installId || '',
os: info.os || '',
// Bring the app window to the foreground (e.g. when a notification is clicked) — the web
// Notification's window.focus() can't raise an Electron window; the main process must.
focusApp: () => ipcRenderer.send('focus-window'),
// Show the unread-chat count as a badge on the taskbar icon. count=number of chats with
// unread; dataUrl=a small PNG badge the renderer drew (null to clear).
setUnread: (count, dataUrl) => ipcRenderer.send('set-unread', { count, dataUrl }),
}));