Skip to content

Commit a651ab2

Browse files
nullvariantclaude
andauthored
fix(git-id-switcher): add User-Agent to Webview fetch (#306)
Node.js fetch in the extension host doesn't include VSCode's User-Agent (Code/x.y.z), causing Cloudflare analytics worker to classify documentation access as OTHER/is_likely_human=0. Now sends Code/${vscode.version} to match existing classifyTraffic detection rules. 🖥️ IDE: [Cursor](https://cursor.sh) 🔌 Extension: [Claude Code](https://claude.ai/download) Model-Raw: claude-opus-4-6 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 26cee48 commit a651ab2

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

extensions/git-id-switcher/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.16.18] - 2026-02-13
11+
12+
### Fixed
13+
14+
- **Add User-Agent header to Webview documentation fetch requests**: Node.js fetch in the extension host doesn't include VSCode's User-Agent (`Code/x.y.z`), causing Cloudflare analytics worker to classify documentation access as `OTHER/is_likely_human=0`. Now sends `Code/${vscode.version} git-id-switcher` to match existing `classifyTraffic` detection rules.
15+
1016
## [0.16.17] - 2026-02-07
1117

1218
### Documentation

extensions/git-id-switcher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "git-id-switcher",
33
"displayName": "%extension.displayName%",
44
"description": "%extension.description%",
5-
"version": "0.16.17",
5+
"version": "0.16.18",
66
"publisher": "nullvariant",
77
"icon": "images/icon.png",
88
"engines": {

extensions/git-id-switcher/src/ui/documentationInternal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const DOCUMENT_HASHES: Record<string, string> = {
2525
'AGENTS.md': 'cb8170851742743e584cf21ff3427c78dc1c9471fd56d25a19abc174ed4fdd61',
2626
'CODE_OF_CONDUCT.md': 'a5eb286c902437bbe0f6d409894f20e51c172fa869fe2f151bfa388f9d911b54',
2727
'CONTRIBUTING.md': '4150f8810aec7b2e8eff9f3c69ee1bae1374843f50a812efa6778cba27a833cd',
28-
'extensions/git-id-switcher/CHANGELOG.md': 'c67ad4a778f2be5f7f3984a2c94d07014a9f4660322fd03fa621448c3eadc29d',
28+
'extensions/git-id-switcher/CHANGELOG.md': '0eec5a04436e23fa644aa7694f6410cebf6d1c4af26300bf4dab0d4cec8d15eb',
2929
'extensions/git-id-switcher/docs/ARCHITECTURE.md': 'a12dd717f83b28b648972a826701a29fcfd575e351c487f8c421402f80ac3d25',
3030
'extensions/git-id-switcher/docs/CONTRIBUTING.md': '7d6ad2bc4d8c838790754cb9df848cb65f9fdce7e1a13e5c965b83a3d5b6378c',
3131
'extensions/git-id-switcher/docs/DESIGN_PHILOSOPHY.md': 'f9718b61ac161cb466dbc76845688e7acacf4e5fdc4b8b9553269dba4a094f6b',

extensions/git-id-switcher/src/ui/documentationPublic.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,13 @@ async function fetchDocumentByPath(path: string): Promise<string | null> {
9191
try {
9292
const url = `${ASSET_BASE_URL}/${path}`;
9393

94-
// Add header for CI/test environment access (for analytics filtering)
95-
const headers: Record<string, string> = {};
94+
// Add headers for analytics classification and CI/test filtering
95+
// Node.js fetch doesn't include VSCode's User-Agent (Code/x.y.z),
96+
// so analytics worker classifies requests as OTHER/is_likely_human=0.
97+
// Setting User-Agent with "Code/" prefix matches existing classifyTraffic detection.
98+
const headers: Record<string, string> = {
99+
'User-Agent': `Code/${vscode.version} git-id-switcher`,
100+
};
96101
if (isTestEnvironment()) {
97102
headers['X-Test-Environment'] = 'true';
98103
}

0 commit comments

Comments
 (0)