Skip to content

Commit

Permalink
Only log deprecation warning once for each extension (#19901)
Browse files Browse the repository at this point in the history
For #19900
  • Loading branch information
Kartik Raj authored Sep 27, 2022
1 parent a4f08a8 commit a500e16
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/client/deprecatedProposedApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ export function buildDeprecatedProposedApi(
const interpreterPathService = serviceContainer.get<IInterpreterPathService>(IInterpreterPathService);
const interpreterService = serviceContainer.get<IInterpreterService>(IInterpreterService);
const extensions = serviceContainer.get<IExtensions>(IExtensions);
const warningLogged = new Set<string>();
function sendApiTelemetry(apiName: string, warnLog = true) {
if (warnLog) {
console.warn('Extension is using deprecated python APIs which will be removed soon');
}
extensions
.determineExtensionFromCallStack()
.then((info) => {
Expand All @@ -75,6 +73,12 @@ export function buildDeprecatedProposedApi(
extensionId: info.extensionId,
});
traceVerbose(`Extension ${info.extensionId} accessed ${apiName}`);
if (warnLog && !warningLogged.has(info.extensionId)) {
console.warn(
`${info.extensionId} extension is using deprecated python APIs which will be removed soon.`,
);
warningLogged.add(info.extensionId);
}
})
.ignoreErrors();
}
Expand Down

0 comments on commit a500e16

Please sign in to comment.