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

@@ -26,6 +26,11 @@ import { DropdownButton } from 'src/components/DropdownButton';
import { detectOS } from 'src/utils/common';
import { QueryButtonProps } from 'src/SqlLab/types';
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
import {
LOG_ACTIONS_SQLLAB_RUN_QUERY,
LOG_ACTIONS_SQLLAB_STOP_QUERY,
} from 'src/logger/LogUtils';
import useLogAction from 'src/logger/useLogAction';
export interface RunQueryActionButtonProps {
queryEditorId: string;
@@ -58,7 +63,13 @@ const onClick = (
allowAsync: boolean,
runQuery: (c?: boolean) => void = () => undefined,
stopQuery = () => {},
logAction: (name: string, payload: Record<string, any>) => void,
): void => {
const eventName = shouldShowStopButton
? LOG_ACTIONS_SQLLAB_STOP_QUERY
: LOG_ACTIONS_SQLLAB_RUN_QUERY;
logAction(eventName, { shortcut: false });
if (shouldShowStopButton) return stopQuery();
if (allowAsync) {
return runQuery(true);
@@ -90,6 +101,7 @@ const RunQueryActionButton = ({
stopQuery,
}: RunQueryActionButtonProps) => {
const theme = useTheme();
const logAction = useLogAction({ queryEditorId });
const userOS = detectOS();
const { selectedText, sql } = useQueryEditor(queryEditorId, [
@@ -122,7 +134,7 @@ const RunQueryActionButton = ({
<ButtonComponent
data-test="run-query-action"
onClick={() =>
onClick(shouldShowStopBtn, allowAsync, runQuery, stopQuery)
onClick(shouldShowStopBtn, allowAsync, runQuery, stopQuery, logAction)
}
disabled={isDisabled}
tooltip={