chore(sqllab): Add logging for actions (#28876)

This commit is contained in:
JUST.in DO IT
2024-06-14 09:35:17 -07:00
committed by GitHub
parent 66bd0ce3d0
commit 05829cbda9
9 changed files with 217 additions and 12 deletions

View File

@@ -34,6 +34,11 @@ import {
import { getDatasourceAsSaveableDataset } from 'src/utils/datasourceUtils';
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
import { QueryEditor } from 'src/SqlLab/types';
import useLogAction from 'src/logger/useLogAction';
import {
LOG_ACTIONS_SQLLAB_CREATE_CHART,
LOG_ACTIONS_SQLLAB_SAVE_QUERY,
} from 'src/logger/LogUtils';
interface SaveQueryProps {
queryEditorId: string;
@@ -92,6 +97,7 @@ const SaveQuery = ({
}),
[queryEditor, columns],
);
const logAction = useLogAction({ queryEditorId });
const defaultLabel = query.name || query.description || t('Undefined');
const [description, setDescription] = useState<string>(
query.description || '',
@@ -106,7 +112,12 @@ const SaveQuery = ({
const overlayMenu = (
<Menu>
<Menu.Item onClick={() => setShowSaveDatasetModal(true)}>
<Menu.Item
onClick={() => {
logAction(LOG_ACTIONS_SQLLAB_CREATE_CHART, {});
setShowSaveDatasetModal(true);
}}
>
{t('Save dataset')}
</Menu.Item>
</Menu>
@@ -130,6 +141,7 @@ const SaveQuery = ({
const close = () => setShowSave(false);
const onSaveWrapper = () => {
logAction(LOG_ACTIONS_SQLLAB_SAVE_QUERY, {});
onSave(queryPayload(), query.id);
close();
};