refactor: extract telemetry into separate module with enable/disable toggle#130
Merged
Conversation
…toggle
- Create src/common/telemetry.ts — standalone reportNewPrompt() with
configurable enabled flag
- Add telemetryEnabled to settings types and resolution chain
(DeepcodingSettings, ResolvedDeepcodingSettings, CreateOpenAIClient)
- Resolution priority: system env > project env > project settings >
user env > user settings > default true (opt-out)
- Configurable via settings.json ("telemetryEnabled": false) or env
(DEEPCODE_TELEMETRY_ENABLED=0)
- Reduce session.ts by ~20 lines, delegating to shared module
- src/tests/telemetry.test.ts: 6 tests covering enabled flag, missing machineId, correct fetch params, error swallowing, custom timeout - src/tests/settings-and-notify.test.ts: 3 new tests + extended precedence test verifying telemetryEnabled resolution chain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
src/common/telemetry.ts,将 telemetry 上报逻辑从session.ts中拆分为独立模块telemetryEnabled配置项,支持通过settings.json或环境变量控制匿名使用数据上报的开关(默认true,opt-out)DeepcodingSettings/ResolvedDeepcodingSettings/CreateOpenAIClient类型中补入telemetryEnabled字段truesession.ts中reportNewPrompt()从 20 行内联代码缩减为 3 行委托调用背景
当前 telemetry 上报逻辑硬编码在
session.ts中(URL、超时、请求体),且没有关闭开关。用户无法选择是否参与匿名使用数据上报。本次改动:
telemetryEnabled开关,用户可随时关闭关闭方式
# 环境变量 DEEPCODE_TELEMETRY_ENABLED=0 deepcode文件变更
src/common/telemetry.tsreportNewPrompt()src/settings.tssrc/common/openai-client.tstelemetryEnabledsrc/tools/executor.tsCreateOpenAIClient类型补字段src/session.tsdocs/configuration.mddocs/configuration_en.md验证
npm run check(typecheck + lint + format)✅npm test(366 tests, 0 fail)✅codex review --base origin/main✅ — no discrete regression or correctness issue