From cf65b6ba8c7d4f203fae698f3c607af8d26f7ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20G=C3=B3mez?= Date: Mon, 17 Aug 2020 17:06:13 +0200 Subject: [PATCH] Track "view in context" usage (#74752) Co-authored-by: Elastic Machine --- .../logging/log_text_stream/log_entry_row.tsx | 12 +++++++----- .../top_categories/category_example_message.tsx | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) 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); },