diff --git a/x-pack/plugins/apm/public/context/UrlParamsContext/__tests__/UrlParamsContext.test.tsx b/x-pack/plugins/apm/public/context/UrlParamsContext/__tests__/UrlParamsContext.test.tsx index 9e620697a69a3..ab1ff922643e4 100644 --- a/x-pack/plugins/apm/public/context/UrlParamsContext/__tests__/UrlParamsContext.test.tsx +++ b/x-pack/plugins/apm/public/context/UrlParamsContext/__tests__/UrlParamsContext.test.tsx @@ -48,8 +48,10 @@ describe('UrlParamsContext', () => { expect(params).toEqual({ start: '2000-06-14T12:00:00.000Z', + serviceName: 'test', end: '2000-06-15T12:00:00.000Z', page: 0, + processorEvent: 'transaction', rangeFrom: 'now-24h', rangeTo: 'now', refreshInterval: 0, diff --git a/x-pack/plugins/apm/public/context/UrlParamsContext/helpers.ts b/x-pack/plugins/apm/public/context/UrlParamsContext/helpers.ts index c52fda4ad6717..453afdde69375 100644 --- a/x-pack/plugins/apm/public/context/UrlParamsContext/helpers.ts +++ b/x-pack/plugins/apm/public/context/UrlParamsContext/helpers.ts @@ -60,6 +60,7 @@ export function getPathParams(pathname: string = '') { const paths = getPathAsArray(pathname); const pageName = paths[1]; + // TODO: use react router's real match params instead of guessing the path order switch (pageName) { case 'transactions': return { @@ -80,6 +81,9 @@ export function getPathParams(pathname: string = '') { serviceName: paths[0] }; default: - return {}; + return { + processorEvent: 'transaction', + serviceName: paths[0] + }; } } diff --git a/x-pack/plugins/apm/public/context/UrlParamsContext/index.tsx b/x-pack/plugins/apm/public/context/UrlParamsContext/index.tsx index c7b1c26df0993..ad594a38ae902 100644 --- a/x-pack/plugins/apm/public/context/UrlParamsContext/index.tsx +++ b/x-pack/plugins/apm/public/context/UrlParamsContext/index.tsx @@ -35,7 +35,7 @@ export function urlParamsReducer( ): IUrlParams { switch (action.type) { case LOCATION_UPDATE: { - return resolveUrlParams(action.location); + return resolveUrlParams(action.location, state); } case TIME_RANGE_REFRESH: @@ -59,7 +59,7 @@ const UrlParamsProvider: React.FC<{}> = ({ children }) => { const location = useLocation(); const [urlParams, dispatch] = useReducer( urlParamsReducer, - resolveUrlParams(location) + resolveUrlParams(location, {}) ); function refreshTimeRange(time: TimeRange) { diff --git a/x-pack/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts b/x-pack/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts index 8daf202679c61..341166a2657ee 100644 --- a/x-pack/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts +++ b/x-pack/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts @@ -21,7 +21,7 @@ import { } from '../../components/shared/Links/url_helpers'; import { TIMEPICKER_DEFAULTS } from './constants'; -export function resolveUrlParams(location: Location, state: IUrlParams = {}) { +export function resolveUrlParams(location: Location, state: IUrlParams) { const { processorEvent, serviceName,