From c8d126df8144b208d6fd11681e6aceb7e49949ee Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Sun, 25 Oct 2026 07:17:33 +0100 Subject: [PATCH 1/2] Add Filter parameter to Get-SentryTestEvent --- utils/Integration.TestUtils.psm1 | 42 +++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/utils/Integration.TestUtils.psm1 b/utils/Integration.TestUtils.psm1 index 3a3c7fe..171149d 100644 --- a/utils/Integration.TestUtils.psm1 +++ b/utils/Integration.TestUtils.psm1 @@ -121,6 +121,22 @@ function Get-EventIds { return , $eventIds # Comma operator ensures array is returned } +# Lifts each entry (exception, breadcrumbs, ...) to a top-level property named after its type. +function ConvertTo-SentryTestEvent { + param($SentryEvent) + + if (-not $SentryEvent) { + return $null + } + + $entries = $SentryEvent.entries + $converted = $SentryEvent | Select-Object -ExcludeProperty 'entries' + foreach ($entry in $entries) { + $converted | Add-Member -MemberType NoteProperty -Name $entry.type -Value $entry.data -Force + } + return $converted +} + function Get-SentryTestEvent { [CmdletBinding()] param( @@ -133,10 +149,18 @@ function Get-SentryTestEvent { [Parameter()] [string]$TagValue, + # Applied to tag lookup results before the single-event check, e.g. to skip unrelated events carrying the same tag. + [Parameter()] + [scriptblock]$Filter, + [Parameter()] [int]$TimeoutSeconds = 300 ) + if ($EventId -and $Filter) { + throw 'Filter is only supported with TagName and TagValue' + } + if ($EventId) { Write-Host "Fetching Sentry event by ID: $EventId" -ForegroundColor Yellow $progressActivity = "Waiting for Sentry event $EventId" @@ -163,10 +187,13 @@ function Get-SentryTestEvent { try { if ($EventId) { # Find by event ID - $sentryEvent = Get-SentryEvent -EventId $EventId + $sentryEvent = ConvertTo-SentryTestEvent (Get-SentryEvent -EventId $EventId) } else { # Find by tag - $result = Find-SentryEventByTag -TagName $TagName -TagValue $TagValue + $result = @((Find-SentryEventByTag -TagName $TagName -TagValue $TagValue) | ForEach-Object { ConvertTo-SentryTestEvent $_ }) + if ($Filter) { + $result = @($result | Where-Object -FilterScript $Filter) + } $result.Count | Should -Be 1 $sentryEvent = $result[0] } @@ -182,11 +209,6 @@ function Get-SentryTestEvent { if ($sentryEvent) { Write-Host "Event $($sentryEvent.id) fetched from Sentry" -ForegroundColor Green - $entries = $sentryEvent.entries - $sentryEvent = $sentryEvent | Select-Object -ExcludeProperty 'entries' - foreach ($entry in $entries) { - $sentryEvent | Add-Member -MemberType NoteProperty -Name $entry.type -Value $entry.data -Force - } $sentryEvent | ConvertTo-Json -Depth 10 | Out-File -FilePath (Get-OutputFilePath "event-$($sentryEvent.id).json") return $sentryEvent } @@ -436,11 +458,7 @@ function Get-SentryTestTransaction { if ($sentryEvent) { Write-Host "Transaction $($sentryEvent.id) fetched from Sentry" -ForegroundColor Green - $entries = $sentryEvent.entries - $sentryEvent = $sentryEvent | Select-Object -ExcludeProperty 'entries' - foreach ($entry in $entries) { - $sentryEvent | Add-Member -MemberType NoteProperty -Name $entry.type -Value $entry.data -Force - } + $sentryEvent = ConvertTo-SentryTestEvent $sentryEvent $sentryEvent | ConvertTo-Json -Depth 10 | Out-File -FilePath (Get-OutputFilePath "transaction-$($sentryEvent.id).json") return $sentryEvent } From bfb7de715ed89f834b0475dd5c4120d0d5fb09c4 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 29 Oct 2026 11:18:21 +0100 Subject: [PATCH 2/2] Show pre/post-filter counts when Get-SentryTestEvent times out With -Filter set, the timeout error read 'Expected 1, but got 0', which looked the same as no event carrying the tag. Add a -Because with the tag-match count and the count left after filtering. The assertion without -Filter is unchanged. --- utils/Integration.TestUtils.psm1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/Integration.TestUtils.psm1 b/utils/Integration.TestUtils.psm1 index 171149d..e30e48c 100644 --- a/utils/Integration.TestUtils.psm1 +++ b/utils/Integration.TestUtils.psm1 @@ -192,9 +192,12 @@ function Get-SentryTestEvent { # Find by tag $result = @((Find-SentryEventByTag -TagName $TagName -TagValue $TagValue) | ForEach-Object { ConvertTo-SentryTestEvent $_ }) if ($Filter) { + $total = $result.Count $result = @($result | Where-Object -FilterScript $Filter) + $result.Count | Should -Be 1 -Because "$total event(s) carry the tag, $($result.Count) passed -Filter" + } else { + $result.Count | Should -Be 1 } - $result.Count | Should -Be 1 $sentryEvent = $result[0] } } catch {