@@ -82,7 +82,7 @@ describe('telemetry', () => {
8282 } ,
8383 ] ,
8484 true ,
85- [ { name : 'someTool ' , args : { } } ] ,
85+ [ { name : 'replace ' , args : { } } ] ,
8686 ) ;
8787 const traceId = 'test-trace-id' ;
8888 const streamingLatency : StreamingLatency = { totalLatency : '1s' } ;
@@ -130,7 +130,7 @@ describe('telemetry', () => {
130130
131131 it ( 'should set status to CANCELLED if signal is aborted' , ( ) => {
132132 const response = createMockResponse ( [ ] , true , [
133- { name : 'tool ' , args : { } } ,
133+ { name : 'replace ' , args : { } } ,
134134 ] ) ;
135135 const signal = new AbortController ( ) . signal ;
136136 vi . spyOn ( signal , 'aborted' , 'get' ) . mockReturnValue ( true ) ;
@@ -147,7 +147,7 @@ describe('telemetry', () => {
147147
148148 it ( 'should set status to ERROR_UNKNOWN if response has error (non-OK SDK response)' , ( ) => {
149149 const response = createMockResponse ( [ ] , false , [
150- { name : 'tool ' , args : { } } ,
150+ { name : 'replace ' , args : { } } ,
151151 ] ) ;
152152
153153 const result = createConversationOffered (
@@ -169,7 +169,7 @@ describe('telemetry', () => {
169169 } ,
170170 ] ,
171171 true ,
172- [ { name : 'tool ' , args : { } } ] ,
172+ [ { name : 'replace ' , args : { } } ] ,
173173 ) ;
174174
175175 const result = createConversationOffered (
@@ -186,7 +186,7 @@ describe('telemetry', () => {
186186 // We force functionCalls to be present to bypass the guard,
187187 // simulating a state where we want to test the candidates check.
188188 const response = createMockResponse ( [ ] , true , [
189- { name : 'tool ' , args : { } } ,
189+ { name : 'replace ' , args : { } } ,
190190 ] ) ;
191191
192192 const result = createConversationOffered (
@@ -212,7 +212,7 @@ describe('telemetry', () => {
212212 } ,
213213 ] ,
214214 true ,
215- [ { name : 'tool ' , args : { } } ] ,
215+ [ { name : 'replace ' , args : { } } ] ,
216216 ) ;
217217 const result = createConversationOffered ( response , 'id' , undefined , { } ) ;
218218 expect ( result ?. includedCode ) . toBe ( true ) ;
@@ -229,7 +229,7 @@ describe('telemetry', () => {
229229 } ,
230230 ] ,
231231 true ,
232- [ { name : 'tool ' , args : { } } ] ,
232+ [ { name : 'replace ' , args : { } } ] ,
233233 ) ;
234234 const result = createConversationOffered ( response , 'id' , undefined , { } ) ;
235235 expect ( result ?. includedCode ) . toBe ( false ) ;
@@ -250,7 +250,7 @@ describe('telemetry', () => {
250250 } as unknown as CodeAssistServer ;
251251
252252 const response = createMockResponse ( [ ] , true , [
253- { name : 'tool ' , args : { } } ,
253+ { name : 'replace ' , args : { } } ,
254254 ] ) ;
255255 const streamingLatency = { } ;
256256
@@ -274,7 +274,7 @@ describe('telemetry', () => {
274274 recordConversationOffered : vi . fn ( ) ,
275275 } as unknown as CodeAssistServer ;
276276 const response = createMockResponse ( [ ] , true , [
277- { name : 'tool ' , args : { } } ,
277+ { name : 'replace ' , args : { } } ,
278278 ] ) ;
279279
280280 await recordConversationOffered (
@@ -331,17 +331,89 @@ describe('telemetry', () => {
331331
332332 await recordToolCallInteractions ( { } as Config , toolCalls ) ;
333333
334- expect ( mockServer . recordConversationInteraction ) . toHaveBeenCalledWith ( {
335- traceId : 'trace-1' ,
336- status : ActionStatus . ACTION_STATUS_NO_ERROR ,
337- interaction : ConversationInteractionInteraction . ACCEPT_FILE ,
338- acceptedLines : '5' ,
339- removedLines : '3' ,
340- isAgentic : true ,
341- } ) ;
334+ expect ( mockServer . recordConversationInteraction ) . toHaveBeenCalledWith (
335+ expect . objectContaining ( {
336+ traceId : 'trace-1' ,
337+ status : ActionStatus . ACTION_STATUS_NO_ERROR ,
338+ interaction : ConversationInteractionInteraction . ACCEPT_FILE ,
339+ acceptedLines : '8' ,
340+ removedLines : '3' ,
341+ isAgentic : true ,
342+ } ) ,
343+ ) ;
342344 } ) ;
343345
344- it ( 'should record UNKNOWN interaction for other accepted tools' , async ( ) => {
346+ it ( 'should include language in interaction if file_path is present' , async ( ) => {
347+ const toolCalls : CompletedToolCall [ ] = [
348+ {
349+ request : {
350+ name : 'replace' ,
351+ args : {
352+ file_path : 'test.ts' ,
353+ old_string : 'old' ,
354+ new_string : 'new' ,
355+ } ,
356+ callId : 'call-1' ,
357+ isClientInitiated : false ,
358+ prompt_id : 'p1' ,
359+ traceId : 'trace-1' ,
360+ } ,
361+ response : {
362+ resultDisplay : {
363+ diffStat : {
364+ model_added_lines : 5 ,
365+ model_removed_lines : 3 ,
366+ } ,
367+ } ,
368+ } ,
369+ outcome : ToolConfirmationOutcome . ProceedOnce ,
370+ status : 'success' ,
371+ } as unknown as CompletedToolCall ,
372+ ] ;
373+
374+ await recordToolCallInteractions ( { } as Config , toolCalls ) ;
375+
376+ expect ( mockServer . recordConversationInteraction ) . toHaveBeenCalledWith (
377+ expect . objectContaining ( {
378+ language : 'TypeScript' ,
379+ } ) ,
380+ ) ;
381+ } ) ;
382+
383+ it ( 'should include language in interaction if write_file is used' , async ( ) => {
384+ const toolCalls : CompletedToolCall [ ] = [
385+ {
386+ request : {
387+ name : 'write_file' ,
388+ args : { file_path : 'test.py' , content : 'test' } ,
389+ callId : 'call-1' ,
390+ isClientInitiated : false ,
391+ prompt_id : 'p1' ,
392+ traceId : 'trace-1' ,
393+ } ,
394+ response : {
395+ resultDisplay : {
396+ diffStat : {
397+ model_added_lines : 5 ,
398+ model_removed_lines : 3 ,
399+ } ,
400+ } ,
401+ } ,
402+ outcome : ToolConfirmationOutcome . ProceedOnce ,
403+ status : 'success' ,
404+ } as unknown as CompletedToolCall ,
405+ ] ;
406+
407+ await recordToolCallInteractions ( { } as Config , toolCalls ) ;
408+
409+ expect ( mockServer . recordConversationInteraction ) . toHaveBeenCalledWith (
410+ expect . objectContaining ( {
411+ language : 'Python' ,
412+ } ) ,
413+ ) ;
414+ } ) ;
415+
416+ it ( 'should not record interaction for other accepted tools' , async ( ) => {
345417 const toolCalls : CompletedToolCall [ ] = [
346418 {
347419 request : {
@@ -359,19 +431,14 @@ describe('telemetry', () => {
359431
360432 await recordToolCallInteractions ( { } as Config , toolCalls ) ;
361433
362- expect ( mockServer . recordConversationInteraction ) . toHaveBeenCalledWith ( {
363- traceId : 'trace-2' ,
364- status : ActionStatus . ACTION_STATUS_NO_ERROR ,
365- interaction : ConversationInteractionInteraction . UNKNOWN ,
366- isAgentic : true ,
367- } ) ;
434+ expect ( mockServer . recordConversationInteraction ) . not . toHaveBeenCalled ( ) ;
368435 } ) ;
369436
370437 it ( 'should not record interaction for cancelled status' , async ( ) => {
371438 const toolCalls : CompletedToolCall [ ] = [
372439 {
373440 request : {
374- name : 'tool ' ,
441+ name : 'replace ' ,
375442 args : { } ,
376443 callId : 'call-3' ,
377444 isClientInitiated : false ,
@@ -394,7 +461,7 @@ describe('telemetry', () => {
394461 const toolCalls : CompletedToolCall [ ] = [
395462 {
396463 request : {
397- name : 'tool ' ,
464+ name : 'replace ' ,
398465 args : { } ,
399466 callId : 'call-4' ,
400467 isClientInitiated : false ,
0 commit comments