Skip to content

Sync eng/common directory with azure-sdk-tools for PR 14692#45889

Open
azure-sdk wants to merge 5 commits intomainfrom
sync-eng/common-telemetry_hook_script-14692
Open

Sync eng/common directory with azure-sdk-tools for PR 14692#45889
azure-sdk wants to merge 5 commits intomainfrom
sync-eng/common-telemetry_hook_script-14692

Conversation

@azure-sdk
Copy link
Collaborator

Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#14692 See eng/common workflow

@azure-sdk azure-sdk requested a review from a team as a code owner March 25, 2026 01:18
@azure-sdk azure-sdk added EngSys This issue is impacting the engineering system. Central-EngSys This issue is owned by the Engineering System team. labels Mar 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR syncs eng/common with updates from azure-sdk-tools PR 14692 by introducing a PowerShell hook script intended to ingest telemetry for select azsdk tool/skill invocations without blocking normal hook execution.

Changes:

  • Added azsdk_tool_telemetry.ps1 hook to parse tool invocation JSON from stdin and decide whether to emit telemetry.
  • Added logic to ignore specific tools, respect an opt-out environment variable, and invoke azsdk ingest-telemetry asynchronously.


# Helper to extract path from tool input (handles 'path', 'filePath', 'file_path')
function Get-ToolInputPath
{
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

Because this script dot-sources AzSdkTool-Helpers.ps1 (which enables Set-StrictMode -Version 4), accessing $toolInput.path / $toolInput.filePath / $toolInput.file_path will throw if $toolInput is $null (or not an object). Consider guarding with if ($toolInput -and ...) or switching to a PSObject.Properties[...] lookup so missing tool args don’t break the hook.

Suggested change
{
{
if (-not $toolInput) { return $null }

Copilot uses AI. Check for mistakes.
# Process skill invocations (looking for "azsdk" prefix in skill name)
if ($toolName -eq "skill")
{
$skillName = $toolInput.skill
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

$skillName = $toolInput.skill will throw under Set-StrictMode -Version 4 if the incoming JSON doesn’t include toolArgs/tool_input (i.e., $toolInput is $null). To keep the hook resilient, add a $toolInput null check before accessing .skill (or use a safe property accessor).

Suggested change
$skillName = $toolInput.skill
$skillName = Get-Property -Object $toolInput -PropertyName 'skill'

Copilot uses AI. Check for mistakes.
Comment on lines +144 to +158
# Find property from tool input or output
function Get-Property
{
param (
[object]$Object,
[string]$PropertyName
)

if ($Object -and $Object.PSObject.Properties[$PropertyName])
{
return $Object.PSObject.Properties[$PropertyName].Value
}
return $null
}

Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

Get-Property is defined but never used. Either remove it to reduce dead code, or use it (e.g., in Get-ToolInputPath / skill parsing) to safely read optional properties under StrictMode.

Suggested change
# Find property from tool input or output
function Get-Property
{
param (
[object]$Object,
[string]$PropertyName
)
if ($Object -and $Object.PSObject.Properties[$PropertyName])
{
return $Object.PSObject.Properties[$PropertyName].Value
}
return $null
}

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +26
# Skip telemetry if opted out
if ($env:AZSDKTOOLS_COLLECT_TELEMETRY -eq "false")
{
Write-Output '{"continue":true}'
exit 0
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The opt-out block duplicates the exact JSON output/exit logic that Write-Success provides, and Write-Success is also invoked before its definition earlier in the file. Consider defining Write-Success at the top and using it for all early-exit paths to keep the hook logic consistent and easier to maintain.

Copilot uses AI. Check for mistakes.
praveenkuttappan and others added 5 commits March 25, 2026 02:02
Co-authored-by: Praveen Kuttappan <55455725+praveenkuttappan@users.noreply.github.com>
Co-authored-by: Praveen Kuttappan <55455725+praveenkuttappan@users.noreply.github.com>
Co-authored-by: Praveen Kuttappan <55455725+praveenkuttappan@users.noreply.github.com>
@azure-sdk azure-sdk force-pushed the sync-eng/common-telemetry_hook_script-14692 branch from cb1a6e7 to 013c044 Compare March 25, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Central-EngSys This issue is owned by the Engineering System team. EngSys This issue is impacting the engineering system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants