11import { Fragment , useCallback , useState } from 'react' ;
22import styled from '@emotion/styled' ;
3+ import { useQuery , useQueryClient } from '@tanstack/react-query' ;
34
45import { Checkbox } from '@sentry/scraps/checkbox' ;
56
@@ -16,13 +17,8 @@ import {SearchBar} from 'sentry/components/searchBar';
1617import { SentryDocumentTitle } from 'sentry/components/sentryDocumentTitle' ;
1718import { t } from 'sentry/locale' ;
1819import type { BuiltinSymbolSource , CustomRepo , DebugFile } from 'sentry/types/debugFiles' ;
19- import { getApiUrl } from 'sentry/utils/api/getApiUrl' ;
20- import {
21- useApiQuery ,
22- useMutation ,
23- useQueryClient ,
24- type ApiQueryKey ,
25- } from 'sentry/utils/queryClient' ;
20+ import { apiOptions , selectJsonWithHeaders } from 'sentry/utils/api/apiOptions' ;
21+ import { useMutation } from 'sentry/utils/queryClient' ;
2622import type { RequestError } from 'sentry/utils/requestError/requestError' ;
2723import { routeTitleGen } from 'sentry/utils/routeTitle' ;
2824import { useApi } from 'sentry/utils/useApi' ;
@@ -37,38 +33,6 @@ import {useProjectSettingsOutlet} from 'sentry/views/settings/project/projectSet
3733import { DebugFileRow } from './debugFileRow' ;
3834import { Sources } from './sources' ;
3935
40- function makeDebugFilesQueryKey ( {
41- orgSlug,
42- projectSlug,
43- query,
44- } : {
45- orgSlug : string ;
46- projectSlug : string ;
47- query : { cursor : string | undefined ; query : string | undefined } ;
48- } ) : ApiQueryKey {
49- return [
50- getApiUrl ( '/projects/$organizationIdOrSlug/$projectIdOrSlug/files/dsyms/' , {
51- path : { organizationIdOrSlug : orgSlug , projectIdOrSlug : projectSlug } ,
52- } ) ,
53- { query} ,
54- ] ;
55- }
56-
57- function makeSymbolSourcesQueryKey ( {
58- orgSlug,
59- platform,
60- } : {
61- orgSlug : string ;
62- platform ?: string ;
63- } ) : ApiQueryKey {
64- return [
65- getApiUrl ( '/organizations/$organizationIdOrSlug/builtin-symbol-sources/' , {
66- path : { organizationIdOrSlug : orgSlug } ,
67- } ) ,
68- { query : { platform} } ,
69- ] ;
70- }
71-
7236export default function ProjectDebugSymbols ( ) {
7337 const organization = useOrganization ( ) ;
7438 const { project} = useProjectSettingsOutlet ( ) ;
@@ -82,21 +46,34 @@ export default function ProjectDebugSymbols() {
8246 const cursor = location . query . cursor as string | undefined ;
8347 const hasSymbolSourcesFeatureFlag = organization . features . includes ( 'symbol-sources' ) ;
8448
49+ const debugFilesApiOptions = apiOptions . as < DebugFile [ ] > ( ) (
50+ '/projects/$organizationIdOrSlug/$projectIdOrSlug/files/dsyms/' ,
51+ {
52+ path : { organizationIdOrSlug : organization . slug , projectIdOrSlug : project . slug } ,
53+ query : { query, cursor} ,
54+ staleTime : 0 ,
55+ }
56+ ) ;
57+
8558 const {
86- data : debugFiles ,
87- getResponseHeader : getDebugFilesResponseHeader ,
59+ data : debugFilesResponse ,
8860 isPending : isLoadingDebugFiles ,
8961 isLoadingError : isLoadingErrorDebugFiles ,
9062 refetch : refetchDebugFiles ,
91- } = useApiQuery < DebugFile [ ] | null > (
92- makeDebugFilesQueryKey ( {
93- projectSlug : project . slug ,
94- orgSlug : organization . slug ,
95- query : { query, cursor} ,
96- } ) ,
63+ } = useQuery ( {
64+ ...debugFilesApiOptions ,
65+ select : selectJsonWithHeaders ,
66+ retry : false ,
67+ } ) ;
68+
69+ const debugFiles = debugFilesResponse ?. json ;
70+
71+ const symbolSourcesOptions = apiOptions . as < BuiltinSymbolSource [ ] | null > ( ) (
72+ '/organizations/$organizationIdOrSlug/builtin-symbol-sources/' ,
9773 {
74+ path : { organizationIdOrSlug : organization . slug } ,
75+ query : { platform : project . platform } ,
9876 staleTime : 0 ,
99- retry : false ,
10077 }
10178 ) ;
10279
@@ -105,17 +82,11 @@ export default function ProjectDebugSymbols() {
10582 isPending : isLoadingSymbolSources ,
10683 isError : isErrorSymbolSources ,
10784 refetch : refetchSymbolSources ,
108- } = useApiQuery < BuiltinSymbolSource [ ] | null > (
109- makeSymbolSourcesQueryKey ( {
110- orgSlug : organization . slug ,
111- platform : project . platform ,
112- } ) ,
113- {
114- staleTime : 0 ,
115- enabled : hasSymbolSourcesFeatureFlag ,
116- retry : 0 ,
117- }
118- ) ;
85+ } = useQuery ( {
86+ ...symbolSourcesOptions ,
87+ enabled : hasSymbolSourcesFeatureFlag ,
88+ retry : 0 ,
89+ } ) ;
11990
12091 const handleSearch = useCallback (
12192 ( value : string ) => {
@@ -144,19 +115,12 @@ export default function ProjectDebugSymbols() {
144115
145116 // invalidate debug files query
146117 queryClient . invalidateQueries ( {
147- queryKey : makeDebugFilesQueryKey ( {
148- projectSlug : project . slug ,
149- orgSlug : organization . slug ,
150- query : { query, cursor} ,
151- } ) ,
118+ queryKey : debugFilesApiOptions . queryKey ,
152119 } ) ;
153120
154121 // invalidate symbol sources query
155122 queryClient . invalidateQueries ( {
156- queryKey : makeSymbolSourcesQueryKey ( {
157- orgSlug : organization . slug ,
158- platform : project . platform ,
159- } ) ,
123+ queryKey : symbolSourcesOptions . queryKey ,
160124 } ) ;
161125 } ,
162126 onError : ( ) => {
@@ -267,7 +231,7 @@ export default function ProjectDebugSymbols() {
267231 } )
268232 : null }
269233 </ StyledPanelTable >
270- < Pagination pageLinks = { getDebugFilesResponseHeader ?. ( ' Link' ) } />
234+ < Pagination pageLinks = { debugFilesResponse ?. headers . Link } />
271235 </ Fragment >
272236 ) }
273237 </ SentryDocumentTitle >
0 commit comments