Add stats and add posthog systeminfo

This commit is contained in:
Nayam Amarshe
2024-12-16 16:18:57 +05:30
parent c9e00de2b0
commit 5a4b29a840
22 changed files with 496 additions and 172 deletions

View File

@@ -1,9 +1,10 @@
"use strict";
import { platform, arch } from "os";
import { ipcRenderer } from "electron";
import os from "os";
export const getPlatform = () => {
switch (platform()) {
switch (os.platform()) {
case "aix":
case "freebsd":
case "linux":
@@ -19,7 +20,7 @@ export const getPlatform = () => {
};
export const getArch = () => {
switch (arch()) {
switch (os.arch()) {
case "x64":
return "x64";
case "x32":
@@ -30,3 +31,33 @@ export const getArch = () => {
return "arm64";
}
};
export const getAppVersion = async () => {
let appVersion = process.env.npm_package_version;
try {
appVersion = await ipcRenderer.invoke("get-app-version");
} catch (error) {
console.error("Failed to get app version:", error);
}
return appVersion;
};
export const getDeviceSpecs = async () => {
let gpuInfo;
try {
gpuInfo = await ipcRenderer.invoke("get-gpu-info");
} catch (error) {
console.error("Failed to get GPU info:", error);
gpuInfo = null;
}
return {
platform: getPlatform(),
release: os.release(),
arch: getArch(),
model: os.cpus()[0].model.trim(),
cpuCount: os.cpus().length,
...(gpuInfo && { gpu: gpuInfo.gpuDevice[0] }),
};
};