signal-desktop/ts/util/getUserAgent.ts

21 lines
706 B
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2020-11-12 23:29:54 +00:00
import { getOwn } from './getOwn';
const PLATFORM_STRINGS: { [platform: string]: string } = {
win32: 'Windows',
darwin: 'macOS',
linux: 'Linux',
};
export function getUserAgent(appVersion: string): string {
2020-11-12 23:29:54 +00:00
// `process.platform` could be missing if someone figures out how to compile Signal on
// an unsupported OS and forgets to update this file. We'd rather send nothing than
// crash.
const platformString = getOwn(PLATFORM_STRINGS, process.platform);
const platformStringWithSpace = platformString ? ` ${platformString}` : '';
return `Signal-Desktop/${appVersion}${platformStringWithSpace}`;
}