import React , { ReactNode } from 'react' ; import { PROCESSOR_EVENT , TRACE_ID , TRANSACTION_ID , } from '../../../../../common/elasticsearch_fieldnames' ; import { Transaction } from '../../../../../typings/es_schemas/ui/transaction' ; import { DiscoverLink } from './discover_link' ; export function getDiscoverQuery ( transaction ) { const transactionId = transaction . transaction . id ; const traceId = transaction . trace . id ; let query = `${ PROCESSOR_EVENT }:"transaction" AND ${ TRANSACTION_ID }:"${ transactionId }"` ; if ( traceId ) { query += ` AND ${ TRACE_ID }:"${ traceId }"` ; } return { _a : { interval : 'auto' , query : { language : 'kuery' , query , } , } , } ; } export function DiscoverTransactionLink ( { transaction , children , } ) { return ( < DiscoverLink query = { getDiscoverQuery ( transaction ) } children = { children } / > ) ; }