Skip to content

Commit d5549f4

Browse files
committed
Add a timeout to waiting for the user to click on telemetry dialog
If user clicks the 'x', then the dialog goes away without its promise ever being resolved. This will prevent the extension from being started. This commit uses `Promise.race` to set a 10s timeout for the dialog to disappear and the extension to start anyway. If this happens, the dialog will appear on next startup and will continue to appear until the user actively clicks 'Yes' or 'No.
1 parent 308b33f commit d5549f4

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

extensions/ql-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
"type": "boolean",
180180
"default": false,
181181
"scope": "application",
182-
"markdownDescription": "Specifies whether to enable Code QL telemetry. This setting AND the global `#telemetry.enableTelemetry#` setting must be checked for telemetry to be sent."
182+
"markdownDescription": "Specifies whether to enable Code QL telemetry. This setting AND the global `#telemetry.enableTelemetry#` setting must be checked for telemetry to be sent. For more information, see [TELEMETRY.md](https://github.com/github/vscode-codeql/blob/93831e28597bb08567db9844737efd9ff188fc3a/.github/TELEMETRY.md)"
183183
},
184184
"codeQL.telemetry.logTelemetry": {
185185
"type": "boolean",

extensions/ql-vscode/src/telemetry.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,15 @@ async function requestTelemetryPermission(ctx: ExtensionContext) {
127127
// if global telemetry is disabled, avoid showing the dialog or making any changes
128128
let result = undefined;
129129
if (workspace.getConfiguration().get<boolean>('telemetry.enableTelemetry')) {
130-
result = await showBinaryChoiceDialog(
131-
'Do we have your permission to collect anonymous usage statistics and sanitized error reports to help us improve CodeQL for VSCode?',
132-
{ modal: false }
133-
);
130+
// Extension won't start until this completes. So, set a timeout here in order
131+
// to ensure the extension continues even if the user doesn't make a choice.
132+
result = await Promise.race([
133+
showBinaryChoiceDialog(
134+
'Do we have your permission to collect anonymous usage statistics help us improve CodeQL for VSCode? See [TELEMETRY.md](https://github.com/github/vscode-codeql/blob/93831e28597bb08567db9844737efd9ff188fc3a/.github/TELEMETRY.md)',
135+
{ modal: false }
136+
),
137+
new Promise(resolve => setTimeout(resolve, 10000))
138+
]) as boolean | undefined;
134139
}
135140
if (result !== undefined) {
136141
await Promise.all([

0 commit comments

Comments
 (0)