mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-12-08 15:24:07 +00:00
Update postInstall.ps1
Improve a distinct ID fallback
This commit is contained in:
parent
77ef5b2270
commit
c240f8dfa8
|
|
@ -100,12 +100,25 @@ if ($TelemetryProvider -and $TelemetryProvider.ToLower() -eq "posthog") {
|
||||||
# No-op: continue script
|
# No-op: continue script
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Resolve distinct ID (fallback to machine name)
|
# Resolve distinct ID (fallback to machine name, then device UID)
|
||||||
# A distinct ID uses a unique and anonymous identifier.
|
|
||||||
$finalDistinctId = if ($DistinctId -and $DistinctId.Trim() -ne "") {
|
$finalDistinctId = if ($DistinctId -and $DistinctId.Trim() -ne "") {
|
||||||
$DistinctId
|
$DistinctId
|
||||||
} else {
|
} else {
|
||||||
$env:COMPUTERNAME
|
# Attempt to get the machine name
|
||||||
|
$computerName = $env:COMPUTERNAME
|
||||||
|
|
||||||
|
if ($computerName -and $computerName.Trim() -ne "") {
|
||||||
|
$computerName
|
||||||
|
} else {
|
||||||
|
# Fall back to using the device UUID (if COMPUTERNAME is unavailable)
|
||||||
|
$deviceUid = (Get-WmiObject -Class Win32_ComputerSystemProduct).UUID
|
||||||
|
if ($deviceUid -and $deviceUid.Trim() -ne "") {
|
||||||
|
$deviceUid
|
||||||
|
} else {
|
||||||
|
# Optionally, generate a new UUID or use a predefined value if UUID is also unavailable
|
||||||
|
[guid]::NewGuid().ToString()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($finalDistinctId -and $finalDistinctId.Trim() -ne "") {
|
if ($finalDistinctId -and $finalDistinctId.Trim() -ne "") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user