mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 20:38:59 +08:00
chore: add log events to alert history page (#6396)
* chore: pass active route with RouteTab's onChangeHandler * chore: add log events to alert history page --------- Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
This commit is contained in:
parent
0b03ff07f1
commit
20e64b5102
@ -11,7 +11,7 @@ function RouteTab({
|
|||||||
}: RouteTabProps & TabsProps): JSX.Element {
|
}: RouteTabProps & TabsProps): JSX.Element {
|
||||||
const onChange = (activeRoute: string): void => {
|
const onChange = (activeRoute: string): void => {
|
||||||
if (onChangeHandler) {
|
if (onChangeHandler) {
|
||||||
onChangeHandler();
|
onChangeHandler(activeRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedRoute = routes.find((e) => e.key === activeRoute);
|
const selectedRoute = routes.find((e) => e.key === activeRoute);
|
||||||
|
@ -11,6 +11,6 @@ export type TabRoutes = {
|
|||||||
export interface RouteTabProps {
|
export interface RouteTabProps {
|
||||||
routes: TabRoutes[];
|
routes: TabRoutes[];
|
||||||
activeKey: TabsProps['activeKey'];
|
activeKey: TabsProps['activeKey'];
|
||||||
onChangeHandler?: VoidFunction;
|
onChangeHandler?: (key: string) => void;
|
||||||
history: History<unknown>;
|
history: History<unknown>;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
import { Color } from '@signozhq/design-tokens';
|
import { Color } from '@signozhq/design-tokens';
|
||||||
import { Progress, Table } from 'antd';
|
import { Progress, Table } from 'antd';
|
||||||
import { ColumnsType } from 'antd/es/table';
|
import { ColumnsType } from 'antd/es/table';
|
||||||
|
import logEvent from 'api/common/logEvent';
|
||||||
import { ConditionalAlertPopover } from 'container/AlertHistory/AlertPopover/AlertPopover';
|
import { ConditionalAlertPopover } from 'container/AlertHistory/AlertPopover/AlertPopover';
|
||||||
import AlertLabels from 'pages/AlertDetails/AlertHeader/AlertLabels/AlertLabels';
|
import AlertLabels from 'pages/AlertDetails/AlertHeader/AlertLabels/AlertLabels';
|
||||||
import PaginationInfoText from 'periscope/components/PaginationInfoText/PaginationInfoText';
|
import PaginationInfoText from 'periscope/components/PaginationInfoText/PaginationInfoText';
|
||||||
import { AlertRuleStats, AlertRuleTopContributors } from 'types/api/alerts/def';
|
import { HTMLAttributes } from 'react';
|
||||||
|
import {
|
||||||
|
AlertRuleStats,
|
||||||
|
AlertRuleTimelineTableResponse,
|
||||||
|
AlertRuleTopContributors,
|
||||||
|
} from 'types/api/alerts/def';
|
||||||
|
|
||||||
function TopContributorsRows({
|
function TopContributorsRows({
|
||||||
topContributors,
|
topContributors,
|
||||||
@ -70,10 +76,21 @@ function TopContributorsRows({
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const handleRowClick = (
|
||||||
|
record: AlertRuleTopContributors,
|
||||||
|
): HTMLAttributes<AlertRuleTimelineTableResponse> => ({
|
||||||
|
onClick: (): void => {
|
||||||
|
logEvent('Alert history: Top contributors row: Clicked', {
|
||||||
|
labels: record.labels,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
rowClassName="contributors-row"
|
rowClassName="contributors-row"
|
||||||
rowKey={(row): string => `top-contributor-${row.fingerprint}`}
|
rowKey={(row): string => `top-contributor-${row.fingerprint}`}
|
||||||
|
onRow={handleRowClick}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
showHeader={false}
|
showHeader={false}
|
||||||
dataSource={topContributors}
|
dataSource={topContributors}
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
import './Table.styles.scss';
|
import './Table.styles.scss';
|
||||||
|
|
||||||
import { Table } from 'antd';
|
import { Table } from 'antd';
|
||||||
|
import logEvent from 'api/common/logEvent';
|
||||||
import { initialFilters } from 'constants/queryBuilder';
|
import { initialFilters } from 'constants/queryBuilder';
|
||||||
import {
|
import {
|
||||||
useGetAlertRuleDetailsTimelineTable,
|
useGetAlertRuleDetailsTimelineTable,
|
||||||
useTimelineTable,
|
useTimelineTable,
|
||||||
} from 'pages/AlertDetails/hooks';
|
} from 'pages/AlertDetails/hooks';
|
||||||
import { useMemo, useState } from 'react';
|
import { HTMLAttributes, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { AlertRuleTimelineTableResponse } from 'types/api/alerts/def';
|
||||||
import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
||||||
|
|
||||||
import { timelineTableColumns } from './useTimelineTable';
|
import { timelineTableColumns } from './useTimelineTable';
|
||||||
@ -43,6 +45,17 @@ function TimelineTable(): JSX.Element {
|
|||||||
return <div>{t('something_went_wrong')}</div>;
|
return <div>{t('something_went_wrong')}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleRowClick = (
|
||||||
|
record: AlertRuleTimelineTableResponse,
|
||||||
|
): HTMLAttributes<AlertRuleTimelineTableResponse> => ({
|
||||||
|
onClick: (): void => {
|
||||||
|
logEvent('Alert history: Timeline table row: Clicked', {
|
||||||
|
ruleId: record.ruleID,
|
||||||
|
labels: record.labels,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="timeline-table">
|
<div className="timeline-table">
|
||||||
<Table
|
<Table
|
||||||
@ -52,6 +65,7 @@ function TimelineTable(): JSX.Element {
|
|||||||
labels: labels ?? {},
|
labels: labels ?? {},
|
||||||
setFilters,
|
setFilters,
|
||||||
})}
|
})}
|
||||||
|
onRow={handleRowClick}
|
||||||
dataSource={timelineData}
|
dataSource={timelineData}
|
||||||
pagination={paginationConfig}
|
pagination={paginationConfig}
|
||||||
size="middle"
|
size="middle"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import './AlertDetails.styles.scss';
|
import './AlertDetails.styles.scss';
|
||||||
|
|
||||||
import { Breadcrumb, Button, Divider } from 'antd';
|
import { Breadcrumb, Button, Divider } from 'antd';
|
||||||
|
import logEvent from 'api/common/logEvent';
|
||||||
import { Filters } from 'components/AlertDetailsFilters/Filters';
|
import { Filters } from 'components/AlertDetailsFilters/Filters';
|
||||||
import NotFound from 'components/NotFound';
|
import NotFound from 'components/NotFound';
|
||||||
import RouteTab from 'components/RouteTab';
|
import RouteTab from 'components/RouteTab';
|
||||||
@ -87,6 +88,12 @@ function AlertDetails(): JSX.Element {
|
|||||||
return <NotFound />;
|
return <NotFound />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleTabChange = (route: string): void => {
|
||||||
|
if (route === ROUTES.ALERT_HISTORY) {
|
||||||
|
logEvent('Alert History tab: Visited', { ruleId });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="alert-details">
|
<div className="alert-details">
|
||||||
<Breadcrumb
|
<Breadcrumb
|
||||||
@ -113,6 +120,7 @@ function AlertDetails(): JSX.Element {
|
|||||||
routes={routes}
|
routes={routes}
|
||||||
activeKey={pathname}
|
activeKey={pathname}
|
||||||
history={history}
|
history={history}
|
||||||
|
onChangeHandler={handleTabChange}
|
||||||
tabBarExtraContent={<Filters />}
|
tabBarExtraContent={<Filters />}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user