14
import { getTelemetryLevel, supportsTelemetry } from '../../telemetry/common/telemetryUtils.js';
15
16
>
export async function resolveMarketplaceHeaders(version: string,
marketplace.ts
17
>
productService: IProductService,
18
>
environmentService: IEnvironmentService,
19
>
configurationService: IConfigurationService,
20
>
fileService: IFileService,
21
>
storageService: IStorageService | undefined,
22
>
telemetryService: ITelemetryService): Promise<IHeaders> {
23
>
24
>
const headers: IHeaders = {
25
>
'X-Market-Client-Id': `VSCode ${version}`,
26
>
'User-Agent': `VSCode ${version} (${productService.nameShort})`
27
>
};
28
>
29
>
if (supportsTelemetry(productService, environmentService) && getTelemetryLevel(configurationService) === TelemetryLevel.USAGE) {
30
>
const serviceMachineId = await getServiceMachineId(environmentService, fileService, storageService);
31
>
headers['X-Market-User-Id'] = serviceMachineId;
32
>
// Send machineId as VSCode-SessionId so we can correlate telemetry events across different services
33
>
// machineId can be undefined sometimes (eg: when launching from CLI), so send serviceMachineId instead otherwise
34
>
// Marketplace will reject the request if there is no VSCode-SessionId header
35
>
headers['VSCode-SessionId'] = telemetryService.machineId || serviceMachineId;
36
>
}
37
>
38
>
return headers;
39
>
}