From 458a5160b0d046b6b0c0eb660b0f6dd820ea8124 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Thu, 23 Jan 2025 20:58:07 -0800 Subject: [PATCH] metrics for updates --- .../platform/void/common/voidUpdateService.ts | 3 -- .../contrib/void/browser/voidUpdateActions.ts | 36 ++++++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/vs/platform/void/common/voidUpdateService.ts b/src/vs/platform/void/common/voidUpdateService.ts index fbe602b7..fd3467dd 100644 --- a/src/vs/platform/void/common/voidUpdateService.ts +++ b/src/vs/platform/void/common/voidUpdateService.ts @@ -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(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 } } diff --git a/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts b/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts index e58d26ad..bd95e747 100644 --- a/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts +++ b/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts @@ -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);