import { useFetcher } from '../../../../hooks/use_fetcher' ; import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params' ; import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context' ; import { useApmParams } from '../../../../hooks/use_apm_params' ; import { useTimeRange } from '../../../../hooks/use_time_range' ; export function useTransactionBreakdown ( { kuery , environment , } ) { const { urlParams : { transactionName } , } = useLegacyUrlParams ( ) ; const { query : { rangeFrom , rangeTo } , } = useApmParams ( '/services/{serviceName}' ) ; const { start , end } = useTimeRange ( { rangeFrom , rangeTo } ) ; const { transactionType , serviceName } = useApmServiceContext ( ) ; const { data = { timeseries : undefined } , error , status , } = useFetcher ( ( callApmApi ) => { if ( serviceName && start && end && transactionType ) { return callApmApi ( { endpoint : 'GET /internal/apm/services/{serviceName}/transaction/charts/breakdown' , params : { path : { serviceName } , query : { environment , kuery , start , end , transactionName , transactionType , } , } , } ) ; } } , [ environment , kuery , serviceName , start , end , transactionType , transactionName , ] ) ; return { data , status , error , } ; }