Track "view in context" usage (#74752)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
9295378d59
commit
cf65b6ba8c
|
@ -8,7 +8,7 @@ import React, { memo, useState, useCallback, useMemo } from 'react';
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
|
|
||||||
import { euiStyled } from '../../../../../observability/public';
|
import { euiStyled, useUiTracker } from '../../../../../observability/public';
|
||||||
import { isTimestampColumn } from '../../../utils/log_entry';
|
import { isTimestampColumn } from '../../../utils/log_entry';
|
||||||
import {
|
import {
|
||||||
LogColumnConfiguration,
|
LogColumnConfiguration,
|
||||||
|
@ -68,6 +68,8 @@ export const LogEntryRow = memo(
|
||||||
scale,
|
scale,
|
||||||
wrap,
|
wrap,
|
||||||
}: LogEntryRowProps) => {
|
}: LogEntryRowProps) => {
|
||||||
|
const trackMetric = useUiTracker({ app: 'infra_logs' });
|
||||||
|
|
||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||||
|
|
||||||
|
@ -82,10 +84,10 @@ export const LogEntryRow = memo(
|
||||||
logEntry.id,
|
logEntry.id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleOpenViewLogInContext = useCallback(() => openViewLogInContext?.(logEntry), [
|
const handleOpenViewLogInContext = useCallback(() => {
|
||||||
openViewLogInContext,
|
openViewLogInContext?.(logEntry); // eslint-disable-line no-unused-expressions
|
||||||
logEntry,
|
trackMetric({ metric: 'view_in_context__stream' });
|
||||||
]);
|
}, [openViewLogInContext, logEntry, trackMetric]);
|
||||||
|
|
||||||
const hasContext = useMemo(() => !isEmpty(logEntry.context), [logEntry]);
|
const hasContext = useMemo(() => !isEmpty(logEntry.context), [logEntry]);
|
||||||
const hasActionFlyoutWithItem = openFlyoutWithItem !== undefined;
|
const hasActionFlyoutWithItem = openFlyoutWithItem !== undefined;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import {
|
||||||
import { LogColumnConfiguration } from '../../../../../utils/source_configuration';
|
import { LogColumnConfiguration } from '../../../../../utils/source_configuration';
|
||||||
import { LogEntryContextMenu } from '../../../../../components/logging/log_text_stream/log_entry_context_menu';
|
import { LogEntryContextMenu } from '../../../../../components/logging/log_text_stream/log_entry_context_menu';
|
||||||
import { useLinkProps } from '../../../../../hooks/use_link_props';
|
import { useLinkProps } from '../../../../../hooks/use_link_props';
|
||||||
|
import { useUiTracker } from '../../../../../../../observability/public';
|
||||||
|
|
||||||
export const exampleMessageScale = 'medium' as const;
|
export const exampleMessageScale = 'medium' as const;
|
||||||
export const exampleTimestampFormat = 'dateTime' as const;
|
export const exampleTimestampFormat = 'dateTime' as const;
|
||||||
|
@ -39,6 +40,7 @@ export const CategoryExampleMessage: React.FunctionComponent<{
|
||||||
tiebreaker: number;
|
tiebreaker: number;
|
||||||
context: LogEntryContext;
|
context: LogEntryContext;
|
||||||
}> = ({ id, dataset, message, timestamp, timeRange, tiebreaker, context }) => {
|
}> = ({ id, dataset, message, timestamp, timeRange, tiebreaker, context }) => {
|
||||||
|
const trackMetric = useUiTracker({ app: 'infra_logs' });
|
||||||
const [, { setContextEntry }] = useContext(ViewLogInContext.Context);
|
const [, { setContextEntry }] = useContext(ViewLogInContext.Context);
|
||||||
// handle special cases for the dataset value
|
// handle special cases for the dataset value
|
||||||
const humanFriendlyDataset = getFriendlyNameForPartitionId(dataset);
|
const humanFriendlyDataset = getFriendlyNameForPartitionId(dataset);
|
||||||
|
@ -129,6 +131,7 @@ export const CategoryExampleMessage: React.FunctionComponent<{
|
||||||
cursor: { time: timestamp, tiebreaker },
|
cursor: { time: timestamp, tiebreaker },
|
||||||
columns: [],
|
columns: [],
|
||||||
};
|
};
|
||||||
|
trackMetric({ metric: 'view_in_context__categories' });
|
||||||
|
|
||||||
setContextEntry(logEntry);
|
setContextEntry(logEntry);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue