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

Using the isTelemetryEnabled provided by VSCode and fixing unit tests #472

Merged
merged 2 commits into from
Dec 6, 2021

Conversation

gracegoo-stripe
Copy link
Contributor

This API also respects the telemetry flag passed in through the CLI when the user starts their code session: https://code.visualstudio.com/updates/v1_55#_telemetry-enablement-api

Regarding the tests, the original tests were not working because it would fail at the line below with an error saying that the update function did not exist.

await vscode.workspace.getConfiguration('telemetry').update('stripe', undefined);

This was because we stubbed out the result returned by getConfiguration and the stubbed result did not have it. However, we don't really need to call update to simulate a config change since we are calling the constructor which calls areAllTelemetryConfigsEnabled anyway.

The reason why the tests did not pass was because we would reach the end of the test case before we reached the exception above. I also updated the tests to wait for all the cases before moving forward.

@@ -9,9 +9,7 @@ const osName = require('os-name');

export const areAllTelemetryConfigsEnabled = () => {
// respect both the overall and Stripe-specific telemetry configs
const enableTelemetry = vscode.workspace
.getConfiguration('telemetry')
.get('enableTelemetry', false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also remove this from package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't exist in our package.json because it's the VSCode-wide telemetry setting. We will still reference stripe.telemetry.enabled which allows users to configure Stripe telemetry separately.

@gracegoo-stripe gracegoo-stripe merged commit 1765787 into master Dec 6, 2021
@gracegoo-stripe gracegoo-stripe deleted the gracegoo-update-telemetry-api branch December 6, 2021 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants