@@ -16,18 +16,24 @@ import useOrganization from 'sentry/utils/useOrganization';
16
16
import usePageFilters from 'sentry/utils/usePageFilters' ;
17
17
import useProjects from 'sentry/utils/useProjects' ;
18
18
import ResourceSize from 'sentry/views/insights/browser/resources/components/resourceSize' ;
19
- import { useIndexedResourcesQuery } from 'sentry/views/insights/browser/resources/queries/useIndexedResourceQuery' ;
20
19
import { useResourceModuleFilters } from 'sentry/views/insights/browser/resources/utils/useResourceFilters' ;
21
20
import ChartPanel from 'sentry/views/insights/common/components/chartPanel' ;
22
- import { SpanIndexedField } from 'sentry/views/insights/types' ;
21
+ import { useEAPSpans } from 'sentry/views/insights/common/queries/useDiscover' ;
22
+ import type { EAPSpanResponse } from 'sentry/views/insights/types' ;
23
+ import { SpanFields } from 'sentry/views/insights/types' ;
23
24
import { usePerformanceGeneralProjectSettings } from 'sentry/views/performance/utils' ;
24
25
25
26
type Props = { groupId : string ; projectId ?: number } ;
26
27
27
28
export const LOCAL_STORAGE_SHOW_LINKS = 'performance-resources-images-showLinks' ;
28
29
29
- const { SPAN_GROUP , RAW_DOMAIN , SPAN_DESCRIPTION , HTTP_RESPONSE_CONTENT_LENGTH , SPAN_OP } =
30
- SpanIndexedField ;
30
+ const {
31
+ SPAN_GROUP ,
32
+ RAW_DOMAIN ,
33
+ SPAN_DESCRIPTION ,
34
+ MEASUREMENT_HTTP_RESPONSE_CONTENT_LENGTH ,
35
+ SPAN_OP ,
36
+ } = SpanFields ;
31
37
const imageWidth = '200px' ;
32
38
const imageHeight = '180px' ;
33
39
@@ -39,15 +45,24 @@ function SampleImages({groupId, projectId}: Props) {
39
45
usePerformanceGeneralProjectSettings ( projectId ) ;
40
46
const isImagesEnabled = settings ?. enable_images ?? false ;
41
47
42
- const { data : imageResources , isPending : isLoadingImages } = useIndexedResourcesQuery ( {
43
- queryConditions : [
44
- `${ SPAN_GROUP } :${ groupId } ` ,
45
- ...( filters [ SPAN_OP ] ? [ `${ SPAN_OP } :${ filters [ SPAN_OP ] } ` ] : [ ] ) ,
46
- ] ,
47
- sorts : [ { field : `measurements.${ HTTP_RESPONSE_CONTENT_LENGTH } ` , kind : 'desc' } ] ,
48
- limit : 100 ,
49
- referrer : 'api.performance.resources.sample-images' ,
50
- } ) ;
48
+ const { data : imageResources , isPending : isLoadingImages } = useEAPSpans (
49
+ {
50
+ fields : [
51
+ SpanFields . PROJECT ,
52
+ SpanFields . SPAN_GROUP ,
53
+ SpanFields . RAW_DOMAIN ,
54
+ SpanFields . SPAN_DESCRIPTION ,
55
+ SpanFields . MEASUREMENT_HTTP_RESPONSE_CONTENT_LENGTH ,
56
+ ] ,
57
+ limit : 100 ,
58
+ sorts : [ { field : MEASUREMENT_HTTP_RESPONSE_CONTENT_LENGTH , kind : 'desc' } ] ,
59
+ search : [
60
+ `${ SPAN_GROUP } :${ groupId } ` ,
61
+ ...( filters [ SPAN_OP ] ? [ `${ SPAN_OP } :${ filters [ SPAN_OP ] } ` ] : [ ] ) ,
62
+ ] . join ( ' ' ) ,
63
+ } ,
64
+ 'api.performance.resources.sample-images'
65
+ ) ;
51
66
52
67
const uniqueResources = new Set ( ) ;
53
68
@@ -81,8 +96,16 @@ function SampleImages({groupId, projectId}: Props) {
81
96
) ;
82
97
}
83
98
99
+ type ImageSpan = Pick <
100
+ EAPSpanResponse ,
101
+ | 'span.group'
102
+ | 'raw_domain'
103
+ | 'span.description'
104
+ | 'measurements.http.response_content_length'
105
+ > ;
106
+
84
107
function SampleImagesChartPanelBody ( props : {
85
- images : ReturnType < typeof useIndexedResourcesQuery > [ 'data' ] ;
108
+ images : ImageSpan [ ] ;
86
109
isImagesEnabled : boolean ;
87
110
isLoadingImages : boolean ;
88
111
isSettingsLoading : boolean ;
@@ -147,7 +170,7 @@ function SampleImagesChartPanelBody(props: {
147
170
src = { src }
148
171
showImage = { isImagesEnabled }
149
172
fileName = { getFileNameFromDescription ( resource [ SPAN_DESCRIPTION ] ) }
150
- size = { resource [ `measurements. ${ HTTP_RESPONSE_CONTENT_LENGTH } ` ] }
173
+ size = { resource [ MEASUREMENT_HTTP_RESPONSE_CONTENT_LENGTH ] }
151
174
key = { resource [ SPAN_DESCRIPTION ] }
152
175
/>
153
176
) ;
0 commit comments