mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
rename suggestions: include more telemetry
This commit is contained in:
parent
838a59f240
commit
9c05ffbbbd
|
@ -242,7 +242,9 @@ class RenameController implements IEditorContribution {
|
|||
const inputFieldResult = await this._renameInputField.getInput(loc.range, loc.text, selectionStart, selectionEnd, supportPreview, newSymbolNameProvidersResults, renameCandidatesCts);
|
||||
trace('received response from rename input field');
|
||||
|
||||
this._reportTelemetry(inputFieldResult);
|
||||
if (newSymbolNamesProviders.length > 0) { // @ulugbekna: we're interested only in telemetry for rename suggestions currently
|
||||
this._reportTelemetry(newSymbolNamesProviders.length, model.getLanguageId(), inputFieldResult);
|
||||
}
|
||||
|
||||
// no result, only hint to focus the editor or not
|
||||
if (typeof inputFieldResult === 'boolean') {
|
||||
|
@ -330,36 +332,51 @@ class RenameController implements IEditorContribution {
|
|||
this._renameInputField.focusPreviousRenameSuggestion();
|
||||
}
|
||||
|
||||
private _reportTelemetry(inputFieldResult: boolean | RenameInputFieldResult) {
|
||||
private _reportTelemetry(nRenameSuggestionProviders: number, languageId: string, inputFieldResult: boolean | RenameInputFieldResult) {
|
||||
type RenameInvokedEvent =
|
||||
{
|
||||
kind: 'accepted' | 'cancelled';
|
||||
/** provided only if kind = 'accepted' */
|
||||
wantsPreview?: boolean;
|
||||
languageId: string;
|
||||
nRenameSuggestionProviders: number;
|
||||
|
||||
/** provided only if kind = 'accepted' */
|
||||
source?: RenameInputFieldResult['source'];
|
||||
/** provided only if kind = 'accepted' */
|
||||
hadRenameSuggestions?: boolean;
|
||||
nRenameSuggestions?: number;
|
||||
/** provided only if kind = 'accepted' */
|
||||
wantsPreview?: boolean;
|
||||
};
|
||||
|
||||
type RenameInvokedClassification = {
|
||||
owner: 'ulugbekna';
|
||||
comment: 'A rename operation was invoked.';
|
||||
|
||||
kind: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the rename operation was cancelled or accepted.' };
|
||||
wantsPreview?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'If user wanted preview.'; isMeasurement: true };
|
||||
languageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Document language ID.' };
|
||||
nRenameSuggestionProviders: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Number of rename providers for this document.'; isMeasurement: true };
|
||||
|
||||
source?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the new name came from the input field or rename suggestions.' };
|
||||
hadRenameSuggestions?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the user had rename suggestions.'; isMeasurement: true };
|
||||
nRenameSuggestions?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Number of rename suggestions user has got'; isMeasurement: true };
|
||||
wantsPreview?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'If user wanted preview.'; isMeasurement: true };
|
||||
};
|
||||
|
||||
this._telemetryService.publicLog2<RenameInvokedEvent, RenameInvokedClassification>(
|
||||
'renameInvokedEvent',
|
||||
typeof inputFieldResult === 'boolean' ? { kind: 'cancelled' } : {
|
||||
kind: 'accepted',
|
||||
wantsPreview: inputFieldResult.wantsPreview,
|
||||
source: inputFieldResult.source,
|
||||
hadRenameSuggestions: inputFieldResult.hadRenameSuggestions,
|
||||
const value: RenameInvokedEvent = typeof inputFieldResult === 'boolean'
|
||||
? {
|
||||
kind: 'cancelled',
|
||||
languageId,
|
||||
nRenameSuggestionProviders,
|
||||
}
|
||||
);
|
||||
: {
|
||||
kind: 'accepted',
|
||||
languageId,
|
||||
nRenameSuggestionProviders,
|
||||
|
||||
source: inputFieldResult.source,
|
||||
nRenameSuggestions: inputFieldResult.nRenameSuggestions,
|
||||
wantsPreview: inputFieldResult.wantsPreview,
|
||||
};
|
||||
|
||||
this._telemetryService.publicLog2<RenameInvokedEvent, RenameInvokedClassification>('renameInvokedEvent', value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ export interface RenameInputFieldResult {
|
|||
newName: string;
|
||||
wantsPreview?: boolean;
|
||||
source: 'inputField' | 'renameSuggestion';
|
||||
hadRenameSuggestions: boolean;
|
||||
nRenameSuggestions: number;
|
||||
}
|
||||
|
||||
export class RenameInputField implements IContentWidget {
|
||||
|
@ -304,13 +304,14 @@ export class RenameInputField implements IContentWidget {
|
|||
assertType(this._input !== undefined);
|
||||
assertType(this._candidatesView !== undefined);
|
||||
|
||||
const hadRenameSuggestions = this._candidatesView.hasCandidates();
|
||||
const nRenameSuggestions = this._candidatesView.nCandidates;
|
||||
|
||||
let newName: string;
|
||||
let source: 'inputField' | 'renameSuggestion';
|
||||
if (this._candidatesView.focusedCandidate !== undefined) {
|
||||
const focusedCandidate = this._candidatesView.focusedCandidate;
|
||||
if (focusedCandidate !== undefined) {
|
||||
this._trace('using new name from renameSuggestion');
|
||||
newName = this._candidatesView.focusedCandidate;
|
||||
newName = focusedCandidate;
|
||||
source = 'renameSuggestion';
|
||||
} else {
|
||||
this._trace('using new name from inputField');
|
||||
|
@ -331,7 +332,7 @@ export class RenameInputField implements IContentWidget {
|
|||
newName,
|
||||
wantsPreview: supportPreview && wantsPreview,
|
||||
source,
|
||||
hadRenameSuggestions,
|
||||
nRenameSuggestions,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -541,8 +542,8 @@ class CandidatesView {
|
|||
this._listWidget.splice(0, this._listWidget.length, []);
|
||||
}
|
||||
|
||||
public hasCandidates() {
|
||||
return this._listWidget.length > 0;
|
||||
public get nCandidates() {
|
||||
return this._listWidget.length;
|
||||
}
|
||||
|
||||
public get focusedCandidate(): string | undefined {
|
||||
|
|
Loading…
Reference in a new issue