Skip to content

Commit

Permalink
Update the link and message color.
Browse files Browse the repository at this point in the history
  • Loading branch information
kceiw committed Feb 8, 2021
1 parent 7b69536 commit 8233d40
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tools/Az.Tools.Predictor/Az.Tools.Predictor/InterceptSurvey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $mutexTiimeout = 1000
$interceptDays = 30
$interceptLoadTimes = 3
$today = Get-Date
$mutexTimeout = 500

function ConvertTo-String {
param (
Expand Down Expand Up @@ -120,7 +121,12 @@ function Update-InterceptObject {

$mutex = New-Object System.Threading.Mutex($false, $mutexName)

$mutex.WaitOne($mutexTimeout)
$hasMutex = $mutex.WaitOne($mutexTimeout)

if (-not $hasMutex) {
return
}

$shouldIntercept = $false

try
Expand Down Expand Up @@ -154,11 +160,11 @@ Write-Host "To enable suggestions from Az predictor, run: Set-PSReadLineOption -

if ($shouldIntercept) {
$userId = (Get-AzContext).Account.Id
$surveyId = "000000"

if ($userId -ne $null)
{
$surveyId = Get-Random -Maximum 1000000 -SetSeed $userId.GetHashCode()
Write-Host "We are listening, please share your feedback about Az Predictor: http://aka.ms/azpredictorsurvey?iQ_CHL=intercept&surveyId=$surveyId"

try {
$azPredictorSettingFilePath = Join-Path -Path (Join-Path -Path $env:USERPROFILE -ChildPath ".Azure") -ChildPath "AzPredictorSettings.json"
$setting = @{
Expand All @@ -168,15 +174,15 @@ if ($shouldIntercept) {
if (Test-Path $azPredictorSettingFilePath) {
try {
$setting = Get-Content $azPredictorSettingFilePath | Out-String | ConvertFrom-Json
$setting | Add-Member -NotePropertyName "surveyId" -NotePropertyValue $surveyId
$setting | Add-Member -NotePropertyName "surveyId" -NotePropertyValue $surveyId -Force
} catch {
}
}

ConvertTo-Json -InputObject $setting | Out-File -FilePath $azPredictorSettingFilePath -Encoding utf8
} catch {
}
} else {
Write-Host "We are listening, please share your feedback about Az Predictor: http://aka.ms/azpredictorsurvey?iQ_CHL=intercept"
}

Write-Host "How was your experience using Az predictor? " -NoNewLine -ForegroundColor $host.privatedata.WarningForegroundColor -BackgroundColor $host.privatedata.WarningBackgroundColor ; Write-Host "http://aka.ms/azpredictorisurvey?SessionId=$surveyId" -ForegroundColor Cyan -BackgroundColor $host.privatedata.WarningBackgroundColor
}

0 comments on commit 8233d40

Please sign in to comment.