import { app, autoUpdater } from 'electron'; import * as Sentry from '@sentry/electron'; const version = app.getVersion(); const updaterFeedURL = new URL('/update/' + process.platform + '/' + version, 'https://solarcast-desktop-updater.vercel.app'); const appUpdater = (): void => { autoUpdater.setFeedURL({ url: updaterFeedURL.href }); const timer = setInterval(() => { autoUpdater.checkForUpdates(); }, 1000 * 60 * 5); autoUpdater.on('error', err => Sentry.captureException(err)); autoUpdater.on('update-available', () => clearInterval(timer)); autoUpdater.on('update-downloaded', () => { setImmediate(() => autoUpdater.quitAndInstall()); }); // init for updates autoUpdater.checkForUpdates(); }; export default appUpdater;