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

chore: update logs in infra monitoring for analytics #6994

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -181,6 +181,10 @@ function ClusterDetails({

const handleTabChange = (e: RadioChangeEvent): void => {
setSelectedView(e.target.value);
logEvent('Infra Monitoring: Clusters list details tab changed', {
cluster: cluster?.clusterUID,
view: e.target.value,
});
};

const handleTimeChange = useCallback(
Expand All @@ -204,6 +208,7 @@ function ClusterDetails({
logEvent('Infra Monitoring: Clusters list details time updated', {
cluster: cluster?.clusterUID,
interval,
view: selectedView,
});
},
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ function K8sClustersList({
}
}, [selectedRowData, fetchGroupedByRowData]);

const numberOfPages = useMemo(() => Math.ceil(totalCount / pageSize), [
totalCount,
pageSize,
]);

const handleTableChange: TableProps<K8sClustersRowData>['onChange'] = useCallback(
(
pagination: TablePaginationConfig,
Expand All @@ -245,6 +250,11 @@ function K8sClustersList({
): void => {
if (pagination.current) {
setCurrentPage(pagination.current);
logEvent('Infra Monitoring: K8s clusters list page number changed', {
page: pagination.current,
pageSize,
numberOfPages,
});
}

if ('field' in sorter && sorter.order) {
Expand All @@ -256,7 +266,7 @@ function K8sClustersList({
setOrderBy(null);
}
},
[],
[numberOfPages, pageSize],
);

const { handleChangeQueryData } = useQueryOperations({
Expand All @@ -270,15 +280,13 @@ function K8sClustersList({
handleChangeQueryData('filters', value);
setCurrentPage(1);

logEvent('Infra Monitoring: K8s list filters applied', {
filters: value,
});
logEvent('Infra Monitoring: K8s clusters list filters applied', {});
},
[handleChangeQueryData],
);

useEffect(() => {
logEvent('Infra Monitoring: K8s list page visited', {});
logEvent('Infra Monitoring: K8s clusters list page visited', {});
}, []);

const selectedClusterData = useMemo(() => {
Expand Down Expand Up @@ -424,6 +432,7 @@ function K8sClustersList({
setCurrentPage(1);
setGroupBy(groupBy);
setExpandedRowKeys([]);
logEvent('Infra Monitoring: K8s clusters list group by changed', {});
},
[groupByFiltersData],
);
Expand All @@ -439,6 +448,16 @@ function K8sClustersList({
}
}, [groupByFiltersData]);

const onPaginationChange = (page: number, pageSize: number): void => {
setCurrentPage(page);
setPageSize(pageSize);
logEvent('Infra Monitoring: K8s clusters list page number changed', {
page,
pageSize,
numberOfPages,
});
};

return (
<div className="k8s-list">
<K8sHeader
Expand All @@ -464,10 +483,7 @@ function K8sClustersList({
total: totalCount,
showSizeChanger: true,
hideOnSinglePage: false,
onChange: (page, pageSize): void => {
setCurrentPage(page);
setPageSize(pageSize);
},
onChange: onPaginationChange,
}}
scroll={{ x: true }}
loading={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ function DaemonSetDetails({

const handleTabChange = (e: RadioChangeEvent): void => {
setSelectedView(e.target.value);
logEvent('Infra Monitoring: DaemonSets list details tab changed', {
daemonSet: daemonSet?.daemonSetName,
view: e.target.value,
});
};

const handleTimeChange = useCallback(
Expand All @@ -218,6 +222,7 @@ function DaemonSetDetails({
logEvent('Infra Monitoring: DaemonSets list details time updated', {
daemonSet: daemonSet?.daemonSetName,
interval,
view: selectedView,
});
},
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ function K8sDaemonSetsList({
}
}, [selectedRowData, fetchGroupedByRowData]);

const numberOfPages = useMemo(() => Math.ceil(totalCount / pageSize), [
totalCount,
pageSize,
]);

const handleTableChange: TableProps<K8sDaemonSetsRowData>['onChange'] = useCallback(
(
pagination: TablePaginationConfig,
Expand All @@ -248,6 +253,11 @@ function K8sDaemonSetsList({
): void => {
if (pagination.current) {
setCurrentPage(pagination.current);
logEvent('Infra Monitoring: K8s daemonSets list page number changed', {
page: pagination.current,
pageSize,
numberOfPages,
});
}

if ('field' in sorter && sorter.order) {
Expand All @@ -259,7 +269,7 @@ function K8sDaemonSetsList({
setOrderBy(null);
}
},
[],
[numberOfPages, pageSize],
);

const { handleChangeQueryData } = useQueryOperations({
Expand All @@ -273,15 +283,13 @@ function K8sDaemonSetsList({
handleChangeQueryData('filters', value);
setCurrentPage(1);

logEvent('Infra Monitoring: K8s list filters applied', {
filters: value,
});
logEvent('Infra Monitoring: K8s daemonSets list filters applied', {});
},
[handleChangeQueryData],
);

useEffect(() => {
logEvent('Infra Monitoring: K8s list page visited', {});
logEvent('Infra Monitoring: K8s daemonSets list page visited', {});
}, []);

const selectedDaemonSetData = useMemo(() => {
Expand Down Expand Up @@ -426,6 +434,8 @@ function K8sDaemonSetsList({
setCurrentPage(1);
setGroupBy(groupBy);
setExpandedRowKeys([]);

logEvent('Infra Monitoring: K8s daemonSets list group by changed', {});
},
[groupByFiltersData],
);
Expand All @@ -441,6 +451,16 @@ function K8sDaemonSetsList({
}
}, [groupByFiltersData]);

const onPaginationChange = (page: number, pageSize: number): void => {
setCurrentPage(page);
setPageSize(pageSize);
logEvent('Infra Monitoring: K8s daemonSets list page number changed', {
page,
pageSize,
numberOfPages,
});
};

return (
<div className="k8s-list">
<K8sHeader
Expand Down Expand Up @@ -468,10 +488,7 @@ function K8sDaemonSetsList({
total: totalCount,
showSizeChanger: true,
hideOnSinglePage: false,
onChange: (page, pageSize): void => {
setCurrentPage(page);
setPageSize(pageSize);
},
onChange: onPaginationChange,
}}
scroll={{ x: true }}
loading={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ function DeploymentDetails({

const handleTabChange = (e: RadioChangeEvent): void => {
setSelectedView(e.target.value);
logEvent('Infra Monitoring: Deployments list details tab changed', {
deployment: deployment?.deploymentName,
view: e.target.value,
});
};

const handleTimeChange = useCallback(
Expand All @@ -220,6 +224,7 @@ function DeploymentDetails({
logEvent('Infra Monitoring: Deployments list details time updated', {
deployment: deployment?.deploymentName,
interval,
view: selectedView,
});
},
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ function K8sDeploymentsList({
}
}, [selectedRowData, fetchGroupedByRowData]);

const numberOfPages = useMemo(() => Math.ceil(totalCount / pageSize), [
totalCount,
pageSize,
]);

const handleTableChange: TableProps<K8sDeploymentsRowData>['onChange'] = useCallback(
(
pagination: TablePaginationConfig,
Expand All @@ -250,6 +255,11 @@ function K8sDeploymentsList({
): void => {
if (pagination.current) {
setCurrentPage(pagination.current);
logEvent('Infra Monitoring: K8s deployments list page number changed', {
page: pagination.current,
pageSize,
numberOfPages,
});
}

if ('field' in sorter && sorter.order) {
Expand All @@ -261,7 +271,7 @@ function K8sDeploymentsList({
setOrderBy(null);
}
},
[],
[numberOfPages, pageSize],
);

const { handleChangeQueryData } = useQueryOperations({
Expand All @@ -275,15 +285,13 @@ function K8sDeploymentsList({
handleChangeQueryData('filters', value);
setCurrentPage(1);

logEvent('Infra Monitoring: K8s list filters applied', {
filters: value,
});
logEvent('Infra Monitoring: K8s deployments list filters applied', {});
},
[handleChangeQueryData],
);

useEffect(() => {
logEvent('Infra Monitoring: K8s list page visited', {});
logEvent('Infra Monitoring: K8s deployments list page visited', {});
}, []);

const selectedDeploymentData = useMemo(() => {
Expand Down Expand Up @@ -429,6 +437,8 @@ function K8sDeploymentsList({
setCurrentPage(1);
setGroupBy(groupBy);
setExpandedRowKeys([]);

logEvent('Infra Monitoring: K8s deployments list group by changed', {});
},
[groupByFiltersData],
);
Expand All @@ -444,6 +454,16 @@ function K8sDeploymentsList({
}
}, [groupByFiltersData]);

const onPaginationChange = (page: number, pageSize: number): void => {
setCurrentPage(page);
setPageSize(pageSize);
logEvent('Infra Monitoring: K8s deployments list page number changed', {
page,
pageSize,
numberOfPages,
});
};

return (
<div className="k8s-list">
<K8sHeader
Expand Down Expand Up @@ -471,10 +491,7 @@ function K8sDeploymentsList({
total: totalCount,
showSizeChanger: true,
hideOnSinglePage: false,
onChange: (page, pageSize): void => {
setCurrentPage(page);
setPageSize(pageSize);
},
onChange: onPaginationChange,
}}
scroll={{ x: true }}
loading={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { VerticalAlignTopOutlined } from '@ant-design/icons';
import * as Sentry from '@sentry/react';
import type { CollapseProps } from 'antd';
import { Collapse, Tooltip, Typography } from 'antd';
import logEvent from 'api/common/logEvent';
import QuickFilters from 'components/QuickFilters/QuickFilters';
import { QuickFiltersSource } from 'components/QuickFilters/types';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
Expand Down Expand Up @@ -68,6 +69,11 @@ export default function InfraMonitoringK8s(): JSX.Element {
// in infra monitoring k8s, we are using only one query, hence updating the 0th index of queryData
handleChangeQueryData('filters', query.builder.queryData[0].filters);
setQuickFiltersLastUpdated(Date.now());

logEvent(
`Infra Monitoring: K8s ${selectedCategory} list quick filters applied`,
{},
);
};

const items: CollapseProps['items'] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ function JobDetails({

const handleTabChange = (e: RadioChangeEvent): void => {
setSelectedView(e.target.value);
logEvent('Infra Monitoring: Jobs list details tab changed', {
job: job?.jobName,
view: e.target.value,
});
};

const handleTimeChange = useCallback(
Expand All @@ -215,6 +219,7 @@ function JobDetails({
logEvent('Infra Monitoring: Jobs list details time updated', {
job: job?.jobName,
interval,
view: selectedView,
});
},
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Loading
Loading