Skip to content

Commit 7cb8073

Browse files
authored
Merge pull request #374 from microsoft/dev
Sync branches
2 parents 3ed23aa + d480099 commit 7cb8073

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

Scripts/0_Shared.ps1

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ function Get-TelemetryLevelSource {
116116
process {
117117
$acceptedTelemetryLevels = "None", "Basic", "Full"
118118

119+
# Is it set interactively?
120+
if($LabConfig.ContainsKey("TelemetryLevelSource")) {
121+
return $LabConfig.TelemetryLevelSource
122+
}
123+
119124
# LabConfig value has a priority
120125
if($LabConfig.TelemetryLevel -and $LabConfig.TelemetryLevel -in $acceptedTelemetryLevels) {
121126
return "LabConfig"
@@ -148,6 +153,8 @@ function Get-PcSystemType {
148153
}
149154
}
150155

156+
$aiPropertyCache = @{}
157+
151158
function New-TelemetryEvent {
152159
param(
153160
[Parameter(Mandatory = $true)]
@@ -159,7 +166,7 @@ function New-TelemetryEvent {
159166

160167
process {
161168
if(-not $TelemetryInstrumentationKey) {
162-
WriteInfo "Instrumentation key is required in order to send telemetry data."
169+
WriteInfo "Instrumentation key is required to send telemetry data."
163170
return
164171
}
165172

@@ -203,6 +210,11 @@ function New-TelemetryEvent {
203210
$extraMetrics.'cpu.logical.count' = $hw.NumberOfLogicalProcessors
204211
$extraMetrics.'cpu.sockets.count' = $hw.NumberOfProcessors
205212

213+
if(-not $aiPropertyCache.ContainsKey("cpu.model")) {
214+
$aiPropertyCache["cpu.model"] = (Get-CimInstance "Win32_Processor" | Select-Object -First 1).Name
215+
}
216+
$extraProperties.'cpu.model' = $aiPropertyCache["cpu.model"]
217+
206218
# Disk
207219
$driveLetter = $ScriptRoot -Split ":" | Select-Object -First 1
208220
$volume = Get-Volume -DriveLetter $driveLetter
@@ -220,11 +232,13 @@ function New-TelemetryEvent {
220232
iKey = $TelemetryInstrumentationKey
221233
tags = @{
222234
"ai.application.ver" = $wslabVersion
223-
"ai.cloud.roleInstance" = Split-Path -Path $ScriptRoot -Leaf
235+
"ai.cloud.role" = Split-Path -Path $PSCommandPath -Leaf
224236
"ai.internal.sdkVersion" = 'wslab-telemetry:1.0.0'
225237
"ai.session.id" = $TelemetrySessionId
226238
"ai.device.locale" = (Get-WinsystemLocale).Name
227-
"ai.device.id" = $computerNameHash
239+
"ai.user.id" = (((Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Cryptography).MachineGuid) | Get-StringHash)
240+
"ai.device.id" = $computerNameHash
241+
"ai.device.type" = $extraProperties["hw.type"]
228242
"ai.device.os" = ""
229243
"ai.device.osVersion" = ""
230244
"ai.device.oemName" = ""

Scripts/2_CreateParentDisks.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ If (-not $isAdmin) {
106106
if(-not (Get-TelemetryLevel)) {
107107
$telemetryLevel = Read-TelemetryLevel
108108
$LabConfig.TelemetryLevel = $telemetryLevel
109+
$LabConfig.TelemetryLevelSource = "Prompt"
109110
$promptShown = $true
110111
}
111112

Scripts/3_Deploy.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ If (-not $isAdmin) {
670670
if(-not (Get-TelemetryLevel)) {
671671
$telemetryLevel = Read-TelemetryLevel
672672
$LabConfig.TelemetryLevel = $telemetryLevel
673+
$LabConfig.TelemetryLevelSource = "Prompt"
673674
$promptShown = $true
674675
}
675676

0 commit comments

Comments
 (0)