diff --git a/.gitignore b/.gitignore index 5e0a2cf5b16..4d4e69760b4 100644 --- a/.gitignore +++ b/.gitignore @@ -46,9 +46,6 @@ dotnet-uninstall-debian-packages.sh *.nupkg *.AppImage -# ignore the telemetry semaphore file -DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY - # default location for produced nuget packages /nuget-artifacts diff --git a/.travis.yml b/.travis.yml index 898cda2f514..9298ab22700 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,7 +57,9 @@ after_success: # travis-ci will quit using the cache if an enviroment variable changes env: - - CACHE_VERSION=netcoreapp.2.0.6-sdk.2.1.4 + global: + - CACHE_VERSION=netcoreapp.2.0.6-sdk.2.1.4 + - POWERSHELL_TELEMETRY_OPTOUT=1 # timeout uploading cache after 6 minutes (360 seconds) cache: diff --git a/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY b/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY new file mode 100644 index 00000000000..e69de29bb2d diff --git a/README.md b/README.md index 3ff3bb15855..07a25e91491 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ License: By requesting and using the Container OS Image for Windows containers, ### Telemetry By default, PowerShell collects the OS description and the version of PowerShell (equivalent to `$PSVersionTable.OS` and `$PSVersionTable.GitCommitId`) using [Application Insights](https://azure.microsoft.com/en-us/services/application-insights/). -To opt-out of sending telemetry, delete the file `DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY` before starting PowerShell from the installed location. +To opt-out of sending telemetry, create an environment variable called `POWERSHELL_TELEMETRY_OPTOUT` set to a value of `1` before starting PowerShell from the installed location. The telemetry we collect fall under the [Microsoft Privacy Statement](https://privacy.microsoft.com/en-us/privacystatement/). ## Governance diff --git a/appveyor.yml b/appveyor.yml index 5d52f914402..2dd6198324d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,6 +10,9 @@ cache: nuget: project_feed: true +environment: + POWERSHELL_TELEMETRY_OPTOUT: 1 + install: - git submodule update --init - ps: Import-Module .\tools\Appveyor.psm1 diff --git a/assets/files.wxs b/assets/files.wxs index 8e8d60b9799..b33e2e2fb7d 100644 --- a/assets/files.wxs +++ b/assets/files.wxs @@ -193,9 +193,6 @@ - - - @@ -1890,7 +1887,6 @@ - diff --git a/build.psm1 b/build.psm1 index 2bb5f6c243f..d5a4c6ab379 100644 --- a/build.psm1 +++ b/build.psm1 @@ -453,9 +453,6 @@ function Start-PSBuild { } } - # create the telemetry flag file - $null = new-item -force -type file "$psscriptroot/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY" - # Add .NET CLI tools to PATH Find-Dotnet @@ -1054,7 +1051,9 @@ Restore the module to '$Pester' by running: Publish-PSTestTools | ForEach-Object {Write-Host $_} # All concatenated commands/arguments are suffixed with the delimiter (space) - $command = "" + + # Disable telemetry for all startups of pwsh in tests + $command = "`$env:POWERSHELL_TELEMETRY_OPTOUT = 1;" if ($Terse) { $command += "`$ProgressPreference = 'silentlyContinue'; " @@ -1155,6 +1154,8 @@ Restore the module to '$Pester' by running: # To ensure proper testing, the module path must not be inherited by the spawned process try { $originalModulePath = $env:PSModulePath + $originalTelemetry = $env:POWERSHELL_TELEMETRY_OPTOUT + $env:POWERSHELL_TELEMETRY_OPTOUT = 1 if ($Unelevate) { Start-UnelevatedProcess -process $powershell -arguments @('-noprofile', '-c', $Command) @@ -1231,6 +1232,7 @@ Restore the module to '$Pester' by running: } } finally { $env:PSModulePath = $originalModulePath + $env:POWERSHELL_TELEMETRY_OPTOUT = $originalTelemetry if ($Unelevate) { Remove-Item $outputBufferFilePath diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs index 12008425843..4548d3b8145 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs @@ -19,18 +19,9 @@ namespace Microsoft.PowerShell /// internal static class ApplicationInsightsTelemetry { - // The semaphore file which indicates whether telemetry should be sent - // This is temporary code waiting on the acceptance and implementation of the configuration spec - // The name of the file by when present in $PSHOME will enable telemetry. - // If this file is not present, no telemetry will be sent. - private const string TelemetrySemaphoreFilename = "DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY"; + // If this env var is true, yes, or 1, telemetry will NOT be sent. private const string TelemetryOptoutEnvVar = "POWERSHELL_TELEMETRY_OPTOUT"; - // The path to the semaphore file which enables telemetry - private static string TelemetrySemaphoreFilePath = Path.Combine( - Utils.DefaultPowerShellAppBase, - TelemetrySemaphoreFilename); - // Telemetry client to be reused when we start sending more telemetry private static TelemetryClient _telemetryClient = null; @@ -75,8 +66,7 @@ private static void SendTelemetry(string eventName, Dictionarypay { try { - // if the semaphore file exists, try to send telemetry - var enabled = Utils.NativeFileExists(TelemetrySemaphoreFilePath) && !GetEnvironmentVariableAsBool(TelemetryOptoutEnvVar, false); + var enabled = !GetEnvironmentVariableAsBool(name : TelemetryOptoutEnvVar, defaultValue : false); if (!enabled) { diff --git a/src/powershell-unix/powershell-unix.csproj b/src/powershell-unix/powershell-unix.csproj index 947af707237..d49023ef59d 100644 --- a/src/powershell-unix/powershell-unix.csproj +++ b/src/powershell-unix/powershell-unix.csproj @@ -16,7 +16,7 @@ PreserveNewest PreserveNewest - + PreserveNewest PreserveNewest diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index 136ab9e1df7..1c767029390 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -20,7 +20,7 @@ PreserveNewest PreserveNewest - + PreserveNewest PreserveNewest diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index d290e394a23..483e8433079 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -347,12 +347,6 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Running all CoreCLR tests..' } - # Remove telemetry semaphore file in CI - $telemetrySemaphoreFilepath = Join-Path $env:CoreOutput DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY - if ( Test-Path "${telemetrySemaphoreFilepath}" ) { - Remove-Item -Force ${telemetrySemaphoreFilepath} - } - Start-PSPester -Terse -bindir $env:CoreOutput -outputFile $testResultsNonAdminFile -Unelevate -Tag @() -ExcludeTag ($ExcludeTag + @('RequireAdminOnWindows')) Write-Host -Foreground Green 'Upload CoreCLR Non-Admin test results' Update-AppVeyorTestResults -resultsFile $testResultsNonAdminFile diff --git a/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh b/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh index 4cc8a1c5348..2624f2b6d96 100755 --- a/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh +++ b/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh @@ -53,9 +53,6 @@ make -j cd ../.. dotnet restore $dotnetArguments -# Add telemetry file -touch DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY - # run ResGen cd src/ResGen dotnet run diff --git a/tools/travis.ps1 b/tools/travis.ps1 index ae13cd28812..94b37d7fc07 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -224,12 +224,6 @@ elseif($Stage -eq 'Build') $pesterParam['IncludeFailingTest'] = $true } - # Remove telemetry semaphore file in CI - $telemetrySemaphoreFilepath = Join-Path $output DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY - if ( Test-Path "${telemetrySemaphoreFilepath}" ) { - Remove-Item -force ${telemetrySemaphoreFilepath} - } - # Running tests which do not require sudo. $pesterPassThruNoSudoObject = Start-PSPester @pesterParam