Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move useTrackMetric hook usage to Observability Shared #157272

Merged
merged 7 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EuiBasicTable, EuiBasicTableColumn } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { EuiTableSortingType } from '@elastic/eui/src/components/basic_table/table_types';
import type { Criteria } from '@elastic/eui/src/components/basic_table/basic_table';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { FETCH_STATUS } from '../../../hooks/use_fetcher';
import { useTheme } from '../../../hooks/use_theme';
import type { FieldValuePair } from '../../../../common/correlations/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { Direction } from '@elastic/eui/src/services/sort/sort_direction';

import { i18n } from '@kbn/i18n';

import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';

import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { FieldStatsPopover } from './context_popover/field_stats_popover';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { EuiTableSortingType } from '@elastic/eui/src/components/basic_table/tab
import { i18n } from '@kbn/i18n';

import { FormattedMessage } from '@kbn/i18n-react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';

import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { FieldStatsPopover } from './context_popover/field_stats_popover';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { METRIC_TYPE } from '@kbn/analytics';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { isTimeComparison } from '../../../shared/time_comparison/get_comparison_options';
import { getNodeName, NodeType } from '../../../../../common/connections';
import { useApmParams } from '../../../../hooks/use_apm_params';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n';
import { TypeOf } from '@kbn/typed-react-router-config';
import { METRIC_TYPE } from '@kbn/analytics';
import React from 'react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { NodeDataDefinition } from 'cytoscape';
import { isTimeComparison } from '../../../shared/time_comparison/get_comparison_options';
import { ContentsProps } from '.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiButton, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { METRIC_TYPE } from '@kbn/analytics';
import React from 'react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { EdgeDataDefinition } from 'cytoscape';
import { ContentsProps } from '.';
import { useAnyOfApmParams } from '../../../../hooks/use_apm_params';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { renderHook } from '@testing-library/react-hooks';
import cytoscape from 'cytoscape';
import dagre from 'cytoscape-dagre';
import { EuiTheme } from '@kbn/kibana-react-plugin/common';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { useCytoscapeEventHandlers } from './use_cytoscape_event_handlers';
import lodash from 'lodash';

jest.mock('@kbn/observability-plugin/public');
jest.mock('@kbn/observability-shared-plugin/public');

