Skip to content

Commit 5827187

Browse files
authored
Add Share provider usage telemetry (microsoft#186677)
1 parent 5385ebc commit 5827187

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/vs/workbench/contrib/share/browser/shareService.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ import { ISubmenuItem } from 'vs/platform/actions/common/actions';
1313
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
1414
import { ILabelService } from 'vs/platform/label/common/label';
1515
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
16+
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1617
import { IShareProvider, IShareService, IShareableItem } from 'vs/workbench/contrib/share/common/share';
1718

1819
export const ShareProviderCountContext = new RawContextKey<number>('shareProviderCount', 0, localize('shareProviderCount', "The number of available share providers"));
1920

21+
type ShareEvent = {
22+
providerId: string;
23+
};
24+
type ShareClassification = {
25+
owner: 'joyceerhl'; comment: 'Reporting which share provider is invoked.';
26+
providerId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The id of the selected share provider.' };
27+
};
28+
2029
export class ShareService implements IShareService {
2130
readonly _serviceBrand: undefined;
2231

@@ -28,6 +37,7 @@ export class ShareService implements IShareService {
2837
@ILabelService private readonly labelService: ILabelService,
2938
@IQuickInputService private quickInputService: IQuickInputService,
3039
@ICodeEditorService private readonly codeEditorService: ICodeEditorService,
40+
@ITelemetryService private readonly telemetryService: ITelemetryService,
3141
) {
3242
this.providerCount = ShareProviderCountContext.bindTo(this.contextKeyService);
3343
}
@@ -59,11 +69,18 @@ export class ShareService implements IShareService {
5969
}
6070

6171
if (providers.length === 1) {
72+
this.telemetryService.publicLog2<ShareEvent, ShareClassification>('shareService.share', { providerId: providers[0].id });
6273
return providers[0].provideShare(item, token);
6374
}
6475

6576
const items: (IQuickPickItem & { provider: IShareProvider })[] = providers.map((p) => ({ label: p.label, provider: p }));
6677
const selected = await this.quickInputService.pick(items, { canPickMany: false, placeHolder: localize('type to filter', 'Choose how to share {0}', this.labelService.getUriLabel(item.resourceUri)) }, token);
67-
return selected?.provider.provideShare(item, token);
78+
79+
if (selected !== undefined) {
80+
this.telemetryService.publicLog2<ShareEvent, ShareClassification>('shareService.share', { providerId: selected.provider.id });
81+
return selected.provider.provideShare(item, token);
82+
}
83+
84+
return;
6885
}
6986
}

0 commit comments

Comments
 (0)