@@ -7,6 +7,7 @@ import * as vscode from 'vscode';
77import { MergeConflictParser } from './mergeConflictParser' ;
88import * as interfaces from './interfaces' ;
99import { Delayer } from './delayer' ;
10+ import TelemetryReporter from '@vscode/extension-telemetry' ;
1011
1112class ScanTask {
1213 public origins : Set < string > = new Set < string > ( ) ;
@@ -47,6 +48,8 @@ export default class DocumentMergeConflictTracker implements vscode.Disposable,
4748 private cache : Map < string , ScanTask > = new Map ( ) ;
4849 private delayExpireTime : number = 0 ;
4950
51+ constructor ( private readonly telemetryReporter : TelemetryReporter ) { }
52+
5053 getConflicts ( document : vscode . TextDocument , origin : string ) : PromiseLike < interfaces . IDocumentMergeConflict [ ] > {
5154 // Attempt from cache
5255
@@ -109,14 +112,35 @@ export default class DocumentMergeConflictTracker implements vscode.Disposable,
109112 this . cache . clear ( ) ;
110113 }
111114
115+ private readonly seenDocumentsWithConflicts = new Set < string > ( ) ;
116+
112117 private getConflictsOrEmpty ( document : vscode . TextDocument , _origins : string [ ] ) : interfaces . IDocumentMergeConflict [ ] {
113118 const containsConflict = MergeConflictParser . containsConflict ( document ) ;
114119
115120 if ( ! containsConflict ) {
116121 return [ ] ;
117122 }
118123
119- const conflicts = MergeConflictParser . scanDocument ( document ) ;
124+ const conflicts = MergeConflictParser . scanDocument ( document , this . telemetryReporter ) ;
125+
126+ const key = document . uri . toString ( ) ;
127+ // Don't report telemetry for the same document twice. This is an approximation, but good enough.
128+ // Otherwise redo/undo could trigger this event multiple times.
129+ if ( ! this . seenDocumentsWithConflicts . has ( key ) ) {
130+ this . seenDocumentsWithConflicts . add ( key ) ;
131+
132+ /* __GDPR__
133+ "mergeMarkers.documentWithConflictMarkersOpened" : {
134+ "owner": "hediet",
135+ "comment": "Used to determine how many documents with conflicts are opened.",
136+ "conflictCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "comment": "Total number of conflict counts" }
137+ }
138+ */
139+ this . telemetryReporter . sendTelemetryEvent ( 'mergeMarkers.documentWithConflictMarkersOpened' , { } , {
140+ conflictCount : conflicts . length ,
141+ } ) ;
142+ }
143+
120144 return conflicts ;
121145 }
122146
0 commit comments