1
1
import { Fragment } from 'react' ;
2
+ import * as Sentry from '@sentry/react' ;
2
3
3
4
import { Event } from 'sentry/types/event' ;
4
5
import { DiscoverQueryProps } from 'sentry/utils/discover/genericDiscoverQuery' ;
@@ -73,6 +74,10 @@ export default function QuickTraceQuery({children, event, ...props}: QueryProps)
73
74
organization
74
75
) ;
75
76
77
+ const scope = new Sentry . Scope ( ) ;
78
+ const traceErrorMsg = 'Trace endpoints returning non-array in response' ;
79
+ scope . setFingerprint ( [ traceErrorMsg ] ) ;
80
+
76
81
if (
77
82
! traceFullResults . isLoading &&
78
83
traceFullResults . error === null &&
@@ -88,19 +93,31 @@ export default function QuickTraceQuery({children, event, ...props}: QueryProps)
88
93
} ) ;
89
94
}
90
95
91
- for ( const subtrace of transactions ??
92
- ( traceFullResults . traces as TraceFull [ ] ) ) {
93
- try {
94
- const trace = flattenRelevantPaths ( event , subtrace ) ;
95
- return children ( {
96
- ...traceFullResults ,
97
- trace,
98
- currentEvent : trace . find ( e => isCurrentEvent ( e , event ) ) ?? null ,
99
- } ) ;
100
- } catch {
101
- // let this fall through and check the next subtrace
102
- // or use the trace lite results
96
+ const traceTransactions =
97
+ transactions ?? ( traceFullResults . traces as TraceFull [ ] ) ;
98
+
99
+ try {
100
+ for ( const subtrace of traceTransactions ) {
101
+ try {
102
+ const trace = flattenRelevantPaths ( event , subtrace ) ;
103
+ return children ( {
104
+ ...traceFullResults ,
105
+ trace,
106
+ currentEvent : trace . find ( e => isCurrentEvent ( e , event ) ) ?? null ,
107
+ } ) ;
108
+ } catch {
109
+ // let this fall through and check the next subtrace
110
+ // or use the trace lite results
111
+ }
103
112
}
113
+ } catch {
114
+ // capture exception and let this fall through to
115
+ // use the /events-trace-lite/ response below
116
+ scope . setExtras ( {
117
+ traceTransactions,
118
+ traceFullResults,
119
+ } ) ;
120
+ Sentry . captureException ( new Error ( traceErrorMsg ) , scope ) ;
104
121
}
105
122
}
106
123
@@ -118,14 +135,25 @@ export default function QuickTraceQuery({children, event, ...props}: QueryProps)
118
135
? orphanErrorsLite [ 0 ]
119
136
: undefined ;
120
137
const traceTransactions = transactionLite ?? ( trace as TraceLite ) ;
138
+
139
+ let traceTransaction : EventLite | undefined ;
140
+ try {
141
+ traceTransaction = traceTransactions . find ( e => isCurrentEvent ( e , event ) ) ;
142
+ } catch {
143
+ scope . setExtras ( {
144
+ traceTransaction,
145
+ orphanError,
146
+ traceTransactions,
147
+ trace,
148
+ } ) ;
149
+ Sentry . captureException ( new Error ( traceErrorMsg ) , scope ) ;
150
+ }
151
+
121
152
return children ( {
122
153
...traceLiteResults ,
123
- trace : traceTransactions ,
154
+ trace : Array . isArray ( traceTransactions ) ? traceTransactions : [ ] ,
124
155
orphanErrors : orphanErrorsLite ,
125
- currentEvent :
126
- orphanError ??
127
- traceTransactions . find ( e => isCurrentEvent ( e , event ) ) ??
128
- null ,
156
+ currentEvent : orphanError ?? traceTransaction ?? null ,
129
157
} ) ;
130
158
}
131
159
0 commit comments