提交 8d9356ea 编写于 作者: M Martin Aeschlimann

Telemetry when exe recommendation is already installed

上级 c2997da2
......@@ -513,9 +513,26 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
return false;
}
const installed = await this.extensionManagementService.getInstalled(ExtensionType.User);
let recommendationsToSuggest = Object.keys(this._importantExeBasedRecommendations);
recommendationsToSuggest = this.filterAllIgnoredInstalledAndNotAllowed(recommendationsToSuggest, installed);
const installed = await this.extensionManagementService.getInstalled(ExtensionType.User);
recommendationsToSuggest = this.filterInstalled(recommendationsToSuggest, installed, (extensionId) => {
const tip = this._importantExeBasedRecommendations[extensionId];
/* __GDPR__
exeExtensionRecommendations:alreadyInstalled" : {
"extensionId": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
"exeName": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }
}
*/
this.telemetryService.publicLog('exeExtensionRecommendations:alreadyInstalled', { extensionId, exeName: tip.exeFriendlyName || basename(tip.windowsPath!) });
});
if (recommendationsToSuggest.length === 0) {
return false;
}
recommendationsToSuggest = this.filterIgnoredOrNotAllowed(recommendationsToSuggest);
if (recommendationsToSuggest.length === 0) {
return false;
}
......@@ -747,7 +764,12 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
private async promptRecommendedExtensionForFileType(recommendationsToSuggest: string[], installed: ILocalExtension[]): Promise<boolean> {
recommendationsToSuggest = this.filterAllIgnoredInstalledAndNotAllowed(recommendationsToSuggest, installed);
recommendationsToSuggest = this.filterIgnoredOrNotAllowed(recommendationsToSuggest);
if (recommendationsToSuggest.length === 0) {
return false;
}
recommendationsToSuggest = this.filterInstalled(recommendationsToSuggest, installed);
if (recommendationsToSuggest.length === 0) {
return false;
}
......@@ -903,10 +925,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
);
}
private filterAllIgnoredInstalledAndNotAllowed(recommendationsToSuggest: string[], installed: ILocalExtension[]): string[] {
private filterIgnoredOrNotAllowed(recommendationsToSuggest: string[]): string[] {
const importantRecommendationsIgnoreList = <string[]>JSON.parse(this.storageService.get('extensionsAssistant/importantRecommendationsIgnore', StorageScope.GLOBAL, '[]'));
const installedExtensionsIds = installed.reduce((result, i) => { result.add(i.identifier.id.toLowerCase()); return result; }, new Set<string>());
return recommendationsToSuggest.filter(id => {
if (importantRecommendationsIgnoreList.indexOf(id) !== -1) {
return false;
......@@ -914,7 +934,17 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
if (!this.isExtensionAllowedToBeRecommended(id)) {
return false;
}
return true;
});
}
private filterInstalled(recommendationsToSuggest: string[], installed: ILocalExtension[], onAlreadyInstalled?: (id: string) => void): string[] {
const installedExtensionsIds = installed.reduce((result, i) => { result.add(i.identifier.id.toLowerCase()); return result; }, new Set<string>());
return recommendationsToSuggest.filter(id => {
if (installedExtensionsIds.has(id.toLowerCase())) {
if (onAlreadyInstalled) {
onAlreadyInstalled(id);
}
return false;
}
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册