fix(telemetry): report real VS Code platform and honor usage opt-out

The VS Code bridge re-mapped the already-mapped platform value from the
webview, collapsing every install to platform "web"; it also sent the
installId even when usage reporting was disabled. The remote-instance
update poll in the header and the post-update wait poll now send
reportUsage=false so status checks no longer count as activity.
This commit is contained in:
Bohdan Triapitsyn
2026-07-30 19:19:43 +03:00
parent 5328245b63
commit 80d939cccd
3 changed files with 10 additions and 6 deletions
+2 -1
View File
@@ -950,7 +950,8 @@ export const Header: React.FC<HeaderProps> = ({
setRemoteUpdateChecking(true);
setRemoteUpdateError(null);
try {
const params = new URLSearchParams({ appType: 'web', instanceMode: 'remote' });
// Status-only poll: must not count as usage on the remote server's install id.
const params = new URLSearchParams({ appType: 'web', instanceMode: 'remote', reportUsage: 'false' });
const response = await runtimeFetch(`/api/openchamber/update-check?${params.toString()}`, {
method: 'GET',
headers: { Accept: 'application/json' },
@@ -161,7 +161,8 @@ async function waitForUpdateApplied(
): Promise<boolean> {
for (let i = 0; i < maxAttempts; i++) {
try {
const response = await runtimeFetch('/api/openchamber/update-check', {
// Status-only poll while waiting for the update to apply; not a usage report.
const response = await runtimeFetch('/api/openchamber/update-check?reportUsage=false', {
method: 'GET',
headers: { Accept: 'application/json' },
});
+6 -4
View File
@@ -77,10 +77,13 @@ const getOrCreateInstallId = (scope: string): string => {
return installId;
};
const mapNodePlatformToApiPlatform = (value: string): 'macos' | 'windows' | 'linux' | 'web' => {
const mapNodePlatformToApiPlatform = (value: string): 'macos' | 'windows' | 'linux' | 'android' | 'ios' | 'web' => {
// The webview already sends API-shaped values; Node's os.platform() is the fallback source.
if (value === 'macos' || value === 'windows' || value === 'linux' || value === 'android' || value === 'ios' || value === 'web') {
return value;
}
if (value === 'darwin') return 'macos';
if (value === 'win32') return 'windows';
if (value === 'linux') return 'linux';
return 'web';
};
@@ -315,7 +318,6 @@ export async function handleSystemBridgeMessage(
: os.arch();
const reportUsage = body.reportUsage !== false;
const installId = getOrCreateInstallId('vscode');
const requestBody = {
appType: 'vscode',
deviceClass,
@@ -323,7 +325,7 @@ export async function handleSystemBridgeMessage(
arch: mapNodeArchToApiArch(archRaw),
channel: 'stable',
currentVersion,
installId,
...(reportUsage ? { installId: getOrCreateInstallId('vscode') } : {}),
instanceMode,
reportUsage,
};