Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/components/automations/create-instructions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ describe("CreateInstructions", () => {
captureMock.mockRestore();
});

it("captures automation_created with the active backend kind when Create Automation is clicked", async () => {
it("captures automation_created_button with the active backend kind when Create Automation is clicked", async () => {
const user = userEvent.setup();
renderCreateInstructions();

await user.click(screen.getByTestId("automations-create-automation"));

expect(captureMock).toHaveBeenCalledWith(
"automation_created",
"automation_created_button",
expect.objectContaining({ backend_kind: "local" }),
);
});
Expand Down
8 changes: 4 additions & 4 deletions __tests__/hooks/query/use-automations-backend-switch.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe("automation mutation hooks — analytics tracking", () => {
});
});

it("captures automation_deactivated when an automation is disabled", async () => {
it("captures automation_disable_button when an automation is disabled", async () => {
const { result } = renderHook(() => useToggleAutomation(), {
wrapper: makeWrapper(),
});
Expand All @@ -318,13 +318,13 @@ describe("automation mutation hooks — analytics tracking", () => {

await waitFor(() => {
expect(captureMock).toHaveBeenCalledWith(
"automation_deactivated",
"automation_disable_button",
expect.objectContaining({ backend_kind: "local" }),
);
});
});

it("does not capture automation_deactivated when an automation is enabled", async () => {
it("does not capture automation_disable_button when an automation is enabled", async () => {
const { result } = renderHook(() => useToggleAutomation(), {
wrapper: makeWrapper(),
});
Expand All @@ -334,7 +334,7 @@ describe("automation mutation hooks — analytics tracking", () => {
});

expect(captureMock).not.toHaveBeenCalledWith(
"automation_deactivated",
"automation_disable_button",
expect.anything(),
);
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/features/automations/create-instructions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export function CreateInstructionsContent({
const { t } = useTranslation("openhands");
const launchInChat = useLaunchSkillInChat();
const active = useActiveBackend();
const { trackAutomationCreated } = useTracking();
const { trackAutomationCreatedButton } = useTracking();

const handleCreateAutomation = () => {
trackAutomationCreated({ backendKind: active.backend.kind });
trackAutomationCreatedButton({ backendKind: active.backend.kind });
launchInChat(t(I18nKey.AUTOMATIONS$CREATE_AUTOMATION_PROMPT), onLaunch);
};

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/query/use-automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ export function useAutomations(options: UseAutomationsOptions = {}) {
export function useToggleAutomation() {
const queryClient = useQueryClient();
const active = useActiveBackend();
const { trackAutomationDeactivated } = useTracking();
const { trackAutomationDisableButton } = useTracking();
return useMutation({
mutationFn: ({ id, enabled }: { id: string; enabled: boolean }) =>
AutomationService.toggleAutomation(id, enabled),
onSuccess: (_data, variables) => {
queryClient.invalidateQueries({ queryKey: AUTOMATIONS_QUERY_KEY });
queryClient.invalidateQueries({ queryKey: AUTOMATION_DETAIL_QUERY_KEY });
if (!variables.enabled) {
trackAutomationDeactivated({ backendKind: active.backend.kind });
trackAutomationDisableButton({ backendKind: active.backend.kind });
}
},
});
Expand Down
12 changes: 6 additions & 6 deletions src/hooks/use-tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ export const useTracking = () => {
track("conversation_exported", { format });
};

const trackAutomationCreated = ({
const trackAutomationCreatedButton = ({
backendKind,
}: {
backendKind: BackendKind;
}) => {
track("automation_created", { backend_kind: backendKind });
track("automation_created_button", { backend_kind: backendKind });
};

const trackAutomationExecuted = ({
Expand All @@ -226,12 +226,12 @@ export const useTracking = () => {
track("automation_deleted", { backend_kind: backendKind });
};

const trackAutomationDeactivated = ({
const trackAutomationDisableButton = ({
backendKind,
}: {
backendKind: BackendKind;
}) => {
track("automation_deactivated", { backend_kind: backendKind });
track("automation_disable_button", { backend_kind: backendKind });
};

const trackAutomationEdited = ({
Expand Down Expand Up @@ -346,10 +346,10 @@ export const useTracking = () => {
trackMcpConfigUpdated,
trackDownloadTrajectoryButtonClicked,
trackConversationExported,
trackAutomationCreated,
trackAutomationCreatedButton,
trackAutomationExecuted,
trackAutomationDeleted,
trackAutomationDeactivated,
trackAutomationDisableButton,
trackAutomationEdited,
trackAutomationExported,
trackAutomationImported,
Expand Down
Loading