mirror of
https://github.com/apache/superset.git
synced 2026-04-24 10:35:01 +00:00
chore(sqllab): Add logging for actions (#28876)
This commit is contained in:
@@ -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={
|
||||
|
||||
Reference in New Issue
Block a user