Skip to content

Commit f3c6f6b

Browse files
authored
1 parent f8bb386 commit f3c6f6b

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/vs/workbench/contrib/editTelemetry/browser/editSourceTrackingFeature.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ import { IEditorService } from '../../../services/editor/common/editorService.js
2424
import { IStatusbarService, StatusbarAlignment } from '../../../services/statusbar/browser/statusbar.js';
2525
import { EditSource } from './documentWithAnnotatedEdits.js';
2626
import { EditSourceTrackingImpl } from './editSourceTrackingImpl.js';
27-
import { EDIT_TELEMETRY_SHOW_DECORATIONS, EDIT_TELEMETRY_SHOW_STATUS_BAR } from './settings.js';
27+
import { EDIT_TELEMETRY_DETAILS_SETTING_ID, EDIT_TELEMETRY_SHOW_DECORATIONS, EDIT_TELEMETRY_SHOW_STATUS_BAR } from './settings.js';
2828
import { VSCodeWorkspace } from './vscodeObservableWorkspace.js';
2929

3030
export class EditTrackingFeature extends Disposable {
3131

3232
private readonly _editSourceTrackingShowDecorations;
3333
private readonly _editSourceTrackingShowStatusBar;
34+
private readonly _editSourceDetailsEnabled;
3435
private readonly _showStateInMarkdownDoc = 'editTelemetry.showDebugDetails';
3536
private readonly _toggleDecorations = 'editTelemetry.toggleDebugDecorations';
3637

@@ -46,6 +47,7 @@ export class EditTrackingFeature extends Disposable {
4647

4748
this._editSourceTrackingShowDecorations = makeSettable(observableConfigValue(EDIT_TELEMETRY_SHOW_DECORATIONS, false, this._configurationService));
4849
this._editSourceTrackingShowStatusBar = observableConfigValue(EDIT_TELEMETRY_SHOW_STATUS_BAR, false, this._configurationService);
50+
this._editSourceDetailsEnabled = observableConfigValue(EDIT_TELEMETRY_DETAILS_SETTING_ID, false, this._configurationService);
4951

5052
const onDidAddGroupSignal = observableSignalFromEvent(this, this._editorGroupsService.onDidAddGroup);
5153
const onDidRemoveGroupSignal = observableSignalFromEvent(this, this._editorGroupsService.onDidRemoveGroup);
@@ -72,7 +74,7 @@ export class EditTrackingFeature extends Disposable {
7274
const impl = this._register(this._instantiationService.createInstance(EditSourceTrackingImpl, this._workspace, (doc, reader) => {
7375
const map = visibleUris.read(reader);
7476
return map.get(doc.uri.toString()) !== undefined;
75-
}));
77+
}, this._editSourceDetailsEnabled));
7678

