Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/externalServices/common/marketplace.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { IHeaders } from '../../../base/parts/request/common/request.js';
7
import { IConfigurationService } from '../../configuration/common/configuration.js';
8
import { IEnvironmentService } from '../../environment/common/environment.js';
9
import { getServiceMachineId } from './serviceMachineId.js';
10
import { IFileService } from '../../files/common/files.js';
11
import { IProductService } from '../../product/common/productService.js';
12
import { IStorageService } from '../../storage/common/storage.js';
13
import { ITelemetryService, TelemetryLevel } from '../../telemetry/common/telemetry.js';
14
import { getTelemetryLevel, supportsTelemetry } from '../../telemetry/common/telemetryUtils.js';
15
16
export async function resolveMarketplaceHeaders(version: string,
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
}
40
41