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

@@ -71,6 +71,12 @@ import {
reRunQuery,
} from 'src/SqlLab/actions/sqlLab';
import { URL_PARAMS } from 'src/constants';
import useLogAction from 'src/logger/useLogAction';
import {
LOG_ACTIONS_SQLLAB_COPY_RESULT_TO_CLIPBOARD,
LOG_ACTIONS_SQLLAB_CREATE_CHART,
LOG_ACTIONS_SQLLAB_DOWNLOAD_CSV,
} from 'src/logger/LogUtils';
import Icons from 'src/components/Icons';
import ExploreCtasResultsButton from '../ExploreCtasResultsButton';
import ExploreResultsButton from '../ExploreResultsButton';
@@ -171,6 +177,7 @@ const ResultSet = ({
'dbId',
'tab',
'sql',
'sqlEditorId',
'templateParams',
'schema',
'rows',
@@ -201,6 +208,7 @@ const ResultSet = ({
const history = useHistory();
const dispatch = useDispatch();
const logAction = useLogAction({ queryId, sqlEditorId: query.sqlEditorId });
const reRunQueryIfSessionTimeoutErrorOnMount = useCallback(() => {
if (
@@ -258,7 +266,7 @@ const ResultSet = ({
const { results } = query;
const openInNewWindow = clickEvent.metaKey;
logAction(LOG_ACTIONS_SQLLAB_CREATE_CHART, {});
if (results?.query_id) {
const key = await postFormData(results.query_id, 'query', {
...EXPLORE_CHART_DEFAULT,
@@ -321,7 +329,11 @@ const ResultSet = ({
/>
)}
{csv && (
<Button buttonSize="small" href={getExportCsvUrl(query.id)}>
<Button
buttonSize="small"
href={getExportCsvUrl(query.id)}
onClick={() => logAction(LOG_ACTIONS_SQLLAB_DOWNLOAD_CSV, {})}
>
<i className="fa fa-file-text-o" /> {t('Download to CSV')}
</Button>
)}
@@ -335,6 +347,9 @@ const ResultSet = ({
</Button>
}
hideTooltip
onCopyEnd={() =>
logAction(LOG_ACTIONS_SQLLAB_COPY_RESULT_TO_CLIPBOARD, {})
}
/>
</ResultSetButtons>
{search && (