From 09c24b4f89a73a7116efd98b51f4d8cef79a276d Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 7 Mar 2024 16:32:50 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20clean=20up=20telemetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/util/posthog.ts | 1 + gui/src/hooks/useChatHandler.ts | 28 +++++++++++----------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/core/util/posthog.ts b/core/util/posthog.ts index 4f83fdee5..6373ec2ce 100644 --- a/core/util/posthog.ts +++ b/core/util/posthog.ts @@ -16,6 +16,7 @@ export class Telemetry { } static async setup(allow: boolean, uniqueId: string) { + Telemetry.uniqueId = uniqueId; if (!allow) { Telemetry.client = undefined; } else { diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index acdf262e0..438004cf8 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -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); @@ -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; @@ -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) { @@ -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; @@ -117,7 +117,7 @@ function useChatHandler(dispatch: Dispatch) { historyIndex, selectedCode, }, - cancelToken + cancelToken, )) { if (!activeRef.current) { abortController.abort(); @@ -161,7 +161,7 @@ function useChatHandler(dispatch: Dispatch) { message, index: historyIndex, contextItems, - }) + }), ); // TODO: hacky way to allow rerender @@ -169,13 +169,9 @@ function useChatHandler(dispatch: Dispatch) { 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); @@ -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) {