diff --git a/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx index 2d53203a60e4..5077bccdc1ca 100644 --- a/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx @@ -8,7 +8,7 @@ import React, { memo, useState, useCallback, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { isEmpty } from 'lodash'; -import { euiStyled } from '../../../../../observability/public'; +import { euiStyled, useUiTracker } from '../../../../../observability/public'; import { isTimestampColumn } from '../../../utils/log_entry'; import { LogColumnConfiguration, @@ -68,6 +68,8 @@ export const LogEntryRow = memo( scale, wrap, }: LogEntryRowProps) => { + const trackMetric = useUiTracker({ app: 'infra_logs' }); + const [isHovered, setIsHovered] = useState(false); const [isMenuOpen, setIsMenuOpen] = useState(false); @@ -82,10 +84,10 @@ export const LogEntryRow = memo( logEntry.id, ]); - const handleOpenViewLogInContext = useCallback(() => openViewLogInContext?.(logEntry), [ - openViewLogInContext, - logEntry, - ]); + const handleOpenViewLogInContext = useCallback(() => { + openViewLogInContext?.(logEntry); // eslint-disable-line no-unused-expressions + trackMetric({ metric: 'view_in_context__stream' }); + }, [openViewLogInContext, logEntry, trackMetric]); const hasContext = useMemo(() => !isEmpty(logEntry.context), [logEntry]); const hasActionFlyoutWithItem = openFlyoutWithItem !== undefined; diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_example_message.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_example_message.tsx index 908e52f01cbc..7bcc05280994 100644 --- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_example_message.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_example_message.tsx @@ -26,6 +26,7 @@ import { import { LogColumnConfiguration } from '../../../../../utils/source_configuration'; import { LogEntryContextMenu } from '../../../../../components/logging/log_text_stream/log_entry_context_menu'; import { useLinkProps } from '../../../../../hooks/use_link_props'; +import { useUiTracker } from '../../../../../../../observability/public'; export const exampleMessageScale = 'medium' as const; export const exampleTimestampFormat = 'dateTime' as const; @@ -39,6 +40,7 @@ export const CategoryExampleMessage: React.FunctionComponent<{ tiebreaker: number; context: LogEntryContext; }> = ({ id, dataset, message, timestamp, timeRange, tiebreaker, context }) => { + const trackMetric = useUiTracker({ app: 'infra_logs' }); const [, { setContextEntry }] = useContext(ViewLogInContext.Context); // handle special cases for the dataset value const humanFriendlyDataset = getFriendlyNameForPartitionId(dataset); @@ -129,6 +131,7 @@ export const CategoryExampleMessage: React.FunctionComponent<{ cursor: { time: timestamp, tiebreaker }, columns: [], }; + trackMetric({ metric: 'view_in_context__categories' }); setContextEntry(logEntry); },