Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log telemetry for uses of deprecated features #1387

Merged
merged 9 commits into from
Jan 14, 2025
Merged
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 Actions/RunPipeline/RunPipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ try {
if ($buildMode -eq 'Clean' -and $settings.ContainsKey('cleanModePreprocessorSymbols')) {
Write-Host "Adding Preprocessor symbols : $($settings.cleanModePreprocessorSymbols -join ',')"
$runAlPipelineParams["preprocessorsymbols"] += $settings.cleanModePreprocessorSymbols
Write-Warning -message "cleanModePreprocessorSymbols is deprecated. See https://aka.ms/ALGoDeprecations#cleanModePreprocessorSymbols for more information."
Trace-DeprecationWarning -Message "cleanModePreprocessorSymbols is deprecated" -DeprecationTag "cleanModePreprocessorSymbols"
}
# <--- REMOVE AFTER April 1st 2025

Expand Down
68 changes: 66 additions & 2 deletions Actions/TelemetryHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function AddTelemetryEvent()
[Parameter(Mandatory = $false)]
[System.Collections.Generic.Dictionary[[System.String], [System.String]]] $Data = @{},
[Parameter(Mandatory = $false)]
[ValidateSet("Information", "Error")]
[ValidateSet("Information", "Warning", "Error")]
[String] $Severity = 'Information'
)

Expand Down Expand Up @@ -138,6 +138,33 @@ function Trace-Information() {
AddTelemetryEvent -Message $Message -Severity 'Information' -Data $AdditionalData
}

<#
.SYNOPSIS
Logs a warning message to telemetry

.DESCRIPTION
Logs a warning message to telemetry

.PARAMETER Message
The message to log to telemetry

.PARAMETER AdditionalData
Additional data to log to telemetry

.EXAMPLE
Trace-Warning -Message "AL-Go warning: This is a warning message"
#>
function Trace-Warning() {
param(
[Parameter(Mandatory = $true)]
[String] $Message,
[Parameter(Mandatory = $false)]
[System.Collections.Generic.Dictionary[[System.String], [System.String]]] $AdditionalData = @{}
)

AddTelemetryEvent -Message $Message -Severity 'Warning' -Data $AdditionalData
}

<#
.SYNOPSIS
Logs an exception message to telemetry
Expand Down Expand Up @@ -212,4 +239,41 @@ function Add-TelemetryProperty() {
}
}

Export-ModuleMember -Function Trace-Information, Trace-Exception, Add-TelemetryProperty
<#
.SYNOPSIS
Writes a deprecation warning to telemetry and as a warning in the GitHub action

.DESCRIPTION
Writes a deprecation warning to telemetry and as a warning in the GitHub action

.PARAMETER Message
The message to log to telemetry

.PARAMETER DeprecationTag
The tag to use to link to the deprecation documentation

.PARAMETER AdditionalData
Additional data to log to telemetry

.EXAMPLE
Trace-DeprecationWarning -Message "This setting is deprecated. Use the new setting instead." -DeprecationTag 'SettingName'
#>
function Trace-DeprecationWarning {
param(
[Parameter(Mandatory = $true)]
[String] $Message,
[Parameter(Mandatory = $true)]
[String] $DeprecationTag,
[Parameter(Mandatory = $false)]
[System.Collections.Generic.Dictionary[[System.String], [System.String]]] $AdditionalData = @{}
aholstrup1 marked this conversation as resolved.
Show resolved Hide resolved
)

# Show deprecation warning in GitHub
OutputWarning -message "$Message. See https://aka.ms/ALGoDeprecations#$($DeprecationTag) for more information."

# Log deprecation warning to telemetry
Add-TelemetryProperty -Hashtable $AdditionalData -Key 'DeprecationTag' -Value $DeprecationTag
Trace-Warning -Message "Deprecation Warning: $Message" -AdditionalData $AdditionalData
}

Export-ModuleMember -Function Trace-Information, Trace-Warning, Trace-Exception, Add-TelemetryProperty, Trace-DeprecationWarning
Loading