7779
this._register(autorun((reader) => {
7880
if (!this._editSourceTrackingShowDecorations.read(reader)) {

src/vs/workbench/contrib/editTelemetry/browser/editSourceTrackingImpl.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,21 @@ export class EditSourceTrackingImpl extends Disposable {
2626
constructor(
2727
private readonly _workspace: ObservableWorkspace,
2828
private readonly _docIsVisible: (doc: IObservableDocument, reader: IReader) => boolean,
29+
private readonly _statsEnabled: IObservable<boolean>,
2930
@IInstantiationService private readonly _instantiationService: IInstantiationService,
3031
) {
3132
super();
3233

3334
const scmBridge = this._instantiationService.createInstance(ScmBridge);
3435

35-
this.docsState = mapObservableArrayCached(this, this._workspace.documents, (doc, store) => {
36+
const states = mapObservableArrayCached(this, this._workspace.documents, (doc, store) => {
3637
const docIsVisible = derived(reader => this._docIsVisible(doc, reader));
3738
const wasEverVisible = derivedObservableWithCache<boolean>(this, (reader, lastVal) => lastVal || docIsVisible.read(reader));
38-
return wasEverVisible.map(v => v ? [doc, store.add(this._instantiationService.createInstance(TrackedDocumentInfo, doc, docIsVisible, scmBridge))] as const : undefined);
39-
}).recomputeInitiallyAndOnChange(this._store).map((entries, reader) => new Map(entries.map(e => e.read(reader)).filter(isDefined)));
39+
return wasEverVisible.map(v => v ? [doc, store.add(this._instantiationService.createInstance(TrackedDocumentInfo, doc, docIsVisible, scmBridge, this._statsEnabled))] as const : undefined);
40+
});
41+
42+
this.docsState = states.map((entries, reader) => new Map(entries.map(e => e.read(reader)).filter(isDefined)))
43+
.recomputeInitiallyAndOnChange(this._store);
4044
}
4145
}
4246

@@ -78,6 +82,7 @@ class TrackedDocumentInfo extends Disposable {
7882
private readonly _doc: IObservableDocument,
7983
docIsVisible: IObservable<boolean>,
8084
private readonly _scm: ScmBridge,
85+
private readonly _statsEnabled: IObservable<boolean>,
8186
@IInstantiationService private readonly _instantiationService: IInstantiationService,
8287
@ITelemetryService private readonly _telemetryService: ITelemetryService
8388
) {
@@ -95,6 +100,7 @@ class TrackedDocumentInfo extends Disposable {
95100
const longtermResetSignal = observableSignal('resetSignal');
96101

97102
this.longtermTracker = derived((reader) => {
103+
if (!this._statsEnabled.read(reader)) { return undefined; }
98104
longtermResetSignal.read(reader);
99105

100106
const t = reader.store.add(new DocumentEditSourceTracker(docWithJustReason, undefined));
@@ -134,6 +140,8 @@ class TrackedDocumentInfo extends Disposable {
134140
const resetSignal = observableSignal('resetSignal');
135141

136142
this.windowedTracker = derived((reader) => {
143+
if (!this._statsEnabled.read(reader)) { return undefined; }
144+
137145
if (!docIsVisible.read(reader)) {
138146
return undefined;
139147
}

src/vs/workbench/contrib/editTelemetry/browser/editTelemetry.contribution.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Registry } from '../../../../platform/registry/common/platform.js';
77
import { EditTelemetryService } from './editTelemetryService.js';
88
import { Extensions as ConfigurationExtensions, IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js';
99
import { localize } from '../../../../nls.js';
10-
import { EDIT_TELEMETRY_SETTING_ID, EDIT_TELEMETRY_SHOW_DECORATIONS, EDIT_TELEMETRY_SHOW_STATUS_BAR } from './settings.js';
10+
import { EDIT_TELEMETRY_DETAILS_SETTING_ID, EDIT_TELEMETRY_SETTING_ID, EDIT_TELEMETRY_SHOW_DECORATIONS, EDIT_TELEMETRY_SHOW_STATUS_BAR } from './settings.js';
1111
import { registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js';
1212

1313
registerWorkbenchContribution2('EditTelemetryService', EditTelemetryService, WorkbenchPhase.AfterRestored);
@@ -25,6 +25,12 @@ configurationRegistry.registerConfiguration({
2525
default: true,
2626
tags: ['experimental'],
2727
},
28+
[EDIT_TELEMETRY_DETAILS_SETTING_ID]: {
29+
markdownDescription: localize('telemetry.editStats.detailed.enabled', "Controls whether to enable telemetry for detailed edit statistics (only sends statistics if general telemetry is enabled)."),
30+
type: 'boolean',
31+
default: false,
32+
tags: ['experimental'],
33+
},
2834
[EDIT_TELEMETRY_SHOW_STATUS_BAR]: {
2935
markdownDescription: localize('telemetry.editStats.showStatusBar', "Controls whether to show the status bar for edit telemetry."),
3036
type: 'boolean',

src/vs/workbench/contrib/editTelemetry/browser/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
export const EDIT_TELEMETRY_SETTING_ID = 'telemetry.editStats.enabled';
7+
export const EDIT_TELEMETRY_DETAILS_SETTING_ID = 'telemetry.editStats.details.enabled';
78
export const EDIT_TELEMETRY_SHOW_DECORATIONS = 'telemetry.editStats.showDecorations';
89
export const EDIT_TELEMETRY_SHOW_STATUS_BAR = 'telemetry.editStats.showStatusBar';

0 commit comments

Comments
 (0)