Add Warning if we fail to disable SDK Telemetry
This commit is contained in:
Родитель
919442fb0d
Коммит
8e06ab0b41
|
@ -70,11 +70,13 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
||||||
extensionContext.extensionConfiguration :
|
extensionContext.extensionConfiguration :
|
||||||
vscode.workspace.getConfiguration(configPrefix);
|
vscode.workspace.getConfiguration(configPrefix);
|
||||||
|
|
||||||
|
const extensionTelemetryEnabled = enableExtensionTelemetry(extensionConfiguration, configKeys.enableTelemetry);
|
||||||
|
|
||||||
const eventStreamContext = {
|
const eventStreamContext = {
|
||||||
displayChannelName,
|
displayChannelName,
|
||||||
logPath: context.logPath,
|
logPath: context.logPath,
|
||||||
extensionId: dotnetCoreAcquisitionExtensionId,
|
extensionId: dotnetCoreAcquisitionExtensionId,
|
||||||
enableTelemetry: enableExtensionTelemetry(extensionConfiguration, configKeys.enableTelemetry),
|
enableTelemetry: extensionTelemetryEnabled,
|
||||||
telemetryReporter: extensionContext ? extensionContext.telemetryReporter : undefined,
|
telemetryReporter: extensionContext ? extensionContext.telemetryReporter : undefined,
|
||||||
showLogCommand: `${commandPrefix}.${commandKeys.showAcquisitionLog}`,
|
showLogCommand: `${commandPrefix}.${commandKeys.showAcquisitionLog}`,
|
||||||
packageJson,
|
packageJson,
|
||||||
|
@ -112,7 +114,8 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
||||||
installationValidator: new InstallationValidator(eventStream),
|
installationValidator: new InstallationValidator(eventStream),
|
||||||
timeoutValue: resolvedTimeoutSeconds,
|
timeoutValue: resolvedTimeoutSeconds,
|
||||||
installDirectoryProvider: new RuntimeInstallationDirectoryProvider(context.globalStoragePath),
|
installDirectoryProvider: new RuntimeInstallationDirectoryProvider(context.globalStoragePath),
|
||||||
proxyUrl: proxyLink
|
proxyUrl: proxyLink,
|
||||||
|
isExtensionTelemetryInitiallyEnabled: extensionTelemetryEnabled
|
||||||
});
|
});
|
||||||
const existingPathResolver = new ExistingPathResolver();
|
const existingPathResolver = new ExistingPathResolver();
|
||||||
const versionResolver = new VersionResolver(context.globalState, eventStream, resolvedTimeoutSeconds, proxyLink);
|
const versionResolver = new VersionResolver(context.globalState, eventStream, resolvedTimeoutSeconds, proxyLink);
|
||||||
|
@ -197,4 +200,5 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
||||||
ensureDependenciesRegistration,
|
ensureDependenciesRegistration,
|
||||||
reportIssueRegistration,
|
reportIssueRegistration,
|
||||||
...eventStreamObservers);
|
...eventStreamObservers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ export function registerEventStream(context: IEventStreamContext): [EventStream,
|
||||||
|
|
||||||
const logFile = path.join(context.logPath, `DotNetAcquisition-${context.extensionId}-${ new Date().getTime() }.txt`);
|
const logFile = path.join(context.logPath, `DotNetAcquisition-${context.extensionId}-${ new Date().getTime() }.txt`);
|
||||||
const loggingObserver = new LoggingObserver(logFile);
|
const loggingObserver = new LoggingObserver(logFile);
|
||||||
let eventStreamObservers: IEventStreamObserver[] =
|
const eventStreamObservers: IEventStreamObserver[] =
|
||||||
[
|
[
|
||||||
new StatusBarObserver(vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, Number.MIN_VALUE), context.showLogCommand),
|
new StatusBarObserver(vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, Number.MIN_VALUE), context.showLogCommand),
|
||||||
new OutputChannelObserver(outputChannel),
|
new OutputChannelObserver(outputChannel),
|
||||||
|
|
|
@ -80,7 +80,11 @@ export class TelemetryObserver implements IEventStreamObserver {
|
||||||
if(!TelemetryObserver.isTelemetryEnabled(isExtensionTelemetryEnabled))
|
if(!TelemetryObserver.isTelemetryEnabled(isExtensionTelemetryEnabled))
|
||||||
{
|
{
|
||||||
TelemetryObserver.logTelemetryChange(`Before disabling .NET SDK telemetry:`, isExtensionTelemetryEnabled, eventStream);
|
TelemetryObserver.logTelemetryChange(`Before disabling .NET SDK telemetry:`, isExtensionTelemetryEnabled, eventStream);
|
||||||
new CommandExecutor(eventStream).setEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT', 'true');
|
|
||||||
|
new CommandExecutor(eventStream).setEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT', 'true',
|
||||||
|
`Telemetry is disabled for VS Code & the .NET Install Tool Extension, but the .NET SDK extension may still collect telemetry and we may not have successfully turned it off.
|
||||||
|
Please verify that .NET SDK telemetry is disabled by setting the environment variable DOTNET_CLI_TELEMETRY_OPTOUT to true.`);
|
||||||
|
|
||||||
TelemetryObserver.logTelemetryChange(`After disabling .NET SDK telemetry:`, isExtensionTelemetryEnabled, eventStream);
|
TelemetryObserver.logTelemetryChange(`After disabling .NET SDK telemetry:`, isExtensionTelemetryEnabled, eventStream);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -22,6 +22,7 @@ import path = require('path');
|
||||||
import { IEventStream } from '../EventStream/EventStream';
|
import { IEventStream } from '../EventStream/EventStream';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
|
import { WindowDisplayWorker } from '../EventStream/WindowDisplayWorker';
|
||||||
|
|
||||||
/* tslint:disable:no-any */
|
/* tslint:disable:no-any */
|
||||||
|
|
||||||
|
@ -211,21 +212,51 @@ out: ${commandResult.stdout} err: ${commandResult.stderr}.`));
|
||||||
return [workingCommand, working];
|
return [workingCommand, working];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setEnvironmentVariable(variable : string, value : string)
|
public async setEnvironmentVariable(variable : string, value : string, failureWarningMessage? : string)
|
||||||
{
|
{
|
||||||
// todo: verify this works on all os
|
// todo: verify this works on all os
|
||||||
|
const oldReturnStatusSetting = this.returnStatus;
|
||||||
|
this.returnStatus = true;
|
||||||
|
let environmentEditExitCode = 0;
|
||||||
|
|
||||||
process.env[variable] = value;
|
process.env[variable] = value;
|
||||||
if(os.platform() === 'win32')
|
if(os.platform() === 'win32')
|
||||||
{
|
{
|
||||||
const setShellVariable = `set ${variable}=${value}`;
|
const setShellVariable = `set ${variable}=${value}`;
|
||||||
const setSystemVariable = `setx ${variable} "${value}"`;
|
const setSystemVariable = `setx ${variable} "${value}"`;
|
||||||
await this.execute(setShellVariable);
|
try
|
||||||
await this.execute(setSystemVariable);
|
{
|
||||||
|
environmentEditExitCode = environmentEditExitCode || Number((await this.execute(setShellVariable))[0]);
|
||||||
|
environmentEditExitCode = environmentEditExitCode || Number((await this.execute(setSystemVariable))[0]);
|
||||||
|
}
|
||||||
|
catch(error)
|
||||||
|
{
|
||||||
|
if(failureWarningMessage)
|
||||||
|
{
|
||||||
|
new WindowDisplayWorker().showWarningMessage(failureWarningMessage, () => {/* No Callback */}, );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const setVariable = `${variable}=${value} && export ${variable}`
|
const setVariable = `${variable}=${value} && export ${variable}`
|
||||||
await this.execute(setVariable);
|
try
|
||||||
|
{
|
||||||
|
environmentEditExitCode = environmentEditExitCode || Number((await this.execute(setVariable))[0]);;
|
||||||
|
}
|
||||||
|
catch(error)
|
||||||
|
{
|
||||||
|
if(failureWarningMessage)
|
||||||
|
{
|
||||||
|
new WindowDisplayWorker().showWarningMessage(failureWarningMessage, () => {/* No Callback */}, );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(environmentEditExitCode && failureWarningMessage)
|
||||||
|
{
|
||||||
|
new WindowDisplayWorker().showWarningMessage(failureWarningMessage, () => {/* No Callback */}, );
|
||||||
|
}
|
||||||
|
this.returnStatus = oldReturnStatusSetting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,6 @@ export class FileUtilities extends IFileUtilities
|
||||||
|
|
||||||
public async getFileHash(filePath : string) : Promise<string | null>
|
public async getFileHash(filePath : string) : Promise<string | null>
|
||||||
{
|
{
|
||||||
|
|
||||||
const res = await this.sha512Hasher(filePath);
|
const res = await this.sha512Hasher(filePath);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* ------------------------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------------------------ */
|
||||||
/* tslint:disable:no-any */
|
/* tslint:disable:no-any */
|
||||||
|
|
||||||
import { IEventStream } from "../EventStream/EventStream";
|
import { IEventStream } from '../EventStream/EventStream';
|
||||||
|
|
||||||
export abstract class IFileUtilities
|
export abstract class IFileUtilities
|
||||||
{
|
{
|
||||||
|
|
|
@ -189,14 +189,14 @@ export class WebRequestWorker
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const finished = promisify(stream.finished);
|
const isFinished = promisify(stream.finished);
|
||||||
const file = fs.createWriteStream(dest, { flags: 'wx' });
|
const file = fs.createWriteStream(dest, { flags: 'wx' });
|
||||||
const options = await this.getAxiosOptions(3, {responseType: 'stream', transformResponse: (x : any) => x}, false);
|
const options = await this.getAxiosOptions(3, {responseType: 'stream', transformResponse: (x : any) => x}, false);
|
||||||
await this.axiosGet(url, options)
|
await this.axiosGet(url, options)
|
||||||
.then(response =>
|
.then(response =>
|
||||||
{
|
{
|
||||||
response.data.pipe(file);
|
response.data.pipe(file);
|
||||||
return finished(file);
|
return isFinished(file);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,9 +295,9 @@ export class MockFileUtilities extends IFileUtilities
|
||||||
{
|
{
|
||||||
private trueUtilities = new FileUtilities();
|
private trueUtilities = new FileUtilities();
|
||||||
|
|
||||||
public writeFileOntoDisk(content : string, path : string)
|
public writeFileOntoDisk(content : string, filePath : string)
|
||||||
{
|
{
|
||||||
return this.trueUtilities.writeFileOntoDisk(content, path, new MockEventStream());
|
return this.trueUtilities.writeFileOntoDisk(content, filePath, new MockEventStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public wipeDirectory(directoryToWipe : string)
|
public wipeDirectory(directoryToWipe : string)
|
||||||
|
|
|
@ -56,7 +56,8 @@ suite('DotnetCoreAcquisitionWorker Unit Tests', function () {
|
||||||
installationValidator: new MockInstallationValidator(eventStream),
|
installationValidator: new MockInstallationValidator(eventStream),
|
||||||
timeoutValue: 10,
|
timeoutValue: 10,
|
||||||
installDirectoryProvider: runtimeInstall ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
installDirectoryProvider: runtimeInstall ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
||||||
installingArchitecture: arch
|
installingArchitecture: arch,
|
||||||
|
isExtensionTelemetryInitiallyEnabled: true
|
||||||
});
|
});
|
||||||
return [acquisitionWorker, eventStream, context];
|
return [acquisitionWorker, eventStream, context];
|
||||||
}
|
}
|
||||||
|
@ -72,6 +73,7 @@ suite('DotnetCoreAcquisitionWorker Unit Tests', function () {
|
||||||
installationValidator: new MockInstallationValidator(eventStream),
|
installationValidator: new MockInstallationValidator(eventStream),
|
||||||
timeoutValue: 10,
|
timeoutValue: 10,
|
||||||
installDirectoryProvider: runtimeInstall ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
installDirectoryProvider: runtimeInstall ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
||||||
|
isExtensionTelemetryInitiallyEnabled: true
|
||||||
});
|
});
|
||||||
return [acquisitionWorker, eventStream, context];
|
return [acquisitionWorker, eventStream, context];
|
||||||
}
|
}
|
||||||
|
@ -304,6 +306,7 @@ suite('DotnetCoreAcquisitionWorker Unit Tests', function () {
|
||||||
installationValidator: new MockInstallationValidator(eventStream),
|
installationValidator: new MockInstallationValidator(eventStream),
|
||||||
timeoutValue: 10,
|
timeoutValue: 10,
|
||||||
installDirectoryProvider: new RuntimeInstallationDirectoryProvider(''),
|
installDirectoryProvider: new RuntimeInstallationDirectoryProvider(''),
|
||||||
|
isExtensionTelemetryInitiallyEnabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
return assert.isRejected(acquisitionWorker.acquireRuntime('1.0'), '.NET Acquisition Failed: Installation failed: Rejecting message');
|
return assert.isRejected(acquisitionWorker.acquireRuntime('1.0'), '.NET Acquisition Failed: Installation failed: Rejecting message');
|
||||||
|
|
|
@ -21,6 +21,7 @@ export function getMockAcquiringContext(runtimeInstall: boolean, timeoutTime : n
|
||||||
installationValidator: new MockInstallationValidator(eventStream),
|
installationValidator: new MockInstallationValidator(eventStream),
|
||||||
timeoutValue: timeoutTime,
|
timeoutValue: timeoutTime,
|
||||||
installDirectoryProvider: runtimeInstall ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
installDirectoryProvider: runtimeInstall ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
||||||
|
isExtensionTelemetryInitiallyEnabled: true
|
||||||
};
|
};
|
||||||
return workerContext;
|
return workerContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ suite('WebRequestWorker Unit Tests', () => {
|
||||||
installationValidator: new MockInstallationValidator(eventStream),
|
installationValidator: new MockInstallationValidator(eventStream),
|
||||||
timeoutValue: 10,
|
timeoutValue: 10,
|
||||||
installDirectoryProvider: new RuntimeInstallationDirectoryProvider(''),
|
installDirectoryProvider: new RuntimeInstallationDirectoryProvider(''),
|
||||||
|
isExtensionTelemetryInitiallyEnabled: true
|
||||||
});
|
});
|
||||||
return assert.isRejected(acquisitionWorker.acquireRuntime('1.0'), Error, '.NET Acquisition Failed');
|
return assert.isRejected(acquisitionWorker.acquireRuntime('1.0'), Error, '.NET Acquisition Failed');
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,6 +29,7 @@ suite('Windows & Mac Global Installer Tests', () =>
|
||||||
installationValidator: new MockInstallationValidator(eventStream),
|
installationValidator: new MockInstallationValidator(eventStream),
|
||||||
timeoutValue: standardTimeoutTime,
|
timeoutValue: standardTimeoutTime,
|
||||||
installDirectoryProvider: runtimeInstall ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
installDirectoryProvider: runtimeInstall ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
||||||
|
isExtensionTelemetryInitiallyEnabled: true,
|
||||||
};
|
};
|
||||||
return workerContext;
|
return workerContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,11 +74,12 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
||||||
extensionContext.extensionConfiguration :
|
extensionContext.extensionConfiguration :
|
||||||
vscode.workspace.getConfiguration(configPrefix);
|
vscode.workspace.getConfiguration(configPrefix);
|
||||||
|
|
||||||
|
const isExtensionTelemetryEnabled = enableExtensionTelemetry(extensionConfiguration, configKeys.enableTelemetry);
|
||||||
const eventStreamContext = {
|
const eventStreamContext = {
|
||||||
displayChannelName,
|
displayChannelName,
|
||||||
logPath: context.logPath,
|
logPath: context.logPath,
|
||||||
extensionId: dotnetCoreAcquisitionExtensionId,
|
extensionId: dotnetCoreAcquisitionExtensionId,
|
||||||
enableTelemetry: enableExtensionTelemetry(extensionConfiguration, configKeys.enableTelemetry),
|
enableTelemetry: isExtensionTelemetryEnabled,
|
||||||
telemetryReporter: extensionContext ? extensionContext.telemetryReporter : undefined,
|
telemetryReporter: extensionContext ? extensionContext.telemetryReporter : undefined,
|
||||||
showLogCommand: `${commandPrefix}.${commandKeys.showAcquisitionLog}`,
|
showLogCommand: `${commandPrefix}.${commandKeys.showAcquisitionLog}`,
|
||||||
packageJson,
|
packageJson,
|
||||||
|
@ -116,12 +117,6 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vscode.env.onDidChangeTelemetryEnabled((_: boolean) =>
|
|
||||||
{
|
|
||||||
console.log('foo');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const acquisitionWorker = new DotnetCoreAcquisitionWorker({
|
const acquisitionWorker = new DotnetCoreAcquisitionWorker({
|
||||||
storagePath,
|
storagePath,
|
||||||
extensionState: context.globalState,
|
extensionState: context.globalState,
|
||||||
|
@ -130,7 +125,8 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
||||||
installationValidator: new InstallationValidator(eventStream),
|
installationValidator: new InstallationValidator(eventStream),
|
||||||
timeoutValue: resolvedTimeoutSeconds,
|
timeoutValue: resolvedTimeoutSeconds,
|
||||||
installDirectoryProvider: new SdkInstallationDirectoryProvider(storagePath),
|
installDirectoryProvider: new SdkInstallationDirectoryProvider(storagePath),
|
||||||
acquisitionContext : null
|
acquisitionContext : null,
|
||||||
|
isExtensionTelemetryInitiallyEnabled : isExtensionTelemetryEnabled
|
||||||
});
|
});
|
||||||
|
|
||||||
const versionResolver = new VersionResolver(context.globalState, eventStream, resolvedTimeoutSeconds);
|
const versionResolver = new VersionResolver(context.globalState, eventStream, resolvedTimeoutSeconds);
|
||||||
|
|
|
@ -153,6 +153,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function()
|
||||||
installationValidator: new MockInstallationValidator(eventStream),
|
installationValidator: new MockInstallationValidator(eventStream),
|
||||||
timeoutValue: 10,
|
timeoutValue: 10,
|
||||||
installDirectoryProvider,
|
installDirectoryProvider,
|
||||||
|
isExtensionTelemetryInitiallyEnabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const version = currentSDKVersion;
|
const version = currentSDKVersion;
|
||||||
|
@ -202,6 +203,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function()
|
||||||
installationValidator: new MockInstallationValidator(eventStream),
|
installationValidator: new MockInstallationValidator(eventStream),
|
||||||
timeoutValue: 10,
|
timeoutValue: 10,
|
||||||
installDirectoryProvider,
|
installDirectoryProvider,
|
||||||
|
isExtensionTelemetryInitiallyEnabled: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const version = currentSDKVersion;
|
const version = currentSDKVersion;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче