test: telemetry
This commit is contained in:
parent
7dd0a03ffe
commit
da98dd3d9c
3 changed files with 34 additions and 10 deletions
|
|
@ -33,8 +33,13 @@ export const callToolById = createAsyncThunk<
|
|||
|
||||
// Track tool call acceptance and start timing
|
||||
const startTime = Date.now();
|
||||
|
||||
// Check if this is an auto-approved tool
|
||||
const toolSettings = state.ui.toolSettings;
|
||||
const isAutoApproved = toolSettings[toolCallState.toolCall.function.name] === "allowedWithoutPermission";
|
||||
|
||||
posthog.capture("gui_tool_call_decision", {
|
||||
decision: "accept",
|
||||
decision: isAutoApproved ? "auto_accept" : "accept",
|
||||
toolName: toolCallState.toolCall.function.name,
|
||||
toolCallId: toolCallId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -69,15 +69,6 @@ async function handleToolCallExecution(
|
|||
|
||||
// Only run if we have auto-approve for all
|
||||
if (allAutoApproved && toolCallStates.length > 0) {
|
||||
// Track auto-approved tool execution
|
||||
toolCallStates.forEach((toolCallState) => {
|
||||
posthog.capture("gui_tool_call_decision", {
|
||||
decision: "auto_accept",
|
||||
toolName: toolCallState.toolCall.function.name,
|
||||
toolCallId: toolCallState.toolCallId,
|
||||
});
|
||||
});
|
||||
|
||||
const toolCallPromises = toolCallStates.map(async (toolCallState) => {
|
||||
const response = await dispatch(
|
||||
callToolById({ toolCallId: toolCallState.toolCallId }),
|
||||
|
|
|
|||
|
|
@ -556,6 +556,20 @@ describe("streamResponseThunk - tool calls", () => {
|
|||
|
||||
expect(result.type).toBe("chat/streamResponse/fulfilled");
|
||||
|
||||
// Verify telemetry events for auto-approved tool execution
|
||||
expect(mockPosthog.capture).toHaveBeenCalledWith("gui_tool_call_decision", {
|
||||
decision: "auto_accept",
|
||||
toolName: "search_codebase",
|
||||
toolCallId: "tool-call-1",
|
||||
});
|
||||
|
||||
expect(mockPosthog.capture).toHaveBeenCalledWith("gui_tool_call_outcome", {
|
||||
succeeded: true,
|
||||
toolName: "search_codebase",
|
||||
errorMessage: undefined,
|
||||
duration_ms: expect.any(Number),
|
||||
});
|
||||
|
||||
// Verify final state after tool call execution
|
||||
const finalState = mockStoreWithToolSettings.getState();
|
||||
expect(finalState).toEqual({
|
||||
|
|
@ -2722,6 +2736,20 @@ describe("streamResponseThunk - tool calls", () => {
|
|||
},
|
||||
]);
|
||||
|
||||
// Verify telemetry events for manual approval flow
|
||||
expect(mockPosthog.capture).toHaveBeenCalledWith("gui_tool_call_decision", {
|
||||
decision: "accept",
|
||||
toolName: "search_codebase",
|
||||
toolCallId: "tool-approval-flow-1",
|
||||
});
|
||||
|
||||
expect(mockPosthog.capture).toHaveBeenCalledWith("gui_tool_call_outcome", {
|
||||
succeeded: true,
|
||||
toolName: "search_codebase",
|
||||
errorMessage: undefined,
|
||||
duration_ms: expect.any(Number),
|
||||
});
|
||||
|
||||
// Verify IDE messenger calls for tool execution
|
||||
expect(mockIdeMessengerApproval.request).toHaveBeenCalledWith(
|
||||
"tools/call",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue