Skip to content

Commit

Permalink
[Backport M72] refactor(telemetry): opt-out option (#7207)
Browse files Browse the repository at this point in the history
This commit update the ability to disable telemetry for Enterprise-users
only and no longer works for PLG users to ensure we can improve the
product.

- Updated the `cody.telemetry.level` configuration to reflect that
telemetry can only be disabled for Enterprise instances.
- Updated the telemetry provider to disable telemetry if the user is NOT
on sourcegraph.com and has telemetry disabled.

This change ensures that telemetry is only disabled for Enterprise
users, as telemetry is always enabled for sourcegraph.com users.

## Test plan



Makes sure the description for the telemetry level configuration shows
that it is for enterprise only:


![image](https://github.com/user-attachments/assets/0f72a984-0563-4355-8c01-efb02a198df1)

Verify telemetry is not disabled even if `cody.telemetry.level` is set
to off.

 <br> Backport a6f7666 from #7205

Co-authored-by: Beatrix <[email protected]>
  • Loading branch information
sourcegraph-release-bot and abeatrix authored Feb 24, 2025
1 parent facc423 commit 99ff04a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1122,8 +1122,11 @@
"order": 99,
"type": "string",
"enum": ["all", "off"],
"enumDescriptions": ["Sends usage data and errors.", "Disables all extension telemetry."],
"markdownDescription": "Controls the telemetry about Cody usage and errors. See [Cody usage and privacy notice](https://about.sourcegraph.com/terms/cody-notice).",
"enumDescriptions": [
"Sends usage data and errors.",
"[Enterprise-only] Disables all extension telemetry."
],
"markdownDescription": "Controls the telemetry about Cody usage and errors for users connected to Enterprise instances. This setting only takes effect for Sourcegraph Enterprise users. For users connected to sourcegraph.com, this option is always enabled. See [Cody usage and privacy notice](https://about.sourcegraph.com/terms/cody-notice).",
"default": "all"
},
"cody.autocomplete.advanced.provider": {
Expand Down
15 changes: 12 additions & 3 deletions vscode/src/services/telemetry-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
NoOpTelemetryRecorderProvider,
TelemetryRecorderProvider,
clientCapabilities,
isDotCom,
resolvedConfig,
subscriptionDisposable,
telemetryRecorder,
Expand Down Expand Up @@ -35,10 +36,18 @@ export function createOrUpdateTelemetryRecorderProvider(
const defaultNoOpProvider = new NoOpTelemetryRecorderProvider([
new TimestampTelemetryProcessor(),
])

// Telemetry can only be disabled for Non-Sourcegraph.com instances.
if (configuration.telemetryLevel === 'off') {
updateGlobalTelemetryInstances(defaultNoOpProvider)
return
if (auth.serverEndpoint && !isDotCom(auth.serverEndpoint)) {
updateGlobalTelemetryInstances(defaultNoOpProvider)
logDebug('TelemetryRecorderProvider', 'telemetry has been disabled.', {
verbose: `telemetry is disabled for ${auth.serverEndpoint}`,
})
return
}
logDebug('TelemetryRecorderProvider', 'Failed to disable telemetry.', {
verbose: 'telemetry cannot be disabled for sourcegraph.com',
})
}

const initialize = telemetryRecorderProvider === undefined
Expand Down

0 comments on commit 99ff04a

Please sign in to comment.