Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor DO_NOT_TRACK as well as DOTNET_CLI_TELEMETRY_OPTOUT #17472

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ SDK Version: {1}</value>
<data name="TelemetryMessage" xml:space="preserve">
<value>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Verze sady SDK: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Telemetrie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SDK-Version: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Telemetrie
Expand All @@ -56,4 +56,4 @@ Weitere Informationen zu Telemetriedaten in .NET-CLI-Tools finden Sie hier: http
</trans-unit>
</body>
</file>
</xliff>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Versión del SDK: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Telemetría
Expand All @@ -56,4 +56,4 @@ Lea más sobre la telemetría de las herramientas de la CLI de .NET: https://aka
</trans-unit>
</body>
</file>
</xliff>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Version du kit SDK : {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Télémétrie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Versione SDK: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Telemetria
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SDK バージョン: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">テレメトリ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SDK 버전: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">원격 분석
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Wersja zestawu SDK: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Telemetria
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Versão do SDK: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Telemetria
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SDK Version: {1}</source>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Телеметрия
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SDK Sürümü: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">Telemetri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SDK 版本: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">遥测
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SDK 版本: {1}</target>
<trans-unit id="TelemetryMessage">
<source>Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting either the DOTNET_CLI_TELEMETRY_OPTOUT or DO_NOT_TRACK environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry</source>
<target state="translated">遙測
Expand Down
3 changes: 2 additions & 1 deletion src/Cli/dotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ internal static int ProcessArgs(string[] args, TimeSpan startupTime, ITelemetry
bool generateAspNetCertificate =
environmentProvider.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", defaultValue: true);
bool telemetryOptout =
environmentProvider.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", defaultValue: false);
environmentProvider.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", defaultValue: false)
|| environmentProvider.GetEnvironmentVariableAsBool("DO_NOT_TRACK", defaultValue: false);
bool addGlobalToolsToPath =
environmentProvider.GetEnvironmentVariableAsBool("DOTNET_ADD_GLOBAL_TOOLS_TO_PATH", defaultValue: true);
bool nologo =
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ The primary package cache. If not set, it defaults to $HOME/.nuget/packages on U

Specifies the location of the servicing index to use by the shared host when loading the runtime.

`DOTNET_CLI_TELEMETRY_OPTOUT`
`DO_NOT_TRACK` or `DOTNET_CLI_TELEMETRY_OPTOUT`

Specifies whether data about the .NET Core tools usage is collected and sent to Microsoft. **true** to opt-out of the telemetry feature (values true, 1 or yes accepted); otherwise, **false** (values false, 0 or no accepted). If not set, it defaults to **false**, that is, the telemetry feature is on.
5 changes: 4 additions & 1 deletion src/Cli/dotnet/Telemetry/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Telemetry : ITelemetry

private const string InstrumentationKey = "74cc1c9e-3e6e-4d05-b3fc-dde9101d0254";
private const string TelemetryOptout = "DOTNET_CLI_TELEMETRY_OPTOUT";
private const string TelemetryOptoutCommon = "DO_NOT_TRACK";

public bool Enabled { get; }

Expand All @@ -42,7 +43,9 @@ public Telemetry(
environmentProvider = new EnvironmentProvider();
}

Enabled = !environmentProvider.GetEnvironmentVariableAsBool(TelemetryOptout, false) && PermissionExists(sentinel);
Enabled = !environmentProvider.GetEnvironmentVariableAsBool(TelemetryOptout, false)
&& !environmentProvider.GetEnvironmentVariableAsBool(TelemetryOptoutCommon, false)
&& PermissionExists(sentinel);

if (!Enabled)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ bool telemetrySecondRunShouldBeEnabled
_environmentProvider
.Setup(p => p.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", It.IsAny<bool>()))
.Returns(DOTNET_GENERATE_ASPNET_CERTIFICATE);
// XXX: Handle DO_NOT_TRACK?
_environmentProvider
.Setup(p => p.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", It.IsAny<bool>()))
.Returns(DOTNET_CLI_TELEMETRY_OPTOUT);
Expand Down Expand Up @@ -215,7 +216,8 @@ private Telemetry RunConfigUsingMocks(bool isInstallerRun)
bool generateAspNetCertificate =
_environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true);
bool telemetryOptout =
_environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", false);
_environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", false)
|| _environmentProviderObject.GetEnvironmentVariableAsBool("DO_NOT_TRACK", false);
bool addGlobalToolsToPath =
_environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_ADD_GLOBAL_TOOLS_TO_PATH", defaultValue: true);
bool nologo =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,38 @@ namespace Microsoft.NET.Sdk.Publish.Tasks.Tests
public class EnvironmentHelperTests
{
private const string TelemetryOptout = "DOTNET_CLI_TELEMETRY_OPTOUT";
private const string TelemetryOptoutCommon = "DO_NOT_TRACK";

[Theory]
[InlineData("true", true)]
[InlineData("1", true)]
[InlineData("yes", true)]
[InlineData("false", false)]
[InlineData("0", false)]
[InlineData("no", false)]
[InlineData("anyothervalue", false)]
public void WebConfigTelemetry_RemovesProjectGuid_IfCLIOptedOutEnvVariableIsSet(string value, bool expectedOutput)
[InlineData(TelemetryOptout, "true", true)]
[InlineData(TelemetryOptout, "1", true)]
[InlineData(TelemetryOptout, "yes", true)]
[InlineData(TelemetryOptout, "false", false)]
[InlineData(TelemetryOptout, "0", false)]
[InlineData(TelemetryOptout, "no", false)]
[InlineData(TelemetryOptout, "anyothervalue", false)]
[InlineData(TelemetryOptoutCommon, "true", true)]
[InlineData(TelemetryOptoutCommon, "1", true)]
[InlineData(TelemetryOptoutCommon, "yes", true)]
[InlineData(TelemetryOptoutCommon, "false", false)]
[InlineData(TelemetryOptoutCommon, "0", false)]
[InlineData(TelemetryOptoutCommon, "no", false)]
[InlineData(TelemetryOptoutCommon, "anyothervalue", false)]
public void WebConfigTelemetry_RemovesProjectGuid_IfCLIOptedOutEnvVariableIsSet(string variable, string value, bool expectedOutput)
{
// Arrange
string originalValue = Environment.GetEnvironmentVariable(TelemetryOptout);
Environment.SetEnvironmentVariable(TelemetryOptout, value);
string originalValue = Environment.GetEnvironmentVariable(variable);
Environment.SetEnvironmentVariable(variable, value);

// Act
bool actualOutput = EnvironmentHelper.GetEnvironmentVariableAsBool(TelemetryOptout);
bool actualOutput = EnvironmentHelper.GetEnvironmentVariableAsBool(variable);


// Assert
Assert.Equal<bool>(expectedOutput, actualOutput);

// reset the value back to the original value
Environment.SetEnvironmentVariable(TelemetryOptout, originalValue);
Environment.SetEnvironmentVariable(variable, originalValue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,18 @@ public void ItCreatesAnAspNetCertificateSentinelFileUnderTheDotDotNetFolder()
.HaveFile($"{GetDotnetVersion()}.aspNetCertificateSentinel");
}

[Fact]
public void ItDoesNotCreateAFirstUseSentinelFileNorAnAspNetCertificateSentinelFileUnderTheDotDotNetFolderWhenInternalReportInstallSuccessIsInvoked()
[Theory]
[InlineData("DOTNET_CLI_TELEMETRY_OPTOUT")]
[InlineData("DO_NOT_TRACK")]
public void ItDoesNotCreateAFirstUseSentinelFileNorAnAspNetCertificateSentinelFileUnderTheDotDotNetFolderWhenInternalReportInstallSuccessIsInvoked(string telemetryOptoutVariableName)
{
var dotnetFirstTime = new DotNetFirstTime();

var command = dotnetFirstTime.Setup(Log, _testAssetsManager);

// Disable telemetry to prevent the creation of the .dotnet folder
// for machineid and docker cache files
command = command.WithEnvironmentVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "true");
command = command.WithEnvironmentVariable(telemetryOptoutVariableName, "true");

command.Execute("internal-reportinstallsuccess", "test").Should().Pass();

Expand Down
Loading