Move appenders to be better controlled by services (#133465)

* Cleanup telemetry appenders to be owned by service

* Add telemetry level to services

* simplify

* Fix compile

* Rename supportsTelemetryLogging -> supportsTelemetry

Co-authored-by: SteVen Batten <sbatten@microsoft.com>
This commit is contained in:
Logan Ramos
2021-09-22 10:39:57 -04:00
committed by GitHub
parent 758daa73e3
commit 12ae331012
23 changed files with 144 additions and 171 deletions

View File

@@ -65,10 +65,10 @@ import { IStateMainService } from 'vs/platform/state/electron-main/state';
import { StorageDatabaseChannel } from 'vs/platform/storage/electron-main/storageIpc';
import { IStorageMainService, StorageMainService } from 'vs/platform/storage/electron-main/storageMainService';
import { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProperties';
import { ITelemetryService, machineIdKey, TelemetryConfiguration, TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
import { ITelemetryService, machineIdKey, TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
import { TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryIpc';
import { ITelemetryServiceConfig, TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
import { NullTelemetryService, getTelemetryLevel, getTelemetryConfiguration } from 'vs/platform/telemetry/common/telemetryUtils';
import { getTelemetryLevel, NullTelemetryService, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
import { IUpdateService } from 'vs/platform/update/common/update';
import { UpdateChannel } from 'vs/platform/update/common/updateIpc';
import { DarwinUpdateService } from 'vs/platform/update/electron-main/updateService.darwin';
@@ -531,12 +531,12 @@ export class CodeApplication extends Disposable {
services.set(IURLService, new SyncDescriptor(NativeURLService));
// Telemetry
if (getTelemetryLevel(this.productService, this.environmentMainService) >= TelemetryLevel.USER) {
if (supportsTelemetry(this.productService, this.environmentMainService)) {
const channel = getDelayedChannel(sharedProcessReady.then(client => client.getChannel('telemetryAppender')));
const appender = new TelemetryAppenderClient(channel);
const commonProperties = resolveCommonProperties(this.fileService, release(), hostname(), process.arch, this.productService.commit, this.productService.version, machineId, this.productService.msftInternalDomains, this.environmentMainService.installSourcePath);
const piiPaths = [this.environmentMainService.appRoot, this.environmentMainService.extensionsPath];
const config: ITelemetryServiceConfig = { appender, commonProperties, piiPaths, sendErrorTelemetry: true };
const config: ITelemetryServiceConfig = { appenders: [appender], commonProperties, piiPaths, sendErrorTelemetry: true };
services.set(ITelemetryService, new SyncDescriptor(TelemetryService, [config]));
} else {
@@ -981,8 +981,8 @@ export class CodeApplication extends Disposable {
const argvString = argvContent.value.toString();
const argvJSON = JSON.parse(stripComments(argvString));
if (argvJSON['enable-crash-reporter'] === undefined) {
const telemetryConfig = getTelemetryConfiguration(this.configurationService);
const enableCrashReporterSetting = telemetryConfig === TelemetryConfiguration.ON || telemetryConfig === TelemetryConfiguration.ERROR;
const telemetryConfig = getTelemetryLevel(this.configurationService);
const enableCrashReporterSetting = telemetryConfig >= TelemetryLevel.ERROR;
const enableCrashReporter = typeof enableCrashReporterSetting === 'boolean' ? enableCrashReporterSetting : true;
const additionalArgvContent = [
'',
@@ -1044,3 +1044,4 @@ export class CodeApplication extends Disposable {
});
}
}