import { SetupUX } from '../routes/rum_client/route' ; import { AGENT_NAME , TRANSACTION_TYPE , SERVICE_LANGUAGE_NAME , } from '../../common/elasticsearch_fieldnames' ; import { rangeQuery } from '../../../observability/server' ; import { ProcessorEvent } from '../../common/processor_event' ; import { TRANSACTION_PAGE_LOAD } from '../../common/transaction_types' ; import { getEsFilter } from '../routes/rum_client/ui_filters/get_es_filter' ; export function getRumPageLoadTransactionsProjection ( { setup , urlQuery , checkFetchStartFieldExists = true , start , end , } ) { const { uiFilters } = setup ; const bool = { filter : [ ... rangeQuery ( start , end ) , { term : { [ TRANSACTION_TYPE ] : TRANSACTION_PAGE_LOAD } } , ... ( checkFetchStartFieldExists ? [ { exists : { field : 'transaction.marks.navigationTiming.fetchStart' , } , } , ] : [ ] ) , ... ( urlQuery ? [ { wildcard : { 'url.full' : `*${ urlQuery }*` , } , } , ] : [ ] ) , ... getEsFilter ( uiFilters ) , ] , must_not : [ ... getEsFilter ( uiFilters , true ) ] , } ; return { apm : { events : [ ProcessorEvent . transaction ] , } , body : { query : { bool , } , } , } ; } export function getRumErrorsProjection ( { setup , urlQuery , start , end , } ) { const { uiFilters } = setup ; const bool = { filter : [ ... rangeQuery ( start , end ) , { term : { [ AGENT_NAME ] : 'rum-js' } } , { term : { [ SERVICE_LANGUAGE_NAME ] : 'javascript' , } , } , ... getEsFilter ( uiFilters ) , ... ( urlQuery ? [ { wildcard : { 'url.full' : `*${ urlQuery }*` , } , } , ] : [ ] ) , ] , must_not : [ ... getEsFilter ( uiFilters , true ) ] , } ; return { apm : { events : [ ProcessorEvent . error ] , } , body : { query : { bool , } , } , } ; }