mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { app, protocol, session, Session, systemPreferences, WebFrameMain } from 'electron';
|
||||
import { app, powerMonitor, protocol, session, Session, systemPreferences, WebFrameMain } from 'electron';
|
||||
import { addUNCHostToAllowlist, disableUNCAccessRestrictions } from '../../base/node/unc.js';
|
||||
import { validatedIpcMain } from '../../base/parts/ipc/electron-main/ipcMain.js';
|
||||
import { hostname, release } from 'os';
|
||||
@@ -611,7 +611,7 @@ export class CodeApplication extends Disposable {
|
||||
this.lifecycleMainService.phase = LifecycleMainPhase.AfterWindowOpen;
|
||||
|
||||
// Post Open Windows Tasks
|
||||
this.afterWindowOpen();
|
||||
this.afterWindowOpen(appInstantiationService);
|
||||
|
||||
// Set lifecycle phase to `Eventually` after a short delay and when idle (min 2.5sec, max 5sec)
|
||||
const eventuallyPhaseScheduler = this._register(new RunOnceScheduler(() => {
|
||||
@@ -1374,7 +1374,7 @@ export class CodeApplication extends Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
private afterWindowOpen(): void {
|
||||
private afterWindowOpen(instantiationService: IInstantiationService): void {
|
||||
|
||||
// Windows: mutex
|
||||
this.installMutex();
|
||||
@@ -1400,6 +1400,41 @@ export class CodeApplication extends Disposable {
|
||||
if (isMacintosh && app.runningUnderARM64Translation) {
|
||||
this.windowsMainService?.sendToFocused('vscode:showTranslatedBuildWarning');
|
||||
}
|
||||
|
||||
// Power telemetry
|
||||
instantiationService.invokeFunction(accessor => {
|
||||
const telemetryService = accessor.get(ITelemetryService);
|
||||
|
||||
type PowerEvent = {
|
||||
readonly idleState: string;
|
||||
readonly idleTime: number;
|
||||
readonly thermalState: string;
|
||||
readonly onBattery: boolean;
|
||||
};
|
||||
type PowerEventClassification = {
|
||||
idleState: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The system idle state (active, idle, locked, unknown).' };
|
||||
idleTime: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'The system idle time in seconds.' };
|
||||
thermalState: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The system thermal state (unknown, nominal, fair, serious, critical).' };
|
||||
onBattery: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'Whether the system is running on battery power.' };
|
||||
owner: 'chrmarti';
|
||||
comment: 'Tracks OS power suspend and resume events for reliability insights.';
|
||||
};
|
||||
|
||||
const getPowerEventData = (): PowerEvent => ({
|
||||
idleState: powerMonitor.getSystemIdleState(60),
|
||||
idleTime: powerMonitor.getSystemIdleTime(),
|
||||
thermalState: powerMonitor.getCurrentThermalState(),
|
||||
onBattery: powerMonitor.isOnBatteryPower()
|
||||
});
|
||||
|
||||
this._register(Event.fromNodeEventEmitter(powerMonitor, 'suspend')(() => {
|
||||
telemetryService.publicLog2<PowerEvent, PowerEventClassification>('power.suspend', getPowerEventData());
|
||||
}));
|
||||
|
||||
this._register(Event.fromNodeEventEmitter(powerMonitor, 'resume')(() => {
|
||||
telemetryService.publicLog2<PowerEvent, PowerEventClassification>('power.resume', getPowerEventData());
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
private async installMutex(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user