@@ -12,11 +12,12 @@ import { URI } from '../../../../base/common/uri.js';
12
12
import { generateUuid } from '../../../../base/common/uuid.js' ;
13
13
import { AnnotatedStringEdit , BaseStringEdit } from '../../../../editor/common/core/edits/stringEdit.js' ;
14
14
import { StringText } from '../../../../editor/common/core/text/abstractText.js' ;
15
+ import { TextModelEditReason } from '../../../../editor/common/textModelEditReason.js' ;
15
16
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js' ;
16
17
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js' ;
17
18
import { ISCMRepository , ISCMService } from '../../scm/common/scm.js' ;
18
19
import { ArcTracker } from './arcTracker.js' ;
19
- import { CombineStreamedChanges , DocumentWithAnnotatedEdits , EditReasonData , EditSource , EditSourceData , IDocumentWithAnnotatedEdits , MinimizeEditsProcessor } from './documentWithAnnotatedEdits.js' ;
20
+ import { CombineStreamedChanges , DocumentWithSourceAnnotatedEdits , EditKeySourceData , EditSource , EditSourceData , IDocumentWithAnnotatedEdits , MinimizeEditsProcessor } from './documentWithAnnotatedEdits.js' ;
20
21
import { DocumentEditSourceTracker , TrackedEdit } from './editTracker.js' ;
21
22
import { ObservableWorkspace , IObservableDocument } from './observableWorkspace.js' ;
22
23
@@ -89,9 +90,9 @@ class TrackedDocumentInfo extends Disposable {
89
90
super ( ) ;
90
91
91
92
// Use the listener service and special events from core to annotate where an edit came from (is async)
92
- let processedDoc : IDocumentWithAnnotatedEdits < EditReasonData > = this . _store . add ( new DocumentWithAnnotatedEdits ( _doc ) ) ;
93
+ let processedDoc : IDocumentWithAnnotatedEdits < EditSourceData > = this . _store . add ( new DocumentWithSourceAnnotatedEdits ( _doc ) ) ;
93
94
// Combine streaming edits into one and make edit smaller
94
- processedDoc = this . _store . add ( this . _instantiationService . createInstance ( ( CombineStreamedChanges < EditReasonData > ) , processedDoc ) ) ;
95
+ processedDoc = this . _store . add ( this . _instantiationService . createInstance ( ( CombineStreamedChanges < EditSourceData > ) , processedDoc ) ) ;
95
96
// Remove common suffix and prefix from edits
96
97
processedDoc = this . _store . add ( new MinimizeEditsProcessor ( processedDoc ) ) ;
97
98
@@ -223,6 +224,10 @@ class TrackedDocumentInfo extends Disposable {
223
224
isTrackedByGit : isTrackedByGit ? 1 : 0 ,
224
225
} ) ;
225
226
227
+ const sourceKeyToRepresentative = new Map < string , TextModelEditReason > ( ) ;
228
+ for ( const r of ranges ) {
229
+ sourceKeyToRepresentative . set ( r . sourceKey , r . sourceRepresentative ) ;
230
+ }
226
231
227
232
const sums = sumByCategory ( ranges , r => r . range . length , r => r . sourceKey ) ;
228
233
const entries = Object . entries ( sums ) . filter ( ( [ key , value ] ) => value !== undefined ) ;
@@ -233,9 +238,21 @@ class TrackedDocumentInfo extends Disposable {
233
238
if ( value === undefined ) {
234
239
continue ;
235
240
}
241
+
242
+
243
+ const repr = sourceKeyToRepresentative . get ( key ) ;
244
+ const cleanedKey = repr ?. toKey ( 1 , { $extensionId : false , $extensionVersion : false } ) ;
245
+
246
+ const metadata = repr ?. metadata ;
247
+ const extensionId = metadata && '$extensionId' in metadata ? metadata . $extensionId : undefined ;
248
+ const extensionVersion = metadata && '$extensionVersion' in metadata ? metadata . $extensionVersion : undefined ;
249
+
236
250
this . _telemetryService . publicLog2 < {
237
251
mode : string ;
238
- reasonKey : string ;
252
+ sourceKey : string ;
253
+ extensionId : string ;
254
+ extensionVersion : string ;
255
+ sourceKeyWithoutExtId : string ;
239
256
languageId : string ;
240
257
statsUuid : string ;
241
258
modifiedCount : number ;
@@ -244,16 +261,22 @@ class TrackedDocumentInfo extends Disposable {
244
261
owner : 'hediet' ;
245
262
comment : 'Reports distribution of various edit kinds.' ;
246
263
247
- reasonKey : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; comment : 'The reason for the edit.' } ;
264
+ sourceKey : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; comment : 'The source of the edit.' } ;
248
265
mode : { classification : 'SystemMetaData' ; purpose : 'PerformanceAndHealth' ; comment : 'longterm or 5minWindow' } ;
249
266
languageId : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; comment : 'The language id of the document.' } ;
250
267
statsUuid : { classification : 'SystemMetaData' ; purpose : 'PerformanceAndHealth' ; comment : 'The unique identifier for the telemetry event.' } ;
268
+ extensionId : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; comment : 'The extension id which provided this inline completion.' } ;
269
+ extensionVersion : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; comment : 'The version of the extension.' } ;
270
+ sourceKeyWithoutExtId : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; comment : 'The source of the edit.' } ;
251
271
252
272
modifiedCount : { classification : 'SystemMetaData' ; purpose : 'PerformanceAndHealth' ; comment : 'Fraction of nes modified characters' ; isMeasurement : true } ;
253
273
totalModifiedCount : { classification : 'SystemMetaData' ; purpose : 'PerformanceAndHealth' ; comment : 'Total number of characters' ; isMeasurement : true } ;
254
274
} > ( 'editTelemetry.editSources.details' , {
255
275
mode,
256
- reasonKey : key ,
276
+ sourceKey : key ,
277
+ extensionId : extensionId ?? '' ,
278
+ extensionVersion : extensionVersion ?? '' ,
279
+ sourceKeyWithoutExtId : cleanedKey ?? '' ,
257
280
languageId : this . _doc . languageId . get ( ) ,
258
281
statsUuid : statsUuid ,
259
282
modifiedCount : value ,
@@ -312,8 +335,8 @@ function mapObservableDelta<T, TDelta, TDeltaNew>(obs: IObservableWithChange<T,
312
335
/**
313
336
* Removing the metadata allows touching edits from the same source to merged, even if they were caused by different actions (e.g. two user edits).
314
337
*/
315
- function createDocWithJustReason ( docWithAnnotatedEdits : IDocumentWithAnnotatedEdits < EditReasonData > , store : DisposableStore ) : IDocumentWithAnnotatedEdits < EditSourceData > {
316
- const docWithJustReason : IDocumentWithAnnotatedEdits < EditSourceData > = {
338
+ function createDocWithJustReason ( docWithAnnotatedEdits : IDocumentWithAnnotatedEdits < EditSourceData > , store : DisposableStore ) : IDocumentWithAnnotatedEdits < EditKeySourceData > {
339
+ const docWithJustReason : IDocumentWithAnnotatedEdits < EditKeySourceData > = {
317
340
value : mapObservableDelta ( docWithAnnotatedEdits . value , edit => ( { edit : edit . edit . mapData ( d => d . data . toEditSourceData ( ) ) } ) , store ) ,
318
341
waitForQueue : ( ) => docWithAnnotatedEdits . waitForQueue ( ) ,
319
342
} ;
@@ -322,7 +345,7 @@ function createDocWithJustReason(docWithAnnotatedEdits: IDocumentWithAnnotatedEd
322
345
323
346
class ArcTelemetrySender extends Disposable {
324
347
constructor (
325
- docWithAnnotatedEdits : IDocumentWithAnnotatedEdits < EditReasonData > ,
348
+ docWithAnnotatedEdits : IDocumentWithAnnotatedEdits < EditSourceData > ,
326
349
scmRepoBridge : ScmRepoBridge | undefined ,
327
350
@IInstantiationService private readonly _instantiationService : IInstantiationService ,
328
351
) {
0 commit comments