Skip to content

Commit

Permalink
🗑️ clean up telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed Mar 8, 2024
1 parent 468b861 commit 09c24b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions core/util/posthog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class Telemetry {
}

static async setup(allow: boolean, uniqueId: string) {
Telemetry.uniqueId = uniqueId;
if (!allow) {
Telemetry.client = undefined;
} else {
Expand Down
28 changes: 11 additions & 17 deletions gui/src/hooks/useChatHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ function useChatHandler(dispatch: Dispatch) {
const defaultModel = useSelector(defaultModelSelector);

const slashCommands = useSelector(
(store: RootState) => store.state.config.slashCommands || []
(store: RootState) => store.state.config.slashCommands || [],
);

const contextItems = useSelector(
(state: RootState) => state.state.contextItems
(state: RootState) => state.state.contextItems,
);

const history = useSelector((store: RootState) => store.state.history);
Expand Down Expand Up @@ -70,7 +70,7 @@ function useChatHandler(dispatch: Dispatch) {
}

const getSlashCommandForInput = (
input: MessageContent
input: MessageContent,
): [SlashCommandDescription, string] | undefined => {
let slashCommand: SlashCommandDescription | undefined;
let slashCommandName: string | undefined;
Expand All @@ -83,7 +83,7 @@ function useChatHandler(dispatch: Dispatch) {
if (lastText.startsWith("/")) {
slashCommandName = lastText.split(" ")[0].substring(1);
slashCommand = slashCommands.find(
(command) => command.name === slashCommandName
(command) => command.name === slashCommandName,
);
}
if (!slashCommand || !slashCommandName) {
Expand All @@ -99,7 +99,7 @@ function useChatHandler(dispatch: Dispatch) {
slashCommand: SlashCommandDescription,
input: string,
historyIndex: number,
selectedCode: RangeInFile[]
selectedCode: RangeInFile[],
) {
const abortController = new AbortController();
const cancelToken = abortController.signal;
Expand All @@ -117,7 +117,7 @@ function useChatHandler(dispatch: Dispatch) {
historyIndex,
selectedCode,
},
cancelToken
cancelToken,
)) {
if (!activeRef.current) {
abortController.abort();
Expand Down Expand Up @@ -161,21 +161,17 @@ function useChatHandler(dispatch: Dispatch) {
message,
index: historyIndex,
contextItems,
})
}),
);

// TODO: hacky way to allow rerender
await new Promise((resolve) => setTimeout(resolve, 0));

posthog.capture("step run", {
step_name: "User Input",
params: {
user_input: content,
},
});
posthog.capture("userInput", {
input: content,
params: {},
});
posthog.capture("userInput", {});

const messages = constructMessages(newHistory);

Expand All @@ -188,16 +184,14 @@ function useChatHandler(dispatch: Dispatch) {
const [slashCommand, commandInput] = commandAndInput;
posthog.capture("step run", {
step_name: slashCommand.name,
params: {
user_input: commandInput,
},
params: {},
});
await _streamSlashCommand(
messages,
slashCommand,
commandInput,
historyIndex,
selectedCode
selectedCode,
);
}
} catch (e) {
Expand Down

0 comments on commit 09c24b4

Please sign in to comment.