startup - convert more to workbench contributions

This commit is contained in:
Benjamin Pasero
2017-11-13 18:45:32 +01:00
parent ecb2beb5bf
commit 79f3ea1ebe
6 changed files with 34 additions and 34 deletions

View 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;
}
}