Skip to content

Commit

Permalink
Merge branch 'main' into handlebars-partials
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Watson authored Feb 2, 2023
2 parents e21d385 + 7bd2e51 commit 2020abc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ import { telemetryTimeRangeFormatter } from '../../../../../common/formatters/te
import type { InfraClientStartDeps } from '../../../../types';
import { useMetricsDataViewContext } from './use_data_view';
import { useSyncKibanaTimeFilterTime } from '../../../../hooks/use_kibana_timefilter_time';
import { useHostsUrlState, INITIAL_DATE_RANGE, HostsState } from './use_unified_search_url_state';

const buildQuerySubmittedPayload = (hostState: HostsState) => {
import {
useHostsUrlState,
INITIAL_DATE_RANGE,
HostsState,
StringDateRangeTimestamp,
} from './use_unified_search_url_state';

const buildQuerySubmittedPayload = (
hostState: HostsState & { dateRangeTimestamp: StringDateRangeTimestamp }
) => {
const { panelFilters, filters, dateRangeTimestamp, query: queryObj } = hostState;

return {
Expand Down Expand Up @@ -77,8 +84,11 @@ export const useUnifiedSearch = () => {

// Track telemetry event on query/filter/date changes
useEffect(() => {
telemetry.reportHostsViewQuerySubmitted(buildQuerySubmittedPayload(state));
}, [state, telemetry]);
const dateRangeTimestamp = getDateRangeAsTimestamp();
telemetry.reportHostsViewQuerySubmitted(
buildQuerySubmittedPayload({ ...state, dateRangeTimestamp })
);
}, [getDateRangeAsTimestamp, state, telemetry]);

const onSubmit = useCallback(
(data?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ const HostsStateRT = rt.type({

export type HostsState = rt.TypeOf<typeof HostsStateRT>;

export interface StringDateRangeTimestamp {
from: number;
to: number;
}

const SetQueryType = rt.partial(HostsStateRT.props);

const encodeUrlState = HostsStateRT.encode;
Expand Down

0 comments on commit 2020abc

Please sign in to comment.