Skip to content

Commit 9f14b08

Browse files
committed
1 parent 1cdf61d commit 9f14b08

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions
3636
import { ExtHostContext, ExtHostLanguageFeaturesShape, HoverWithId, ICallHierarchyItemDto, ICodeActionDto, ICodeActionProviderMetadataDto, IdentifiableInlineCompletion, IdentifiableInlineCompletions, IDocumentDropEditDto, IDocumentDropEditProviderMetadata, IDocumentFilterDto, IIndentationRuleDto, IInlayHintDto, ILanguageConfigurationDto, ILanguageWordDefinitionDto, ILinkDto, ILocationDto, ILocationLinkDto, IOnEnterRuleDto, IPasteEditDto, IPasteEditProviderMetadataDto, IRegExpDto, ISignatureHelpProviderMetadataDto, ISuggestDataDto, ISuggestDataDtoField, ISuggestResultDtoField, ITypeHierarchyItemDto, IWorkspaceSymbolDto, MainContext, MainThreadLanguageFeaturesShape } from '../common/extHost.protocol.js';
3737
import { InlineCompletionEndOfLifeReasonKind } from '../common/extHostTypes.js';
3838
import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';
39-
import { DataChannelForwardingTelemetryService } from '../../contrib/editTelemetry/browser/telemetry/forwardingTelemetryService.js';
39+
import { DataChannelForwardingTelemetryService, forwardToChannelIf, isCopilotLikeExtension } from '../../contrib/editTelemetry/browser/telemetry/forwardingTelemetryService.js';
4040

4141
@extHostNamedCustomer(MainContext.MainThreadLanguageFeatures)
4242
export class MainThreadLanguageFeatures extends Disposable implements MainThreadLanguageFeaturesShape {
@@ -684,7 +684,8 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
684684
superseded: reason.kind === InlineCompletionEndOfLifeReasonKind.Ignored && !!reason.supersededBy,
685685
reason: reason.kind === InlineCompletionEndOfLifeReasonKind.Accepted ? 'accepted'
686686
: reason.kind === InlineCompletionEndOfLifeReasonKind.Rejected ? 'rejected'
687-
: 'ignored'
687+
: 'ignored',
688+
...forwardToChannelIf(isCopilotLikeExtension(extensionId)),
688689
};
689690

690691
const telemetryService = this._instantiationService.createInstance(DataChannelForwardingTelemetryService);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { IDocumentWithAnnotatedEdits, EditSourceData, createDocWithJustReason }
1818
import type { ScmRepoBridge } from './editSourceTrackingImpl.js';
1919
import { ITextModelEditSourceMetadata } from '../../../../../editor/common/textModelEditSource.js';
2020
import { generateUuid } from '../../../../../base/common/uuid.js';
21+
import { forwardToChannelIf, isCopilotLikeExtension } from './forwardingTelemetryService.js';
2122

2223
export class InlineEditArcTelemetrySender extends Disposable {
2324
constructor(
@@ -87,6 +88,8 @@ export class InlineEditArcTelemetrySender extends Disposable {
8788
currentLineCount: res.currentLineCount,
8889
originalDeletedLineCount: res.originalDeletedLineCount,
8990
currentDeletedLineCount: res.currentDeletedLineCount,
91+
92+
...forwardToChannelIf(isCopilotLikeExtension(data.$extensionId)),
9093
});
9194
});
9295

@@ -193,6 +196,8 @@ export class ChatArcTelemetrySender extends Disposable {
193196
originalLineCount: res.originalLineCount,
194197
currentLineCount: res.currentLineCount,
195198
originalDeletedLineCount: res.originalDeletedLineCount,
199+
200+
...forwardToChannelIf(isCopilotLikeExtension(data.props.$extensionId)),
196201
});
197202
});
198203

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,31 @@ export class DataChannelForwardingTelemetryService extends InterceptingTelemetry
8383
@IDataChannelService dataChannelService: IDataChannelService,
8484
) {
8585
super(telemetryService, (eventName, data) => {
86-
dataChannelService.getDataChannel<IEditTelemetryData>('editTelemetry').sendData({ eventName, data: data as any });
86+
// filter for extension
87+
let forward = true;
88+
if (data && shouldForwardToChannel in data) {
89+
forward = Boolean(data[shouldForwardToChannel]);
90+
}
91+
92+
if (forward) {
93+
dataChannelService.getDataChannel<IEditTelemetryData>('editTelemetry').sendData({ eventName, data: data as any });
94+
}
8795
});
8896
}
8997
}
98+
99+
const shouldForwardToChannel = Symbol('shouldForwardToChannel');
100+
export function forwardToChannelIf(value: boolean): Record<string, unknown> {
101+
return {
102+
// This will not be sent via telemetry, it is just a marker
103+
[shouldForwardToChannel]: value
104+
};
105+
}
106+
107+
export function isCopilotLikeExtension(extensionId: string | undefined): boolean {
108+
if (!extensionId) {
109+
return false;
110+
}
111+
const extIdLowerCase = extensionId.toLowerCase();
112+
return extIdLowerCase === 'github.copilot' || extIdLowerCase === 'github.copilot-chat';
113+
}

0 commit comments

Comments
 (0)