mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 16:49:06 +01:00
startup - convert more to workbench contributions
This commit is contained in:
70
src/vs/workbench/parts/cache/node/nodeCachedDataManager.ts
vendored
Normal file
70
src/vs/workbench/parts/cache/node/nodeCachedDataManager.ts
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { basename } from 'path';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
|
||||
declare type OnNodeCachedDataArgs = [{ errorCode: string, path: string, detail?: string }, { path: string, length: number }];
|
||||
declare const MonacoEnvironment: { onNodeCachedData: OnNodeCachedDataArgs[] };
|
||||
|
||||
export class NodeCachedDataManager implements IWorkbenchContribution {
|
||||
|
||||
private readonly _telemetryService: ITelemetryService;
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService
|
||||
) {
|
||||
this._telemetryService = telemetryService;
|
||||
this._handleCachedDataInfo();
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
return 'vs.cache.nodeCachedDataManager';
|
||||
}
|
||||
|
||||
private _handleCachedDataInfo(): void {
|
||||
|
||||
let didRejectCachedData = false;
|
||||
let didProduceCachedData = false;
|
||||
for (const [err, data] of MonacoEnvironment.onNodeCachedData) {
|
||||
// build summary
|
||||
didRejectCachedData = didRejectCachedData || Boolean(err);
|
||||
didProduceCachedData = didProduceCachedData || Boolean(data);
|
||||
|
||||
// log each failure separately
|
||||
if (err) {
|
||||
/* __GDPR__
|
||||
"cachedDataError" : {
|
||||
"errorCode" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
|
||||
"path": { "classification": "CustomerContent", "purpose": "PerformanceAndHealth" }
|
||||
}
|
||||
*/
|
||||
this._telemetryService.publicLog('cachedDataError', {
|
||||
errorCode: err.errorCode,
|
||||
path: basename(err.path)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// log summary
|
||||
/* __GDPR__
|
||||
"cachedDataInfo" : {
|
||||
"didRequestCachedData" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
|
||||
"didRejectCachedData": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
|
||||
"didProduceCachedData": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
}
|
||||
*/
|
||||
this._telemetryService.publicLog('cachedDataInfo', {
|
||||
didRequestCachedData: Boolean(global.require.getConfig().nodeCachedDataDir),
|
||||
didRejectCachedData,
|
||||
didProduceCachedData
|
||||
});
|
||||
|
||||
global.require.config({ onNodeCachedData: undefined });
|
||||
delete MonacoEnvironment.onNodeCachedData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user