Skip to content

Commit c0ae2f6

Browse files
authored
debt - resolve machineId when window crashes (microsoft#167070)
* debt - resolve machineId when window crashes * use state service
1 parent c646be0 commit c0ae2f6

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

src/vs/platform/windows/electron-main/windowImpl.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeH
4747
import { OneDataSystemAppender } from 'vs/platform/telemetry/node/1dsAppender';
4848
import { ITelemetryServiceConfig, TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
4949
import { getPiiPathsFromEnvironment, isInternalTelemetry, ITelemetryAppender, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
50-
import { Promises } from 'vs/base/node/pfs';
5150
import { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProperties';
5251
import { hostname, release } from 'os';
5352

@@ -784,19 +783,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
784783
const config: ITelemetryServiceConfig = {
785784
appenders,
786785
sendErrorTelemetry: false,
787-
commonProperties: (async () => {
788-
let machineId: string | undefined = undefined;
789-
try {
790-
const storageContents = await Promises.readFile(this.environmentMainService.stateResource.fsPath);
791-
machineId = JSON.parse(storageContents.toString())[machineIdKey];
792-
} catch (error) {
793-
if (error.code !== 'ENOENT') {
794-
this.logService.error(error);
795-
}
796-
}
797-
798-
return resolveCommonProperties(this.fileService, release(), hostname(), process.arch, this.productService.commit, this.productService.version, machineId, isInternal, installSourcePath);
799-
})(),
786+
commonProperties: resolveCommonProperties(this.fileService, release(), hostname(), process.arch, this.productService.commit, this.productService.version, this.stateMainService.getItem<string>(machineIdKey), isInternal, installSourcePath),
800787
piiPaths: getPiiPathsFromEnvironment(this.environmentMainService)
801788
};
802789

@@ -812,7 +799,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
812799
reason: string | undefined;
813800
code: number | undefined;
814801
};
815-
telemetryService.publicLog2<WindowAdminErrorEvent, WindowAdminErrorClassification>('windowadminerror', { reason: details.reason, code: details.exitCode });
802+
await telemetryService.publicLog2<WindowAdminErrorEvent, WindowAdminErrorClassification>('windowadminerror', { reason: details.reason, code: details.exitCode });
816803
}
817804

818805
// Inform user
@@ -829,7 +816,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
829816
}, this._win);
830817

831818
// Ensure to await flush telemetry
832-
await Promise.all(appenders.map(a => a.flush()));
819+
await Promise.all(appenders.map(appender => appender.flush()));
833820

834821
// Exit
835822
await this.destroyWindow(false, false);

0 commit comments

Comments
 (0)