Skip to content

Commit 2c8bfe2

Browse files
committed
- Move workspace tips to tips service - Simplify telemetry
1 parent ce57f8a commit 2c8bfe2

7 files changed

Lines changed: 129 additions & 186 deletions

File tree

src/vs/platform/extensionManagement/common/extensionManagement.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,15 @@ export interface IGlobalExtensionEnablementService {
223223
}
224224

225225
export type IExecutableBasedExtensionTip = { extensionId: string } & Omit<Omit<IExeBasedExtensionTip, 'recommendations'>, 'important'>;
226+
export type IWorkspaceTips = { readonly remoteSet: string[]; readonly recommendations: string[]; };
226227

227228
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('IExtensionTipsService');
228229
export interface IExtensionTipsService {
229230
_serviceBrand: undefined;
230231

231232
getImportantExecutableBasedTips(): Promise<IExecutableBasedExtensionTip[]>;
232233
getOtherExecutableBasedTips(): Promise<IExecutableBasedExtensionTip[]>;
234+
getAllWorkspacesTips(): Promise<IWorkspaceTips[]>;
233235
}
234236

235237

src/vs/platform/extensionManagement/common/extensionManagementIpc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export class ExtensionTipsChannel implements IServerChannel {
144144
switch (command) {
145145
case 'getImportantExecutableBasedTips': return this.service.getImportantExecutableBasedTips();
146146
case 'getOtherExecutableBasedTips': return this.service.getOtherExecutableBasedTips();
147+
case 'getAllWorkspacesTips': return this.service.getAllWorkspacesTips();
147148
}
148149

149150
throw new Error('Invalid call');

src/vs/platform/extensionManagement/node/extensionTipsService.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import { INativeEnvironmentService } from 'vs/platform/environment/node/environm
1212
import { IFileService } from 'vs/platform/files/common/files';
1313
import { isWindows } from 'vs/base/common/platform';
1414
import { isNonEmptyArray } from 'vs/base/common/arrays';
15-
import { IExtensionTipsService, IExecutableBasedExtensionTip } from 'vs/platform/extensionManagement/common/extensionManagement';
15+
import { IExtensionTipsService, IExecutableBasedExtensionTip, IWorkspaceTips } from 'vs/platform/extensionManagement/common/extensionManagement';
1616
import { IStringDictionary, forEach } from 'vs/base/common/collections';
17+
import { IRequestService, asJson } from 'vs/platform/request/common/request';
18+
import { CancellationToken } from 'vs/base/common/cancellation';
19+
import { ILogService } from 'vs/platform/log/common/log';
1720

1821
export class ExtensionTipsService implements IExtensionTipsService {
1922

@@ -26,6 +29,8 @@ export class ExtensionTipsService implements IExtensionTipsService {
2629
@IFileService private readonly fileService: IFileService,
2730
@IEnvironmentService private readonly environmentService: IEnvironmentService,
2831
@IProductService private readonly productService: IProductService,
32+
@IRequestService private readonly requestService: IRequestService,
33+
@ILogService private readonly logService: ILogService,
2934
) {
3035
if (this.productService.exeBasedExtensionTips) {
3136
forEach(this.productService.exeBasedExtensionTips, ({ key, value }) => {
@@ -38,6 +43,10 @@ export class ExtensionTipsService implements IExtensionTipsService {
3843
}
3944
}
4045

46+
getAllWorkspacesTips(): Promise<IWorkspaceTips[]> {
47+
return this.fetchWorkspacesTips();
48+
}
49+
4150
getImportantExecutableBasedTips(): Promise<IExecutableBasedExtensionTip[]> {
4251
return this.getValidExecutableBasedExtensionTips(this.allImportantExecutableTips);
4352
}
@@ -90,4 +99,24 @@ export class ExtensionTipsService implements IExtensionTipsService {
9099
return result;
91100
}
92101

102+
private async fetchWorkspacesTips(): Promise<IWorkspaceTips[]> {
103+
if (!this.productService.extensionsGallery?.recommendationsUrl) {
104+
return [];
105+
}
106+
try {
107+
const context = await this.requestService.request({ type: 'GET', url: this.productService.extensionsGallery?.recommendationsUrl }, CancellationToken.None);
108+
if (context.res.statusCode !== 200) {
109+
return [];
110+
}
111+
const result = await asJson<{ workspaceRecommendations?: IWorkspaceTips[] }>(context);
112+
if (!result) {
113+
return [];
114+
}
115+
return result.workspaceRecommendations || [];
116+
} catch (error) {
117+
this.logService.error(error);
118+
return [];
119+
}
120+
}
121+
93122
}

src/vs/workbench/contrib/extensions/browser/extensionRecommendationsService.ts

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ import { setImmediate } from 'vs/base/common/platform';
3939
import { Schemas } from 'vs/base/common/network';
4040
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
4141

42+
export type ExtensionRecommendationsNotificationClassification = {
43+
userReaction: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
44+
extensionId: { classification: 'PublicNonPersonalData', purpose: 'FeatureInsight' };
45+
};
46+
4247
export const milliSecondsInADay = 1000 * 60 * 60 * 24;
4348
export const choiceNever = localize('neverShowAgain', "Don't Show Again");
4449
const searchMarketplace = localize('searchMarketplace', "Search Marketplace");
@@ -635,25 +640,13 @@ export class ExtensionRecommendationsService extends Disposable implements IExte
635640
[{
636641
label: localize('install', 'Install'),
637642
run: () => {
638-
/* __GDPR__
639-
"extensionRecommendations:popup" : {
640-
"userReaction" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
641-
"extensionId": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }
642-
}
643-
*/
644-
this.telemetryService.publicLog('extensionRecommendations:popup', { userReaction: 'install', extensionId: name });
643+
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'install', extensionId: name });
645644
this.instantiationService.createInstance(InstallRecommendedExtensionAction, id).run();
646645
}
647646
}, {
648647
label: localize('showRecommendations', "Show Recommendations"),
649648
run: () => {
650-
/* __GDPR__
651-
"extensionRecommendations:popup" : {
652-
"userReaction" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
653-
"extensionId": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }
654-
}
655-
*/
656-
this.telemetryService.publicLog('extensionRecommendations:popup', { userReaction: 'show', extensionId: name });
649+
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'show', extensionId: name });
657650

658651
const recommendationsAction = this.instantiationService.createInstance(ShowRecommendedExtensionsAction, ShowRecommendedExtensionsAction.ID, localize('showRecommendations', "Show Recommendations"));
659652
recommendationsAction.run();
@@ -664,13 +657,7 @@ export class ExtensionRecommendationsService extends Disposable implements IExte
664657
isSecondary: true,
665658
run: () => {
666659
this.addToImportantRecommendationsIgnore(id);
667-
/* __GDPR__
668-
"extensionRecommendations:popup" : {
669-
"userReaction" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
670-
"extensionId": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }
671-
}
672-
*/
673-
this.telemetryService.publicLog('extensionRecommendations:popup', { userReaction: 'neverShowAgain', extensionId: name });
660+
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'neverShowAgain', extensionId: name });
674661
this.notificationService.prompt(
675662
Severity.Info,
676663
localize('ignoreExtensionRecommendations', "Do you want to ignore all extension recommendations?"),
@@ -687,13 +674,7 @@ export class ExtensionRecommendationsService extends Disposable implements IExte
687674
{
688675
sticky: true,
689676
onCancel: () => {
690-
/* __GDPR__
691-
"extensionRecommendations:popup" : {
692-
"userReaction" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
693-
"extensionId": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }
694-
}
695-
*/
696-
this.telemetryService.publicLog('extensionRecommendations:popup', { userReaction: 'cancelled', extensionId: name });
677+
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'cancelled', extensionId: name });
697678
}
698679
}
699680
);

0 commit comments

Comments
 (0)