From 07381834f885d5813862d33b2870ad7be5cfdfca Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Fri, 28 Apr 2023 09:06:57 +0200 Subject: [PATCH] chore: Add logging events for drill by (#23854) --- .../components/Chart/DrillBy/DrillByModal.tsx | 45 ++++++++++++++++--- superset-frontend/src/logger/LogUtils.ts | 5 +++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx index 1204a77bdfe15..d1e8b39e0c963 100644 --- a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx @@ -35,7 +35,7 @@ import { useTheme, ContextMenuFilters, } from '@superset-ui/core'; -import { useSelector } from 'react-redux'; +import { useDispatch, useSelector } from 'react-redux'; import { Link } from 'react-router-dom'; import Modal from 'src/components/Modal'; import Loading from 'src/components/Loading'; @@ -43,11 +43,17 @@ import Button from 'src/components/Button'; import { RootState } from 'src/dashboard/types'; import { DashboardPageIdContext } from 'src/dashboard/containers/DashboardPage'; import { postFormData } from 'src/explore/exploreUtils/formData'; -import { noOp } from 'src/utils/common'; import { simpleFilterToAdhoc } from 'src/utils/simpleFilterToAdhoc'; import { useDatasetMetadataBar } from 'src/features/datasets/metadataBar/useDatasetMetadataBar'; import { useToasts } from 'src/components/MessageToasts/withToasts'; import Alert from 'src/components/Alert'; +import { logEvent } from 'src/logger/actions'; +import { + LOG_ACTIONS_DRILL_BY_BREADCRUMB_CLICKED, + LOG_ACTIONS_DRILL_BY_EDIT_CHART, + LOG_ACTIONS_DRILL_BY_MODAL_OPENED, + LOG_ACTIONS_FURTHER_DRILL_BY, +} from 'src/logger/LogUtils'; import { Dataset, DrillByType } from '../types'; import DrillByChart from './DrillByChart'; import { ContextMenuItem } from '../ChartContextMenu/ChartContextMenu'; @@ -67,9 +73,18 @@ interface ModalFooterProps { } const ModalFooter = ({ formData, closeModal }: ModalFooterProps) => { + const dispatch = useDispatch(); const { addDangerToast } = useToasts(); const [url, setUrl] = useState(''); const dashboardPageId = useContext(DashboardPageIdContext); + const onEditChartClick = useCallback(() => { + dispatch( + logEvent(LOG_ACTIONS_DRILL_BY_EDIT_CHART, { + slice_id: formData.slice_id, + }), + ); + }, [dispatch, formData.slice_id]); + const [datasource_id, datasource_type] = formData.datasource.split('__'); useEffect(() => { postFormData(Number(datasource_id), datasource_type, formData, 0) @@ -93,7 +108,7 @@ const ModalFooter = ({ formData, closeModal }: ModalFooterProps) => {