Skip to content
Open
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
2 changes: 1 addition & 1 deletion StoreBroker.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
CompanyName = 'Microsoft Corporation'
Copyright = 'Copyright (C) Microsoft Corporation. All rights reserved.'

ModuleVersion = '2.1.16'
ModuleVersion = '2.1.17'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is out of date now, otherwise looks good

Description = 'Provides command-line access to the Windows Store Submission REST API.'

RootModule = 'StoreBroker/StoreIngestionApi.psm1'
Expand Down
62 changes: 30 additions & 32 deletions StoreBroker/Telemetry.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Singleton. Don't directly access this though....always get it
# by calling Get-BaseTelemetryEvent to ensure that it has been initialized and that you're always
# getting a fresh copy.
$script:SBBaseTelemetryEvent = $null
# Maintain a consistent ID for this PowerShell session that we'll use as our telemetry's session ID.
$script:TelemetrySessionId = [System.GUID]::NewGuid().ToString()

# Tracks if we've seen the telemetry reminder this session.
$script:SeenTelemetryReminder = $false

Add-Type -TypeDefinition @"
public enum StoreBrokerTelemetryProperty
Expand Down Expand Up @@ -248,40 +249,37 @@ function Get-BaseTelemetryEvent
[CmdletBinding()]
param()

if ($null -eq $script:SBBaseTelemetryEvent)
if ((-not $script:SeenTelemetryReminder) -and
(-not $global:SBSuppressTelemetryReminder))
{
if (-not $global:SBSuppressTelemetryReminder)
{
Write-Log -Message "Telemetry is currently enabled. It can be disabled by setting ""`$global:SBDisableTelemetry = `$true"". Refer to USAGE.md#telemetry for more information. Stop seeing this message in the future by setting `"`$global:SBSuppressTelemetryReminder=`$true`""
}
Write-Log -Message "Telemetry is currently enabled. It can be disabled by setting ""`$global:SBDisableTelemetry = `$true"". Refer to USAGE.md#telemetry for more information. Stop seeing this message in the future by setting `"`$global:SBSuppressTelemetryReminder=`$true`""
$script:SeenTelemetryReminder = $true
}

$username = Get-PiiSafeString -PlainText $env:USERNAME

$script:SBBaseTelemetryEvent = [PSCustomObject] @{
'name' = 'Microsoft.ApplicationInsights.66d83c523070489b886b09860e05e78a.Event'
'time' = (Get-Date).ToUniversalTime().ToString("O")
'iKey' = $global:SBApplicationInsightsKey
'tags' = [PSCustomObject] @{
'ai.user.id' = $username
'ai.session.id' = [System.GUID]::NewGuid().ToString()
'ai.application.ver' = $MyInvocation.MyCommand.Module.Version.ToString()
'ai.internal.sdkVersion' = '2.0.1.33027' # The version this schema was based off of.
}
$username = Get-PiiSafeString -PlainText $env:USERNAME

return [PSCustomObject] @{
'name' = 'Microsoft.ApplicationInsights.66d83c523070489b886b09860e05e78a.Event'
'time' = (Get-Date).ToUniversalTime().ToString("O")
'iKey' = $global:SBApplicationInsightsKey
'tags' = [PSCustomObject] @{
'ai.user.id' = $username
'ai.session.id' = $script:TelemetrySessionId
'ai.application.ver' = $MyInvocation.MyCommand.Module.Version.ToString()
'ai.internal.sdkVersion' = '2.0.1.33027' # The version this schema was based off of.
}

'data' = [PSCustomObject] @{
'baseType' = 'EventData'
'baseData' = [PSCustomObject] @{
'ver' = 2
'properties' = [PSCustomObject] @{
'DayOfWeek' = (Get-Date).DayOfWeek.ToString()
'Username' = $username
}
'data' = [PSCustomObject] @{
'baseType' = 'EventData'
'baseData' = [PSCustomObject] @{
'ver' = 2
'properties' = [PSCustomObject] @{
'DayOfWeek' = (Get-Date).DayOfWeek.ToString()
'Username' = $username
}
}
}
}

return $script:SBBaseTelemetryEvent.PSObject.Copy() # Get a new instance, not a reference
}

function Invoke-SendTelemetryEvent
Expand Down Expand Up @@ -645,4 +643,4 @@ function Set-TelemetryException
"",
$_.Exception)
}
}
}