Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ability to recognize extensions which access environment API #20791

Merged
merged 2 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions src/client/proposedApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,16 @@ export function buildProposedApi(
const extensions = serviceContainer.get<IExtensions>(IExtensions);
const envVarsProvider = serviceContainer.get<IEnvironmentVariablesProvider>(IEnvironmentVariablesProvider);
function sendApiTelemetry(apiName: string, args?: unknown) {
setTimeout(() =>
extensions
.determineExtensionFromCallStack()
.then((info) => {
sendTelemetryEvent(EventName.PYTHON_ENVIRONMENTS_API, undefined, {
apiName,
extensionId: info.extensionId,
});
traceVerbose(
`Extension ${info.extensionId} accessed ${apiName} with args: ${JSON.stringify(args)}`,
);
})
.ignoreErrors(),
);
extensions
.determineExtensionFromCallStack()
.then((info) => {
sendTelemetryEvent(EventName.PYTHON_ENVIRONMENTS_API, undefined, {
apiName,
extensionId: info.extensionId,
});
traceVerbose(`Extension ${info.extensionId} accessed ${apiName} with args: ${JSON.stringify(args)}`);
})
.ignoreErrors();
}
disposables.push(
discoveryApi.onChanged((e) => {
Expand Down
2 changes: 2 additions & 0 deletions src/test/proposedApi.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ suite('Proposed Extension API', () => {
});

teardown(() => {
// Verify each API method sends telemetry regarding who called the API.
extensions.verifyAll();
sinon.restore();
});

Expand Down