cytoscape.use(dagre);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import cytoscape from 'cytoscape';
import { debounce } from 'lodash';
import { useEffect } from 'react';
import { EuiTheme } from '@kbn/kibana-react-plugin/common';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { getAnimationOptions, getNodeHeight } from './cytoscape_options';

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiIcon, EuiToolTip } from '@elastic/eui';
import { METRIC_TYPE } from '@kbn/analytics';
import { i18n } from '@kbn/i18n';
import React, { ReactNode } from 'react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { isTimeComparison } from '../../../shared/time_comparison/get_comparison_options';
import { getNodeName, NodeType } from '../../../../../common/connections';
import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EuiStat,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import React, { useMemo, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { getOptionLabel } from '../../../../../../../common/agent_configuration/all_option';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
htmlIdGenerator,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { ElasticDocsLink } from '../../../shared/links/elastic_docs_link';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import React from 'react';

import { i18n } from '@kbn/i18n';

import { METRIC_TYPE, useTrackMetric } from '@kbn/observability-plugin/public';
import {
METRIC_TYPE,
useTrackMetric,
} from '@kbn/observability-shared-plugin/public';

import { isActivePlatinumLicense } from '../../../../common/license_check';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import React from 'react';

import { i18n } from '@kbn/i18n';

import { METRIC_TYPE, useTrackMetric } from '@kbn/observability-plugin/public';
import {
METRIC_TYPE,
useTrackMetric,
} from '@kbn/observability-shared-plugin/public';

import { isActivePlatinumLicense } from '../../../../common/license_check';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

import { i18n } from '@kbn/i18n';
import React from 'react';
import { METRIC_TYPE, useUiTracker } from '@kbn/observability-plugin/public';
import {
METRIC_TYPE,
useUiTracker,
} from '@kbn/observability-shared-plugin/public';
import {
SERVICE_NAME,
SPAN_DESTINATION_SERVICE_RESOURCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { EuiButtonEmpty } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useEffect, useState } from 'react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { LabsFlyout } from './labs_flyout';

export function Labs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/
import { useRoutePath } from '@kbn/typed-react-router-config';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';

export function TrackPageview({ children }: { children: React.ReactElement }) {
const routePath = useRoutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { BrushEndListener, BrushEvent, XYBrushEvent } from '@elastic/charts';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import {
EuiBadge,
EuiFlexGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n';
import React, { useMemo } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { useApmRouter } from '../../../hooks/use_apm_router';
import { useEnvironmentsContext } from '../../../context/environments_context/use_environments_context';
import { useAnomalyDetectionJobsContext } from '../../../context/anomaly_detection_jobs/use_anomaly_detection_jobs_context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FieldState } from '@kbn/advanced-settings-plugin/public';
import { toEditableConfig } from '@kbn/advanced-settings-plugin/public';
import { IUiSettingsClient } from '@kbn/core/public';
import { isEmpty } from 'lodash';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';

function getEditableConfig({
settingsKeys,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ import type {
} from '@kbn/observability-shared-plugin/public';
import {
FetchDataParams,
METRIC_TYPE,
ObservabilityPublicSetup,
ObservabilityPublicStart,
} from '@kbn/observability-plugin/public';
import { METRIC_TYPE } from '@kbn/observability-shared-plugin/public';
import type {
TriggersAndActionsUIPublicPluginSetup,
TriggersAndActionsUIPublicPluginStart,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { memo, useState, useCallback, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { isEmpty } from 'lodash';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { isTimestampColumn } from '../../../utils/log_entry';
import { TextScale } from '../../../../common/log_text_scale';
import { LogEntryColumn, LogEntryColumnWidths, iconColumnId } from './log_entry_column';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { useCallback, useMemo } from 'react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { DatasetFilter } from '../../../../common/log_analysis';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
import { useTrackedPromise } from '../../../utils/use_tracked_promise';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/infra/public/hooks/use_inventory_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
useQuery,
useQueryClient,
} from '@tanstack/react-query';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';

import { IHttpFetchError, ResponseErrorBody } from '@kbn/core-http-browser';
import { MetricsSourceConfigurationResponse } from '../../common/metrics_sources';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
useQuery,
useQueryClient,
} from '@tanstack/react-query';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';

import { IHttpFetchError, ResponseErrorBody } from '@kbn/core-http-browser';
import { MetricsSourceConfigurationResponse } from '../../common/metrics_sources';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import useInterval from 'react-use/lib/useInterval';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { MLJobsAwaitingNodeWarning, ML_PAGES, useMlHref } from '@kbn/ml-plugin/public';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { TimeRange } from '../../../../common/time/time_range';
import { CategoryJobNoticesSection } from '../../../components/logging/log_analysis_job_status';
import { AnalyzeInMlButton } from '../../../components/logging/log_analysis_results';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import { EuiText, EuiButton } from '@elastic/eui';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';

interface LogEntryCategoriesSetupContentProps {
onOpenSetup: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { i18n } from '@kbn/i18n';
import { encode } from '@kbn/rison';
import moment from 'moment';

import { useUiTracker, useLinkProps } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { useLinkProps } from '@kbn/observability-plugin/public';
import { LogEntry, LogEntryContext } from '../../../../../../common/log_entry';
import { TimeRange } from '../../../../../../common/time';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import React, { useCallback, useMemo } from 'react';
import { encode } from '@kbn/rison';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { MLJobsAwaitingNodeWarning } from '@kbn/ml-plugin/public';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { isJobStatusWithResults } from '../../../../common/log_analysis';
import { TimeKey } from '../../../../common/time';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import { EuiText, EuiButton } from '@elastic/eui';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';

interface LogEntryRateSetupContentProps {
onOpenSetup: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { EuiCode, EuiDescribedFormGroup, EuiFieldText, EuiFormRow } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import React from 'react';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { LogIndexNameReference } from '../../../../common/log_views';
import { FormElement } from './form_elements';
import { getFormRowProps, getInputFieldProps } from './form_field_props';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { EuiDescribedFormGroup, EuiFormRow, EuiLink, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import React, { useCallback, useMemo } from 'react';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { useLinkProps } from '@kbn/observability-plugin/public';
import { LogDataViewReference } from '../../../../common/log_views';
import { FormElement } from './form_elements';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { useMemo } from 'react';
import { SavedObjectNotFound } from '@kbn/kibana-utils-plugin/common';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import {
LogDataViewReference,
LogIndexNameReference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { EuiCheckableCard, EuiFormFieldset, EuiSpacer, EuiTitle } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import React, { useCallback } from 'react';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import {
logIndexNameReferenceRT,
LogDataViewReference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import React, { useCallback, useMemo } from 'react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { Prompt, useTrackPageview } from '@kbn/observability-plugin/public';
import { Prompt } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { SourceLoadingPage } from '../../../components/source_loading_page';
import { useLogsBreadcrumbs } from '../../../hooks/use_logs_breadcrumbs';
import { useLogViewContext } from '../../../hooks/use_log_view';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/infra/public/pages/logs/stream/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { EuiErrorBoundary } from '@elastic/eui';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import React from 'react';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
import { useLogsBreadcrumbs } from '../../../hooks/use_logs_breadcrumbs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EuiPageTemplate, EuiImage, EuiSpacer } from '@elastic/eui';
import { css } from '@emotion/react';
import { useEuiBackgroundColor } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { useUiSetting } from '@kbn/kibana-react-plugin/public';
import { MetricsPageTemplate } from '../../../page_template';
import hostsLandingBetaLight from './hosts_landing_beta_light.svg';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/infra/public/pages/metrics/hosts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { EuiButton, EuiErrorBoundary } from '@elastic/eui';
import React from 'react';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { APP_WRAPPER_CLASS } from '@kbn/core/public';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useCallback, useState, useEffect, useRef } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem, EuiButtonEmpty, EuiPanel } from '@elastic/eui';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import { InventoryItemType } from '../../../../../common/inventory_models/types';
import { TryItButton } from '../../../../components/try_it_button';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import { FormattedMessage, FormattedDate } from '@kbn/i18n-react';
import { withTheme } from '@kbn/kibana-react-plugin/common';
import { useLinkProps } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { datemathToEpochMillis } from '../../../../../../../utils/datemath';
import { SnapshotMetricType } from '../../../../../../../../common/inventory_models/types';
import { useSorting } from '../../../../../../../hooks/use_sorting';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import moment, { Moment } from 'moment';
import { EuiComboBox } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { EuiLoadingSpinner } from '@elastic/eui';
import { useUiTracker } from '@kbn/observability-plugin/public';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { useSourceContext } from '../../../../../../containers/metrics_source';
import { useMetricK8sModuleContext } from '../../../../../../containers/ml/modules/metrics_k8s/module';
import { useMetricHostsModuleContext } from '../../../../../../containers/ml/modules/metrics_hosts/module';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { EuiErrorBoundary } from '@elastic/eui';
import React from 'react';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { APP_WRAPPER_CLASS } from '@kbn/core/public';
import { css } from '@emotion/react';
import { FilterBar } from './components/filter_bar';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { EuiErrorBoundary } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useEffect, useState } from 'react';
import { useTrackPageview } from '@kbn/observability-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { SourceLoadingPage } from '../../../components/source_loading_page';
import { useMetricsExplorerViews } from '../../../hooks/use_metrics_explorer_views';
import { MetricsSourceConfigurationProperties } from '../../../../common/metrics_sources';
Expand Down
Loading