Skip to content

Commit d3ed199

Browse files
committed
1 parent d436b22 commit d3ed199

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import { AnnotatedDocuments } from '../helpers/annotatedDocuments.js';
2626
import { DataChannelForwardingTelemetryService } from './forwardingTelemetryService.js';
2727
import { EDIT_TELEMETRY_DETAILS_SETTING_ID, EDIT_TELEMETRY_SHOW_DECORATIONS, EDIT_TELEMETRY_SHOW_STATUS_BAR } from '../settings.js';
2828
import { VSCodeWorkspace } from '../helpers/vscodeObservableWorkspace.js';
29+
import { IExtensionService } from '../../../../services/extensions/common/extensions.js';
2930

3031
export class EditTrackingFeature extends Disposable {
3132

3233
private readonly _editSourceTrackingShowDecorations;
3334
private readonly _editSourceTrackingShowStatusBar;
34-
private readonly _editSourceDetailsEnabled;
3535
private readonly _showStateInMarkdownDoc = 'editTelemetry.showDebugDetails';
3636
private readonly _toggleDecorations = 'editTelemetry.toggleDebugDecorations';
3737

@@ -43,19 +43,32 @@ export class EditTrackingFeature extends Disposable {
4343
@IStatusbarService private readonly _statusbarService: IStatusbarService,
4444

4545
@IEditorService private readonly _editorService: IEditorService,
46+
@IExtensionService private readonly _extensionService: IExtensionService,
4647
) {
4748
super();
4849

4950
this._editSourceTrackingShowDecorations = makeSettable(observableConfigValue(EDIT_TELEMETRY_SHOW_DECORATIONS, false, this._configurationService));
5051
this._editSourceTrackingShowStatusBar = observableConfigValue(EDIT_TELEMETRY_SHOW_STATUS_BAR, false, this._configurationService);
51-
this._editSourceDetailsEnabled = observableConfigValue(EDIT_TELEMETRY_DETAILS_SETTING_ID, false, this._configurationService);
52+
const editSourceDetailsEnabled = observableConfigValue(EDIT_TELEMETRY_DETAILS_SETTING_ID, false, this._configurationService);
53+
54+
const extensions = observableFromEvent(this._extensionService.onDidChangeExtensions, () => {
55+
return this._extensionService.extensions;
56+
});
57+
const extensionIds = derived(reader => new Set(extensions.read(reader).map(e => e.id?.toLowerCase())));
58+
function getExtensionInfoObs(extensionId: string, extensionService: IExtensionService) {
59+
const extIdLowerCase = extensionId.toLowerCase();
60+
return derived(reader => extensionIds.read(reader).has(extIdLowerCase));
61+
}
5262

63+
const copilotInstalled = getExtensionInfoObs('GitHub.copilot', this._extensionService);
64+
const copilotChatInstalled = getExtensionInfoObs('GitHub.copilot-chat', this._extensionService);
5365

66+
const shouldSendDetails = derived(reader => editSourceDetailsEnabled.read(reader) || !!copilotInstalled.read(reader) || !!copilotChatInstalled.read(reader));
5467

5568
const instantiationServiceWithInterceptedTelemetry = this._instantiationService.createChild(new ServiceCollection(
5669
[ITelemetryService, this._instantiationService.createInstance(DataChannelForwardingTelemetryService)]
5770
));
58-
const impl = this._register(instantiationServiceWithInterceptedTelemetry.createInstance(EditSourceTrackingImpl, this._editSourceDetailsEnabled, this._annotatedDocuments));
71+
const impl = this._register(instantiationServiceWithInterceptedTelemetry.createInstance(EditSourceTrackingImpl, shouldSendDetails, this._annotatedDocuments));
5972

6073
this._register(autorun((reader) => {
6174
if (!this._editSourceTrackingShowDecorations.read(reader)) {

0 commit comments

Comments
 (0)