Skip to content

Commit

Permalink
[ui] add tracking to launch all button (#26411)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Linear:
https://linear.app/dagster-labs/issue/FE-719/add-tracking-to-the-launch-all-button

Adds tracking to the launch all button in the preview tick result modal

## How I Tested These Changes
Tested locally
  • Loading branch information
dliu27 authored Dec 13, 2024
1 parent 7583417 commit fbd0fe5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
() => ({
Expand Down Expand Up @@ -181,6 +184,8 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => {
if (!canLaunchAll) {
return;
}

trackEvent('launch-all-schedule');
setLaunching(true);

try {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -74,6 +75,8 @@ export const SensorDryRunDialog = (props: Props) => {
};

const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Props) => {
const trackEvent = useTrackEvent();

const [sensorDryRun] = useMutation<SensorDryRunMutation, SensorDryRunMutationVariables>(
EVALUATE_SENSOR_MUTATION,
);
Expand Down Expand Up @@ -187,6 +190,8 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop
if (!canLaunchAll) {
return;
}

trackEvent('launch-all-sensor');
setLaunching(true);

try {
Expand All @@ -206,6 +211,7 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop
launchMultipleRunsWithTelemetry,
onClose,
onCommitTickResult,
trackEvent,
]);

const leftButtons = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}) {
Expand Down Expand Up @@ -119,6 +125,8 @@ describe('EvaluateScheduleTest', () => {
createHref: createHrefSpy,
});

(useTrackEvent as jest.Mock).mockReturnValue(jest.fn());

render(
<MemoryRouter initialEntries={['/automation']}>
<Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {SensorDryRunDialog} from '../SensorDryRunDialog';
import * as Mocks from '../__fixtures__/SensorDryRunDialog.fixtures';

Expand All @@ -20,6 +21,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}) {
Expand Down Expand Up @@ -98,6 +104,8 @@ describe('SensorDryRunTest', () => {
createHref: createHrefSpy,
});

(useTrackEvent as jest.Mock).mockReturnValue(jest.fn());

render(
<MemoryRouter initialEntries={['/automation']}>
<Test
Expand Down

1 comment on commit fbd0fe5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-arzltttxw-elementl.vercel.app

Built with commit fbd0fe5.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.