Disable telemetry in smoke tests using an env arg

This commit is contained in:
Sandeep Somavarapu
2017-10-04 12:41:27 +02:00
parent 34b4fb6b8b
commit 583e903669
8 changed files with 13 additions and 7 deletions

View File

@@ -99,9 +99,10 @@ function main(server: Server, initData: ISharedProcessInitData): void {
server.registerChannel('telemetryAppender', new TelemetryAppenderChannel(appender));
const services = new ServiceCollection();
const { appRoot, extensionsPath, extensionDevelopmentPath, isBuilt, extensionTestsPath, installSource } = accessor.get(IEnvironmentService);
const environmentService = accessor.get(IEnvironmentService);
const { appRoot, extensionsPath, extensionDevelopmentPath, isBuilt, extensionTestsPath, installSource } = environmentService;
if (isBuilt && !extensionDevelopmentPath && product.enableTelemetry) {
if (isBuilt && !extensionDevelopmentPath && !environmentService.args['disable-telemetry'] && product.enableTelemetry) {
const disableStorage = !!extensionTestsPath; // never keep any state when running extension tests!
const storage = disableStorage ? inMemoryLocalStorageInstance : window.localStorage;
const storageService = new StorageService(storage, storage);

View File

@@ -291,7 +291,7 @@ export class CodeApplication {
services.set(ICredentialsService, new SyncDescriptor(CredentialsService));
// Telemtry
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !!product.enableTelemetry) {
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
const channel = getDelayedChannel<ITelemetryAppenderChannel>(this.sharedProcessClient.then(c => c.getChannel('telemetryAppender')));
const appender = new TelemetryAppenderClient(channel);
const commonProperties = resolveCommonProperties(product.commit, pkg.version, this.environmentService.installSource)

View File

@@ -181,7 +181,7 @@ export function main(argv: ParsedArgs): TPromise<void> {
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
services.set(IChoiceService, new SyncDescriptor(ChoiceCliService));
if (isBuilt && !extensionDevelopmentPath && product.enableTelemetry) {
if (isBuilt && !extensionDevelopmentPath && !envService.args['disable-telemetry'] && product.enableTelemetry) {
const appenders: AppInsightsAppender[] = [];
if (product.aiConfig && product.aiConfig.asimovKey) {

View File

@@ -41,6 +41,7 @@ export interface ParsedArgs {
'open-url'?: string | string[];
'skip-getting-started'?: boolean;
'sticky-quickopen'?: boolean;
'disable-telemetry'?: boolean;
'export-default-configuration'?: string;
'install-source'?: string;
}

View File

@@ -49,7 +49,8 @@ const options: minimist.Opts = {
'show-versions',
'nolazy',
'skip-getting-started',
'sticky-quickopen'
'sticky-quickopen',
'disable-telemetry'
],
alias: {
add: 'a',

View File

@@ -11,7 +11,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
export function addGAParameters(telemetryService: ITelemetryService, environmentService: IEnvironmentService, uri: URI, origin: string, experiment = '1'): TPromise<URI> {
if (environmentService.isBuilt && !environmentService.isExtensionDevelopment && !!product.enableTelemetry) {
if (environmentService.isBuilt && !environmentService.isExtensionDevelopment && !environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
if (uri.scheme === 'https' && uri.authority === 'code.visualstudio.com') {
return telemetryService.getTelemetryInfo()
.then(info => {

View File

@@ -299,7 +299,7 @@ export class WorkbenchShell {
// Telemetry
this.sendMachineIdToMain(this.storageService);
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !!product.enableTelemetry) {
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
const channel = getDelayedChannel<ITelemetryAppenderChannel>(sharedProcess.then(c => c.getChannel('telemetryAppender')));
const commit = product.commit;
const version = pkg.version;

View File

@@ -126,6 +126,9 @@ export class SpectronApplication {
// Prevent Quick Open from closing when focus is stolen, this allows concurrent smoketest suite running
args.push('--sticky-quickopen');
// Disable telemetry for smoke tests
args.push('--disable-telemetry');
// Ensure that running over custom extensions directory, rather than picking up the one that was used by a tester previously
args.push(`--extensions-dir=${EXTENSIONS_DIR}`);