11import { expect , test } from '@playwright/test' ;
2- import { waitForError , waitForTransaction } from '@sentry-internal/test-utils' ;
2+ import { getSpanOp , waitForError , waitForStreamedSpan } from '@sentry-internal/test-utils' ;
33
44test . describe ( 'server-side errors' , ( ) => {
55 test ( 'captures SSR error' , async ( { page } ) => {
66 const errorEventPromise = waitForError ( 'astro-6-cf-workers' , errorEvent => {
77 return errorEvent ?. exception ?. values ?. [ 0 ] ?. value === "Cannot read properties of undefined (reading 'x')" ;
88 } ) ;
99
10- const transactionEventPromise = waitForTransaction ( 'astro-6-cf-workers' , transactionEvent => {
11- return transactionEvent . transaction === 'GET /ssr-error' ;
10+ const spanPromise = waitForStreamedSpan ( 'astro-6-cf-workers' , span => {
11+ return getSpanOp ( span ) === 'http.server' && span . is_segment && span . name === 'GET /ssr-error' ;
1212 } ) ;
1313
1414 // This page returns an error status code, so we need to catch the navigation error
@@ -17,19 +17,14 @@ test.describe('server-side errors', () => {
1717 } ) ;
1818
1919 const errorEvent = await errorEventPromise ;
20- const transactionEvent = await transactionEventPromise ;
20+ const span = await spanPromise ;
2121
22- expect ( transactionEvent ) . toMatchObject ( {
23- transaction : 'GET /ssr-error' ,
24- spans : [ ] ,
25- } ) ;
26-
27- const traceId = transactionEvent . contexts ?. trace ?. trace_id ;
28- const spanId = transactionEvent . contexts ?. trace ?. span_id ;
22+ const traceId = span . trace_id ;
23+ const spanId = span . span_id ;
2924
3025 expect ( traceId ) . toMatch ( / [ a - f 0 - 9 ] { 32 } / ) ;
3126 expect ( spanId ) . toMatch ( / [ a - f 0 - 9 ] { 16 } / ) ;
32- expect ( transactionEvent . contexts ?. trace ? .parent_span_id ) . toBeUndefined ( ) ;
27+ expect ( span . parent_span_id ) . toBeUndefined ( ) ;
3328
3429 expect ( errorEvent ) . toMatchObject ( {
3530 contexts : {
@@ -80,38 +75,28 @@ test.describe('server-side errors', () => {
8075 const errorEventPromise = waitForError ( 'astro-6-cf-workers' , errorEvent => {
8176 return errorEvent ?. exception ?. values ?. [ 0 ] ?. value === 'Endpoint Error' ;
8277 } ) ;
83- const transactionEventApiPromise = waitForTransaction ( 'astro-6-cf-workers' , transactionEvent => {
84- return transactionEvent . transaction === 'GET /endpoint-error/api' ;
78+ const apiSpanPromise = waitForStreamedSpan ( 'astro-6-cf-workers' , span => {
79+ return getSpanOp ( span ) === 'http.server' && span . name === 'GET /endpoint-error/api' ;
8580 } ) ;
86- const transactionEventEndpointPromise = waitForTransaction ( 'astro-6-cf-workers' , transactionEvent => {
87- return transactionEvent . transaction === 'GET /endpoint-error' ;
81+ const endpointSpanPromise = waitForStreamedSpan ( 'astro-6-cf-workers' , span => {
82+ return getSpanOp ( span ) === 'http.server' && span . is_segment && span . name === 'GET /endpoint-error' ;
8883 } ) ;
8984
9085 await page . goto ( '/endpoint-error' ) ;
9186 await page . getByText ( 'Get Data' ) . click ( ) ;
9287
9388 const errorEvent = await errorEventPromise ;
94- const transactionEventApi = await transactionEventApiPromise ;
95- const transactionEventEndpoint = await transactionEventEndpointPromise ;
96-
97- expect ( transactionEventEndpoint ) . toMatchObject ( {
98- transaction : 'GET /endpoint-error' ,
99- spans : [ ] ,
100- } ) ;
89+ const apiSpan = await apiSpanPromise ;
90+ const endpointSpan = await endpointSpanPromise ;
10191
102- const traceId = transactionEventEndpoint . contexts ?. trace ? .trace_id ;
103- const endpointSpanId = transactionEventApi . contexts ?. trace ? .span_id ;
92+ const traceId = endpointSpan . trace_id ;
93+ const endpointSpanId = apiSpan . span_id ;
10494
10595 expect ( traceId ) . toMatch ( / [ a - f 0 - 9 ] { 32 } / ) ;
10696 expect ( endpointSpanId ) . toMatch ( / [ a - f 0 - 9 ] { 16 } / ) ;
10797
108- expect ( transactionEventApi ) . toMatchObject ( {
109- transaction : 'GET /endpoint-error/api' ,
110- spans : [ ] ,
111- } ) ;
112-
113- const spanId = transactionEventApi . contexts ?. trace ?. span_id ;
114- const parentSpanId = transactionEventApi . contexts ?. trace ?. parent_span_id ;
98+ const spanId = apiSpan . span_id ;
99+ const parentSpanId = apiSpan . parent_span_id ;
115100
116101 expect ( spanId ) . toMatch ( / [ a - f 0 - 9 ] { 16 } / ) ;
117102 // TODO: This is incorrect, for whatever reason, it should be the endpointSpanId ideally
0 commit comments