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
70 changes: 1 addition & 69 deletions refact-agent/gui/src/app/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import {
import { setThemeMode, updateConfig } from "../features/Config/configSlice";
import { resetAttachedImagesSlice } from "../features/AttachedImages";
import { nextTip } from "../features/TipOfTheDay";
import { telemetryApi } from "../services/refact/telemetry";
import { CONFIG_PATH_URL, FULL_PATH_URL } from "../services/refact/consts";

import {
ideToolCallResponse,
ideForceReloadProjectTreeFiles,
Expand Down Expand Up @@ -349,73 +348,6 @@ startListening({
},
});

// Telemetry
startListening({
matcher: isAnyOf(
pathApi.endpoints.getFullPath.matchFulfilled,
pathApi.endpoints.getFullPath.matchRejected,
pathApi.endpoints.customizationPath.matchFulfilled,
pathApi.endpoints.customizationPath.matchRejected,
pathApi.endpoints.privacyPath.matchFulfilled,
pathApi.endpoints.privacyPath.matchRejected,
pathApi.endpoints.integrationsPath.matchFulfilled,
pathApi.endpoints.integrationsPath.matchRejected,
),
effect: (action, listenerApi) => {
if (pathApi.endpoints.getFullPath.matchFulfilled(action)) {
const thunk = telemetryApi.endpoints.sendTelemetryNetEvent.initiate({
url: FULL_PATH_URL,
scope: "getFullPath",
success: true,
error_message: "",
});
void listenerApi.dispatch(thunk);
}

if (
pathApi.endpoints.getFullPath.matchRejected(action) &&
!action.meta.condition
) {
const thunk = telemetryApi.endpoints.sendTelemetryNetEvent.initiate({
url: FULL_PATH_URL,
scope: "getFullPath",
success: false,
error_message: action.error.message ?? JSON.stringify(action.error),
});
void listenerApi.dispatch(thunk);
}

if (
pathApi.endpoints.customizationPath.matchFulfilled(action) ||
pathApi.endpoints.privacyPath.matchFulfilled(action) ||
pathApi.endpoints.integrationsPath.matchFulfilled(action)
) {
const thunk = telemetryApi.endpoints.sendTelemetryNetEvent.initiate({
url: CONFIG_PATH_URL,
scope: action.meta.arg.endpointName,
success: true,
error_message: "",
});
void listenerApi.dispatch(thunk);
}

if (
(pathApi.endpoints.customizationPath.matchRejected(action) ||
pathApi.endpoints.privacyPath.matchRejected(action) ||
pathApi.endpoints.integrationsPath.matchRejected(action)) &&
!action.meta.condition
) {
const thunk = telemetryApi.endpoints.sendTelemetryNetEvent.initiate({
url: CONFIG_PATH_URL,
scope: action.meta.arg.endpointName,
success: false,
error_message: action.error.message ?? JSON.stringify(action.error),
});
void listenerApi.dispatch(thunk);
}
},
});

// TODO: this should let flexus know that the user accepted the tool
// Tool Call results from ide.
startListening({
Expand Down
3 changes: 0 additions & 3 deletions refact-agent/gui/src/app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
pingApi,
integrationsApi,
dockerApi,
telemetryApi,
providersApi,
modelsApi,
teamsApi,
Expand Down Expand Up @@ -87,7 +86,6 @@ const rootReducer = combineSlices(
[pingApi.reducerPath]: pingApi.reducer,
[linksApi.reducerPath]: linksApi.reducer,
[checkpointsApi.reducerPath]: checkpointsApi.reducer,
[telemetryApi.reducerPath]: telemetryApi.reducer,
[teamsApi.reducerPath]: teamsApi.reducer,
[providersApi.reducerPath]: providersApi.reducer,
[modelsApi.reducerPath]: modelsApi.reducer,
Expand Down Expand Up @@ -174,7 +172,6 @@ export function setUpStore(preloadedState?: Partial<RootState>) {
integrationsApi.middleware,
dockerApi.middleware,
checkpointsApi.middleware,
telemetryApi.middleware,
providersApi.middleware,
modelsApi.middleware,
teamsApi.middleware,
Expand Down
43 changes: 3 additions & 40 deletions refact-agent/gui/src/components/ChatContent/AssistantInput.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useCallback } from "react";
import React from "react";
import { Markdown } from "../Markdown";

import { Container, Box } from "@radix-ui/themes";
import { AssistantMessage, ToolCall } from "../../services/refact";
import { ToolContent } from "./ToolsContent";
import { fallbackCopying } from "../../utils/fallbackCopying";
import { telemetryApi } from "../../services/refact/telemetry";
import { ReasoningContent } from "./ReasoningContent";
import { useCopyToClipboard } from "../../hooks";

type ChatInputProps = {
reasoningContent?: string | null;
Expand All @@ -20,43 +19,7 @@ export const AssistantInput: React.FC<ChatInputProps> = ({
toolCalls,
children,
}) => {
const [sendTelemetryEvent] =
telemetryApi.useLazySendTelemetryChatEventQuery();

const handleCopy = useCallback(
(text: string) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (window.navigator?.clipboard?.writeText) {
void window.navigator.clipboard
.writeText(text)
.catch(() => {
// eslint-disable-next-line no-console
console.log("failed to copy to clipboard");
void sendTelemetryEvent({
scope: `codeBlockCopyToClipboard`,
success: false,
error_message:
"window.navigator?.clipboard?.writeText: failed to copy to clipboard",
});
})
.then(() => {
void sendTelemetryEvent({
scope: `codeBlockCopyToClipboard`,
success: true,
error_message: "",
});
});
} else {
fallbackCopying(text);
void sendTelemetryEvent({
scope: `codeBlockCopyToClipboard`,
success: true,
error_message: "",
});
}
},
[sendTelemetryEvent],
);
const handleCopy = useCopyToClipboard();

return (
<Container position="relative">
Expand Down
11 changes: 2 additions & 9 deletions refact-agent/gui/src/components/Dropzone/Dropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Cross1Icon, ImageIcon } from "@radix-ui/react-icons";
import { DropzoneInputProps, FileRejection, useDropzone } from "react-dropzone";
import { useAttachedImages } from "../../hooks/useAttachedImages";
import { TruncateLeft } from "../Text";
import { telemetryApi } from "../../services/refact/telemetry";

// import { useCapsForToolUse } from "../../hooks";
import { useAttachedFiles } from "../ChatForm/useCheckBoxes";

Expand Down Expand Up @@ -81,8 +81,6 @@ export const DropzoneProvider: React.FC<
export const DropzoneConsumer = FileUploadContext.Consumer;

export const AttachImagesButton = () => {
const [sendTelemetryEvent] =
telemetryApi.useLazySendTelemetryChatEventQuery();
const attachFileOnClick = useCallback(
(
event: { preventDefault: () => void; stopPropagation: () => void },
Expand All @@ -91,13 +89,8 @@ export const AttachImagesButton = () => {
event.preventDefault();
event.stopPropagation();
open();
void sendTelemetryEvent({
scope: `addImage/button`, // add drag&drop and clipboard
success: true,
error_message: "",
});
},
[sendTelemetryEvent],
[],
);
return (
<DropzoneConsumer>
Expand Down
54 changes: 3 additions & 51 deletions refact-agent/gui/src/components/Toolbar/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
useEventsBusForIDE,
} from "../../hooks";
import { useWindowDimensions } from "../../hooks/useWindowDimensions";
import { telemetryApi } from "../../services/refact/telemetry";

// import styles from "./Toolbar.module.css";
import { resetThread } from "../../features/ThreadMessages";
Expand Down Expand Up @@ -71,8 +70,6 @@ export const Toolbar = ({ activeTab }: ToolbarProps) => {
const [focus, _setFocus] = useState<HTMLElement | null>(null);

const refs = useTourRefs();
const [sendTelemetryEvent] =
telemetryApi.useLazySendTelemetryChatEventQuery();

// const history = useAppSelector(getHistory, {
// devModeChecks: { stabilityCheck: "never" },
Expand All @@ -96,61 +93,26 @@ export const Toolbar = ({ activeTab }: ToolbarProps) => {
(to: DropdownNavigationOptions | "chat") => {
if (to === "settings") {
openSettings();
void sendTelemetryEvent({
scope: `openSettings`,
success: true,
error_message: "",
});
} else if (to === "hot keys") {
openHotKeys();
void sendTelemetryEvent({
scope: `openHotkeys`,
success: true,
error_message: "",
});
} else if (to === "fim") {
dispatch(push({ name: "fill in the middle debug page" }));
void sendTelemetryEvent({
scope: `openDebugFim`,
success: true,
error_message: "",
});
} else if (to === "stats") {
dispatch(push({ name: "statistics page" }));
void sendTelemetryEvent({
scope: `openStats`,
success: true,
error_message: "",
});
} else if (to === "restart tour") {
dispatch(popBackTo({ name: "login page" }));
dispatch(push({ name: "welcome" }));
dispatch(restart());
void sendTelemetryEvent({
scope: `restartTour`,
success: true,
error_message: "",
});
} else if (to === "integrations") {
dispatch(push({ name: "integrations page" }));
void sendTelemetryEvent({
scope: `openIntegrations`,
success: true,
error_message: "",
});
} else if (to === "providers") {
dispatch(push({ name: "providers page" }));
void sendTelemetryEvent({
scope: `openProviders`,
success: true,
error_message: "",
});
} else if (to === "chat") {
dispatch(popBackTo({ name: "history" }));
dispatch(push({ name: "chat" }));
}
},
[dispatch, sendTelemetryEvent, openSettings, openHotKeys],
[dispatch, openSettings, openHotKeys],
);

const onCreateNewChat = useCallback(() => {
Expand All @@ -160,12 +122,7 @@ export const Toolbar = ({ activeTab }: ToolbarProps) => {
dispatch(resetThread());
// clear out old chat
handleNavigation("chat");
void sendTelemetryEvent({
scope: `openNewChat`,
success: true,
error_message: "",
});
}, [dispatch, sendTelemetryEvent, handleNavigation]);
}, [dispatch, handleNavigation]);

const goToTab = useCallback(
(tab: Tab) => {
Expand All @@ -183,13 +140,8 @@ export const Toolbar = ({ activeTab }: ToolbarProps) => {
dispatch(popBackTo({ name: "history" }));
dispatch(push({ name: "chat" }));
}
void sendTelemetryEvent({
scope: `goToTab/${tab.type}`,
success: true,
error_message: "",
});
},
[dispatch, shouldChatTabLinkBeNotClickable, sendTelemetryEvent],
[dispatch, shouldChatTabLinkBeNotClickable],
);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion refact-agent/gui/src/features/Login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Accordion } from "../../components/Accordion";
import { useLogin, useEmailLogin, useEventsBusForIDE } from "../../hooks";
import { UnderConstruction } from "./UnderConstruction";

const IS_LOGIN_DISABLED = true;
const IS_LOGIN_DISABLED = false;

export const LoginPage: React.FC = () => {
const { loginWithProvider, polling, cancelLogin } = useLogin();
Expand Down
Loading