@sussudio/platform
Version:
Internal APIs for VS Code's service injection the base services.
20 lines (19 loc) • 993 B
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { isMacintosh } from '@sussudio/base/common/platform.mjs';
import { getMachineId } from '@sussudio/base/node/id.mjs';
import { machineIdKey } from '../common/telemetry.mjs';
export async function resolveMachineId(stateService) {
// We cache the machineId for faster lookups
// and resolve it only once initially if not cached or we need to replace the macOS iBridge device
let machineId = stateService.getItem(machineIdKey);
if (
typeof machineId !== 'string' ||
(isMacintosh && machineId === '6c9d2bc8f91b89624add29c0abeae7fb42bf539fa1cdb2e3e57cd668fa9bcead')
) {
machineId = await getMachineId();
}
return machineId;
}