mirror of
https://github.com/upscayl/upscayl.git
synced 2026-04-25 03:00:05 -04:00
Add stats and add posthog systeminfo
This commit is contained in:
@@ -93,6 +93,21 @@ ipcMain.on(ELECTRON_COMMANDS.DOUBLE_UPSCAYL, doubleUpscayl);
|
||||
|
||||
ipcMain.on(ELECTRON_COMMANDS.PASTE_IMAGE, pasteImage);
|
||||
|
||||
ipcMain.handle("get-gpu-info", async () => {
|
||||
try {
|
||||
return await app.getGPUInfo("complete");
|
||||
} catch (error) {
|
||||
console.error("Failed to get GPU info:", error);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("get-app-version", () => {
|
||||
return `${app.getVersion()} ${
|
||||
FEATURE_FLAGS.APP_STORE_BUILD ? "MAC-APP-STORE" : "FOSS"
|
||||
}`;
|
||||
});
|
||||
|
||||
if (!FEATURE_FLAGS.APP_STORE_BUILD) {
|
||||
autoUpdater.on("update-downloaded", autoUpdate);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { ipcRenderer, contextBridge } from "electron";
|
||||
import { getPlatform } from "./utils/get-device-specs";
|
||||
import { ipcRenderer, contextBridge, app } from "electron";
|
||||
import {
|
||||
getAppVersion,
|
||||
getDeviceSpecs,
|
||||
getPlatform,
|
||||
} from "./utils/get-device-specs";
|
||||
import { FEATURE_FLAGS } from "@common/feature-flags";
|
||||
|
||||
// 'ipcRenderer' will be available in index.js with the method 'window.electron'
|
||||
contextBridge.exposeInMainWorld("electron", {
|
||||
@@ -11,4 +16,6 @@ contextBridge.exposeInMainWorld("electron", {
|
||||
invoke: (command: string, payload: any) =>
|
||||
ipcRenderer.invoke(command, payload),
|
||||
platform: getPlatform(),
|
||||
getSystemInfo: async () => await getDeviceSpecs(),
|
||||
getAppVersion: async () => await getAppVersion(),
|
||||
});
|
||||
|
||||
@@ -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] }),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user