import * as t from 'io-ts' ; import { compact } from 'lodash' ; import { Setup } from '../../../lib/helpers/setup_request' ; import { ProcessorEvent } from '../../../../common/processor_event' ; import { filterOptionsRt } from './custom_link_types' ; import { splitFilterValueByComma } from './helper' ; export async function getTransaction ( { setup , filters = { } , } ) { const { apmEventClient } = setup ; const esFilters = compact ( Object . entries ( filters ) . map ( ( [ key , value ] ) => { if ( value ) { return { terms : { [ key ] : splitFilterValueByComma ( value ) } } ; } } ) ) ; const params = { terminate_after : 1 , apm : { events : [ ProcessorEvent . transaction as const ] , } , size : 1 , body : { query : { bool : { filter : esFilters , } , } , } , } ; const resp = await apmEventClient . search ( 'get_transaction_for_custom_link' , params ) ; return resp . hits . hits [ 0 ] ?. _source ; }