-
Notifications
You must be signed in to change notification settings - Fork 226
Respect "telemetry.telemetryLevel" as well as "telemetry.enableTelemetry" #2824
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
Changes from 6 commits
90093fb
9c76ba3
c7bd343
c7a9337
f3e72a0
a506276
af5547f
5fc9a73
9ec6590
d403361
177c770
48399a9
aad1fee
ca96cdf
4227ff6
d499ff3
2b0bd84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import { | |
| LOG_TELEMETRY, | ||
| isIntegrationTestMode, | ||
| isCanary, | ||
| GLOBAL_TELEMETRY_LEVEL, | ||
| } from "../../config"; | ||
| import * as appInsights from "applicationinsights"; | ||
| import { extLogger } from "../logging/vscode"; | ||
|
|
@@ -59,8 +60,6 @@ export class ExtensionTelemetryListener | |
| extends ConfigListener | ||
| implements AppTelemetry | ||
| { | ||
| static relevantSettings = [ENABLE_TELEMETRY, CANARY_FEATURES]; | ||
|
|
||
| private reporter?: TelemetryReporter; | ||
|
|
||
| private cliVersionStr = NOT_SET_CLI_VERSION; | ||
|
|
@@ -92,8 +91,9 @@ export class ExtensionTelemetryListener | |
| e: ConfigurationChangeEvent, | ||
| ): Promise<void> { | ||
| if ( | ||
| e.affectsConfiguration("codeQL.telemetry.enableTelemetry") || | ||
| e.affectsConfiguration("telemetry.enableTelemetry") | ||
| e.affectsConfiguration(ENABLE_TELEMETRY.qualifiedName) || | ||
| e.affectsConfiguration(GLOBAL_ENABLE_TELEMETRY.qualifiedName) || | ||
| e.affectsConfiguration(GLOBAL_TELEMETRY_LEVEL.qualifiedName) | ||
| ) { | ||
| await this.initialize(); | ||
| } | ||
|
|
@@ -102,7 +102,7 @@ export class ExtensionTelemetryListener | |
| // Re-request if codeQL.canary is being set to `true` and telemetry | ||
| // is not currently enabled. | ||
| if ( | ||
| e.affectsConfiguration("codeQL.canary") && | ||
| e.affectsConfiguration(CANARY_FEATURES.qualifiedName) && | ||
| CANARY_FEATURES.getValue() && | ||
| !ENABLE_TELEMETRY.getValue() | ||
| ) { | ||
|
|
@@ -212,7 +212,7 @@ export class ExtensionTelemetryListener | |
| properties.stack = error.stack; | ||
| } | ||
|
|
||
| this.reporter.sendTelemetryEvent("error", properties, {}); | ||
| this.reporter.sendTelemetryErrorEvent("error", properties, {}); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -224,7 +224,7 @@ export class ExtensionTelemetryListener | |
| // if global telemetry is disabled, avoid showing the dialog or making any changes | ||
| let result = undefined; | ||
| if ( | ||
| GLOBAL_ENABLE_TELEMETRY.getValue() && | ||
| isGlobalTelemetryEnabled() && | ||
| // Avoid showing the dialog if we are in integration test mode. | ||
| !isIntegrationTestMode() | ||
| ) { | ||
|
|
@@ -297,3 +297,21 @@ export async function initializeTelemetry( | |
| ctx.subscriptions.push(telemetryListener); | ||
| return telemetryListener; | ||
| } | ||
|
|
||
| function isGlobalTelemetryEnabled(): boolean { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs suggest not trying to implement this logic ourselves and instead using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is complicated enough that it would be nice to use existing logic for it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've done some testing of how
Maybe this is fine for us and the CodeQL extension doesn't need the granularity of only sending error reports and not other telemetry. We certainly aren't losing anything with this PR because we weren't checking the level at all before. Are people happy with this limitation that if |
||
| // If "enableTelemetry" is set to false, no telemetry will be sent regardless of the value of "telemetryLevel" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| const enableTelemetry: boolean | undefined = | ||
| GLOBAL_ENABLE_TELEMETRY.getValue(); | ||
| if (enableTelemetry === false) { | ||
| return false; | ||
| } | ||
|
|
||
| // If a value for "telemetry.telemetryLevel" is provided, then use that | ||
| const telemetryLevel: string | undefined = GLOBAL_TELEMETRY_LEVEL.getValue(); | ||
| if (telemetryLevel !== undefined) { | ||
| return telemetryLevel === "error" || telemetryLevel === "on"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. I was originally reading https://code.visualstudio.com/updates/v1_61#_telemetry-settings but that's a changelog entry and is apparently not outdated. In my local vscode and some other docs I also see what you see. |
||
| } | ||
|
|
||
| // Otherwise fall back to the deprecated "telemetry.enableTelemetry" setting | ||
| return !!enableTelemetry; | ||
| } | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the docs it says
But I couldn't quite work out what this means. I need to hunt down the general docs for these settings to see how to add tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what that means either. Do you have a link for where that's said?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this means that we need to add a
tagsproperty to our telemetry configuration options in thepackage.json. In this documentation for the configuration contribution points, they give this example:{ "contributes": { "configuration": { "title": "Git", "properties": { "git.alwaysSignOff": { "type": "boolean", "scope": "resource", "default": false, "description": "%config.alwaysSignOff%" }, "git.ignoredRepositories": { "type": "array", "default": [], "scope": "window", "description": "%config.ignoredRepositories%" }, "git.autofetch": { "type": ["boolean", "string"], "enum": [true, false, "all"], "scope": "resource", "markdownDescription": "%config.autofetch%", "default": false, "tags": ["usesOnlineServices"] } } } } }The
tagsproperty doesn't seem to be documented on that page though, so I'm not sure what other tags there are.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read it at https://code.visualstudio.com/api/extension-guides/telemetry#dos-and-donts
Thanks for finding that example. It's a shame there isn't more documentation on this but I think there's enough we can add the
tagsfield. I believe it shouldn't cause any harm so we may as well add it.