@@ -17,6 +17,7 @@ import { ITelemetryService } from '../../../platform/telemetry/common/telemetry'
17
17
import { IWorkspaceService } from '../../../platform/workspace/common/workspaceService' ;
18
18
import { getLanguageForResource } from '../../../util/common/languages' ;
19
19
import { removeLeadingFilepathComment } from '../../../util/common/markdown' ;
20
+ import { extname } from '../../../util/vs/base/common/resources' ;
20
21
import { URI } from '../../../util/vs/base/common/uri' ;
21
22
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation' ;
22
23
import { LanguageModelPromptTsxPart , LanguageModelTextPart , LanguageModelToolResult , MarkdownString } from '../../../vscodeTypes' ;
@@ -30,7 +31,6 @@ import { IToolsService } from '../common/toolsService';
30
31
import { ActionType } from './applyPatch/parser' ;
31
32
import { EditFileResult } from './editFileToolResult' ;
32
33
import { createEditConfirmation } from './editFileToolUtils' ;
33
- import { sendEditNotebookTelemetry } from './editNotebookTool' ;
34
34
import { assertFileNotContentExcluded , formatUriForFileWidget , resolveToolInputPath } from './toolUtils' ;
35
35
36
36
export interface ICreateFileParams {
@@ -92,6 +92,9 @@ export class CreateFileTool implements ICopilotTool<ICreateFileParams> {
92
92
}
93
93
94
94
const languageId = doc ?. languageId ?? getLanguageForResource ( uri ) . languageId ;
95
+ const fileExtension = extname ( uri ) ;
96
+ const modelId = options . model && ( await this . endpointProvider . getChatEndpoint ( options . model ) ) . model ;
97
+
95
98
if ( hasSupportedNotebooks ) {
96
99
// Its possible we have a code block with a language id
97
100
// Also possible we have file paths in the content.
@@ -102,11 +105,12 @@ export class CreateFileTool implements ICopilotTool<ICreateFileParams> {
102
105
content = removeLeadingFilepathComment ( options . input . content , languageId , options . input . filePath ) ;
103
106
await processFullRewriteNewNotebook ( uri , content , this . _promptContext . stream , this . alternativeNotebookEditGenerator , { source : NotebookEditGenrationSource . createFile , requestId : options . chatRequestId , model : options . model ? this . endpointProvider . getChatEndpoint ( options . model ) . then ( m => m . model ) : undefined } , token ) ;
104
107
this . _promptContext . stream . notebookEdit ( uri , true ) ;
105
- sendEditNotebookTelemetry ( this . telemetryService , this . endpointProvider , 'createFile' , uri , this . _promptContext . requestId , options . model ?? this . _promptContext . request ?. model ) ;
108
+ this . sendTelemetry ( options . chatRequestId , modelId , fileExtension ) ;
106
109
} else {
107
110
const content = removeLeadingFilepathComment ( options . input . content , languageId , options . input . filePath ) ;
108
111
await processFullRewrite ( uri , doc as TextDocumentSnapshot | undefined , content , this . _promptContext . stream , token , [ ] ) ;
109
112
this . _promptContext . stream . textEdit ( uri , true ) ;
113
+ this . sendTelemetry ( options . chatRequestId , modelId , fileExtension ) ;
110
114
return new LanguageModelToolResult ( [
111
115
new LanguageModelPromptTsxPart (
112
116
await renderPromptElementJSON (
@@ -161,6 +165,22 @@ export class CreateFileTool implements ICopilotTool<ICreateFileParams> {
161
165
pastTenseMessage : new MarkdownString ( l10n . t `Created ${ formatUriForFileWidget ( uri ) } ` )
162
166
} ;
163
167
}
168
+
169
+ private sendTelemetry ( requestId : string | undefined , model : string | undefined , fileExtension : string ) {
170
+ /* __GDPR__
171
+ "createFileToolInvoked" : {
172
+ "owner": "bhavyaus",
173
+ "requestId": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The id of the current request turn." },
174
+ "model": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The model that invoked the tool" },
175
+ "fileExtension": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The file extension of the created file" }
176
+ }
177
+ */
178
+ this . telemetryService . sendMSFTTelemetryEvent ( 'createFileToolInvoked' , {
179
+ requestId,
180
+ model,
181
+ fileExtension
182
+ } ) ;
183
+ }
164
184
}
165
185
166
186
ToolRegistry . registerTool ( CreateFileTool ) ;
0 commit comments