diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/EvaluateScheduleDialog.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/EvaluateScheduleDialog.tsx index 06add60352b2c..7262979f9473a 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/EvaluateScheduleDialog.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/EvaluateScheduleDialog.tsx @@ -34,6 +34,7 @@ import {showCustomAlert} from '../app/CustomAlertProvider'; import {PYTHON_ERROR_FRAGMENT} from '../app/PythonErrorFragment'; import {PythonErrorInfo} from '../app/PythonErrorInfo'; import {assertUnreachable} from '../app/Util'; +import {useTrackEvent} from '../app/analytics'; import {TimeContext} from '../app/time/TimeContext'; import {timestampToString} from '../app/time/timestampToString'; import {PythonErrorFragment} from '../app/types/PythonErrorFragment.types'; @@ -77,6 +78,8 @@ export const EvaluateScheduleDialog = (props: Props) => { }; const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => { + const trackEvent = useTrackEvent(); + const [selectedTimestamp, setSelectedTimestamp] = useState<{ts: number; label: string}>(); const scheduleSelector: ScheduleSelector = useMemo( () => ({ @@ -181,6 +184,8 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => { if (!canLaunchAll) { return; } + + trackEvent('launch-all-schedule'); setLaunching(true); try { @@ -193,7 +198,7 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => { setLaunching(false); onClose(); - }, [canLaunchAll, executionParamsList, launchMultipleRunsWithTelemetry, onClose]); + }, [canLaunchAll, executionParamsList, launchMultipleRunsWithTelemetry, onClose, trackEvent]); const content = useMemo(() => { // launching all runs state diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/SensorDryRunDialog.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/SensorDryRunDialog.tsx index 1cd0bda5aad43..1047d13d9a391 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/SensorDryRunDialog.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/SensorDryRunDialog.tsx @@ -32,6 +32,7 @@ import {showSharedToaster} from '../app/DomUtils'; import {PYTHON_ERROR_FRAGMENT} from '../app/PythonErrorFragment'; import {PythonErrorInfo} from '../app/PythonErrorInfo'; import {assertUnreachable} from '../app/Util'; +import {useTrackEvent} from '../app/analytics'; import {PythonErrorFragment} from '../app/types/PythonErrorFragment.types'; import {SensorSelector} from '../graphql/types'; import {useLaunchMultipleRunsWithTelemetry} from '../launchpad/useLaunchMultipleRunsWithTelemetry'; @@ -74,6 +75,8 @@ export const SensorDryRunDialog = (props: Props) => { }; const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Props) => { + const trackEvent = useTrackEvent(); + const [sensorDryRun] = useMutation( EVALUATE_SENSOR_MUTATION, ); @@ -187,6 +190,8 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop if (!canLaunchAll) { return; } + + trackEvent('launch-all-sensor'); setLaunching(true); try { @@ -206,6 +211,7 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop launchMultipleRunsWithTelemetry, onClose, onCommitTickResult, + trackEvent, ]); const leftButtons = useMemo(() => { diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/EvaluateScheduleDialog.test.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/EvaluateScheduleDialog.test.tsx index 6c17208d0628d..a8a2b55c06eb5 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/EvaluateScheduleDialog.test.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/__tests__/EvaluateScheduleDialog.test.tsx @@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event'; import {MemoryRouter, useHistory} from 'react-router-dom'; import {Resolvers} from '../../apollo-client'; +import {useTrackEvent} from '../../app/analytics'; import {EvaluateScheduleDialog} from '../EvaluateScheduleDialog'; import { GetScheduleQueryMock, @@ -26,6 +27,11 @@ jest.mock('react-router-dom', () => ({ useHistory: jest.fn(), })); +// Mocking useTrackEvent +jest.mock('../../app/analytics', () => ({ + useTrackEvent: jest.fn(() => jest.fn()), +})); + const onCloseMock = jest.fn(); function Test({mocks, resolvers}: {mocks?: MockedResponse[]; resolvers?: Resolvers}) { @@ -119,6 +125,8 @@ describe('EvaluateScheduleTest', () => { createHref: createHrefSpy, }); + (useTrackEvent as jest.Mock).mockReturnValue(jest.fn()); + render( ({ useHistory: jest.fn(), })); +// Mocking useTrackEvent +jest.mock('../../app/analytics', () => ({ + useTrackEvent: jest.fn(() => jest.fn()), +})); + const onCloseMock = jest.fn(); function Test({mocks, resolvers}: {mocks?: MockedResponse[]; resolvers?: Resolvers}) { @@ -98,6 +104,8 @@ describe('SensorDryRunTest', () => { createHref: createHrefSpy, }); + (useTrackEvent as jest.Mock).mockReturnValue(jest.fn()); + render(