vlogs_sdk_ts/src/util.ts

35 lines
700 B
TypeScript
Raw Normal View History

2023-05-27 11:16:06 +07:00
import { v4 as uuidv4 } from 'uuid';
export const getSystemHostname = () => {
let name = 'localhost';
if (typeof window !== 'undefined') {
name = window.location.hostname;
}
// @ts-ignore
if (typeof process !== 'undefined') {
// @ts-ignore
name = process.env.HOSTNAME;
}
return name;
}
export const getSystemUsername = () => {
let name = 'unknown';
if (typeof window !== 'undefined') {
name = window.navigator.userAgent;
}
// @ts-ignore
if (typeof process !== 'undefined') {
// @ts-ignore
name = process.env.USER;
}
return name;
}
export const generateUUID = () => {
return uuidv4();
}