mirror of
https://github.com/voideditor/void
synced 2026-05-23 17:38:23 +00:00
metrics for updates
This commit is contained in:
parent
a90bbffeb9
commit
458a5160b0
2 changed files with 23 additions and 16 deletions
|
|
@ -7,7 +7,6 @@ import { createDecorator } from '../../instantiation/common/instantiation.js';
|
|||
import { ProxyChannel } from '../../../base/parts/ipc/common/ipc.js';
|
||||
import { IMainProcessService } from '../../ipc/common/mainProcessService.js';
|
||||
import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';
|
||||
import { IMetricsService } from './metricsService.js';
|
||||
|
||||
|
||||
|
||||
|
|
@ -28,7 +27,6 @@ export class VoidUpdateService implements IVoidUpdateService {
|
|||
|
||||
constructor(
|
||||
@IMainProcessService mainProcessService: IMainProcessService, // (only usable on client side)
|
||||
@IMetricsService private readonly metricsService: IMetricsService,
|
||||
) {
|
||||
// creates an IPC proxy to use metricsMainService.ts
|
||||
this.voidUpdateService = ProxyChannel.toService<IVoidUpdateService>(mainProcessService.getChannel('void-channel-update'));
|
||||
|
|
@ -38,7 +36,6 @@ export class VoidUpdateService implements IVoidUpdateService {
|
|||
// anything transmitted over a channel must be async even if it looks like it doesn't have to be
|
||||
check: IVoidUpdateService['check'] = async () => {
|
||||
const res = await this.voidUpdateService.check()
|
||||
this.metricsService.capture('Check for Updates', { ...res })
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,11 @@ registerAction2(class extends Action2 {
|
|||
const notifService = accessor.get(INotificationService)
|
||||
const metricsService = accessor.get(IMetricsService)
|
||||
|
||||
metricsService.capture('Void Update Manual: Checking...', {})
|
||||
const res = await voidUpdateService.check()
|
||||
if (!res) { notifyErrChecking(notifService); metricsService.capture('Void Update: Error', {}) }
|
||||
else if (res.hasUpdate) { notifyYesUpdate(notifService, res.message); metricsService.capture('Void Update: Yes', {}) }
|
||||
else if (!res.hasUpdate) { notifyNoUpdate(notifService); metricsService.capture('Void Update: No', {}) }
|
||||
if (!res) { notifyErrChecking(notifService); metricsService.capture('Void Update Manual: Error', { res }) }
|
||||
else if (res.hasUpdate) { notifyYesUpdate(notifService, res.message); metricsService.capture('Void Update Manual: Yes', { res }) }
|
||||
else if (!res.hasUpdate) { notifyNoUpdate(notifService); metricsService.capture('Void Update Manual: No', { res }) }
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -65,23 +66,32 @@ class VoidUpdateWorkbenchContribution extends Disposable implements IWorkbenchCo
|
|||
static readonly ID = 'workbench.contrib.void.voidUpdate'
|
||||
constructor(
|
||||
@IVoidUpdateService private readonly voidUpdateService: IVoidUpdateService,
|
||||
@INotificationService private readonly notifService: INotificationService,
|
||||
@IMetricsService private readonly metricsService: IMetricsService,
|
||||
@INotificationService private readonly notifService: INotificationService,
|
||||
) {
|
||||
super()
|
||||
|
||||
// on mount
|
||||
setTimeout(async () => {
|
||||
const autoCheck = async () => {
|
||||
this.metricsService.capture('Void Update Startup: Checking...', {})
|
||||
const res = await this.voidUpdateService.check()
|
||||
if (!res) { notifyErrChecking(this.notifService); this.metricsService.capture('Void Update Startup: Error', { res }) }
|
||||
else if (res.hasUpdate) { notifyYesUpdate(this.notifService, res.message); this.metricsService.capture('Void Update Startup: Yes', { res }) }
|
||||
else if (!res.hasUpdate) { this.metricsService.capture('Void Update Startup: No', { res }) } // display nothing if up to date
|
||||
}
|
||||
|
||||
const notifService = this.notifService
|
||||
const metricsService = this.metricsService
|
||||
// check once 5 seconds after mount
|
||||
this._register({
|
||||
dispose: () => clearTimeout(
|
||||
setTimeout(() => autoCheck(), 5 * 1000)
|
||||
)
|
||||
})
|
||||
|
||||
if (!res) { notifyErrChecking(notifService); metricsService.capture('Void Update Startup: Error', {}) }
|
||||
else if (res.hasUpdate) { notifyYesUpdate(this.notifService, res.message); metricsService.capture('Void Update Startup: Yes', {}) }
|
||||
else if (!res.hasUpdate) { metricsService.capture('Void Update Startup: No', {}) } // display nothing if up to date
|
||||
// check every 3 hours
|
||||
this._register({
|
||||
dispose: () => clearInterval(
|
||||
setInterval(() => autoCheck(), 3 * 60 * 60 * 1000)
|
||||
)
|
||||
})
|
||||
|
||||
}, 5 * 1000)
|
||||
}
|
||||
}
|
||||
registerWorkbenchContribution2(VoidUpdateWorkbenchContribution.ID, VoidUpdateWorkbenchContribution, WorkbenchPhase.BlockRestore);
|
||||
|
|
|
|||
Loading…
Reference in a new issue