Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds telemetry to understand how long the diff editor was visible to the user. #181021

Merged
merged 5 commits into from
Apr 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/vs/workbench/browser/parts/editor/textDiffEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
return this.diffEditorControl?.getModifiedEditor();
}

private inputShownTimestampMs: number | undefined;
hediet marked this conversation as resolved.
Show resolved Hide resolved

override async setInput(input: DiffEditorInput, options: ITextEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
this.inputShownTimestampMs = undefined;

// Dispose previous diff navigator
this.diffNavigatorDisposables.clear();
Expand Down Expand Up @@ -149,6 +152,8 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
readOnly: resolvedDiffEditorModel.modifiedModel?.isReadonly(),
originalEditable: !resolvedDiffEditorModel.originalModel?.isReadonly()
});

this.inputShownTimestampMs = Date.now();
} catch (error) {
await this.handleSetInputError(error, input, options);
}
Expand Down Expand Up @@ -297,13 +302,32 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
}

override clearInput(): void {
const editorVisibleTimeMs = this.inputShownTimestampMs !== undefined ? Date.now() - this.inputShownTimestampMs : undefined;
this.inputShownTimestampMs = undefined;
const languageId = this.diffEditorControl?.getModel().modified.getLanguageId();

super.clearInput();

// Dispose previous diff navigator
this.diffNavigatorDisposables.clear();

// Clear Model
this.diffEditorControl?.setModel(null);

if (editorVisibleTimeMs !== undefined) {
this.telemetryService.publicLog2<{
editorVisibleTimeMs: number;
languageId: string;
}, {
owner: 'hediet';
editorVisibleTimeMs: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Indicates the time the diff editor was visible to the user' };
languageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Indicates for which language the diff editor was shown' };
comment: 'This event gives insight about how long the diff editor was visible to the user.';
}>('diffEditor.editorVisibleTime', {
editorVisibleTimeMs,
languageId: languageId ?? '',
});
}
}

getDiffNavigator(): DiffNavigator | undefined {
Expand Down