Skip to content

Commit 4461e54

Browse files
author
Calvinn Ng
committed
add Telemetry in chat sessions
1 parent 6353440 commit 4461e54

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

gui/src/hooks/useChatHandler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import {
3030
streamUpdate,
3131
} from "../redux/slices/stateSlice";
3232
import { RootState } from "../redux/store";
33+
import { Telemetry } from "core/util/logging";
34+
35+
// Log streaming responses, number of sessions, and number of tokens
3336

3437
function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
3538
const posthog = usePostHog();
@@ -224,6 +227,8 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
224227
}),
225228
);
226229

230+
Telemetry.capture("streamChat", newHistory);
231+
227232
// TODO: hacky way to allow rerender
228233
await new Promise((resolve) => setTimeout(resolve, 0));
229234

@@ -232,6 +237,7 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
232237
params: {},
233238
});
234239
posthog.capture("userInput", {});
240+
235241

236242
const messages = constructMessages(newHistory);
237243

@@ -255,7 +261,7 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
255261
);
256262
}
257263
} catch (e) {
258-
console.log("Continue: error streaming response: ", e);
264+
console.log("Ahrefs-Continue: error streaming response: ", e);
259265
ideMessenger.post("errorPopup", {
260266
message: `Error streaming response: ${e.message}`,
261267
});

gui/src/pages/history.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ function History() {
376376
</table>
377377
<br />
378378
<i className="text-sm ml-4">
379-
All session data is saved in ~/.continue/sessions
379+
All session data is saved in ~/.ahrefs-continue/sessions
380380
</i>
381381
</div>
382382
</div>

gui/src/redux/slices/stateSlice.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { stripImages } from "core/llm/countTokens";
1414
import { createSelector } from "reselect";
1515
import { v4 } from "uuid";
1616
import { RootState } from "../store";
17+
import { Telemetry } from "core/util/logging";
1718

1819
export const memoizedContextItemsSelector = createSelector(
1920
[(state: RootState) => state.state.history],
@@ -327,12 +328,14 @@ export const stateSlice = createSlice({
327328
state.history = payload.history;
328329
state.title = payload.title;
329330
state.sessionId = payload.sessionId;
331+
Telemetry.capture("loadSession", payload)
330332
} else {
331333
state.history = [];
332334
state.contextItems = [];
333335
state.active = false;
334336
state.title = "New Session";
335337
state.sessionId = v4();
338+
Telemetry.capture("newSession", {})
336339
}
337340
},
338341
deleteContextWithIds: (

0 commit comments

Comments
 (0)