Skip to content

Commit

Permalink
Update analytics and system info
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Feb 3, 2024
1 parent 316437f commit 17a3957
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 27 deletions.
30 changes: 20 additions & 10 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.5.0", features = ["api-all", "system-tray", "updater"] }
auto-launch = "0.3.0"
sysinfo = "0.28.4"
sysinfo = "0.30.5"
argon2 = "0.4"
rand_core = { version = "0.6", features = ["std"] }
magic-crypt = "3.1.10"
keyring = "1.2.0"
once_cell = "1.15.0"
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace" }
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
rand = "0.8.5"
google_authenticator_converter = { path = "crates/google_authenticator_converter" }

Expand Down
17 changes: 14 additions & 3 deletions core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rand::{thread_rng, Rng};
use serde::{Deserialize, Serialize};
use std::io::Write;
use std::{env, fs};
use sysinfo::{CpuExt, System, SystemExt};
use sysinfo::System;
use tauri::{GlobalShortcutManager, Manager};

#[tauri::command]
Expand Down Expand Up @@ -85,10 +85,21 @@ pub fn system_info() -> SystemInfo {
let mut sys = System::new_all();
sys.refresh_all();

let os_name = sys.name().unwrap();
let mut os_name = System::name().unwrap();
let mut os_arch = env::consts::ARCH.to_string();
let cpu_name = sys.cpus()[0].brand().to_string();
let total_mem = sys.total_memory();
let os_arch = env::consts::ARCH.to_string();

os_name = match os_name.as_str() {
"Darwin" => "macOS".to_string(),
_ => os_name,
};

os_arch = match os_arch.as_str() {
"x86_64" => "x64".to_string(),
"aarch64" => "arm64".to_string(),
_ => os_arch,
};

let res = SystemInfo {
os_name,
Expand Down
17 changes: 7 additions & 10 deletions interface/layout/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { os, event, window, invoke } from "@tauri-apps/api"
import { getSettings } from "../stores/settings"
import { navigate } from "../utils/navigate"
import { getState } from "interface/stores/state"
import { dev } from "../../build.json"
import { dev, version } from "../../build.json"
import { optionalAnalyticsPayload } from "interface/utils/analytics"
import { checkForUpdate } from "interface/utils/update"
import logger from "interface/utils/logger"
import { init, trackEvent } from "@aptabase/web"

const settings = getSettings()
const state = getState()
Expand All @@ -19,6 +20,9 @@ const app = new App({

export default app

// Setup analytics
init("A-EU-1557095726", { appVersion: version })

// Set background color if vibrancy not supported
const setBackground = async () => {

Check warning on line 27 in interface/layout/app.ts

View workflow job for this annotation

GitHub Actions / build

'setBackground' is assigned a value but never used
const system = await os.type()
Expand Down Expand Up @@ -97,17 +101,10 @@ launchOptions()
// Optional analytics
const optionalAnalytics = async () => {
if (settings.settings.optionalAnalytics === true && dev === false) {
const payload = JSON.stringify(await optionalAnalyticsPayload())
const payload = await optionalAnalyticsPayload()

try {
fetch("https://api.levminer.com/api/v1/authme/analytics/post", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: payload,
})
trackEvent("app_start", { version: payload.version, build: payload.build, os: payload.os, lang: payload.lang, date: payload.date.toISOString().split("T")[0] })
} catch (error) {
logger.error(`Failed to send analytics: ${error}`)
}
Expand Down
2 changes: 1 addition & 1 deletion interface/utils/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const optionalAnalyticsPayload = async () => {
return {
version: build.version,
build: build.number,
os: `${osName} ${osArch.replace("x86_64", "x64")} ${osVersion}`,
os: `${osName} ${osArch.replace("x86_64", "x64").replace("aarch64", "arm64")} ${osVersion}`,
lang: navigator.language,
date: new Date(),
}
Expand Down
2 changes: 1 addition & 1 deletion interface/windows/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const about = async () => {
.replace(/ +(?= )/g, "")
const memory = `${Math.round(systemInfo.totalMem / 1024 / 1024 / 1024)} GB`
const osName = systemInfo.osName
const osArch = systemInfo.osArch.replace("x86_64", "x64").replace("aarch64", "arm64")
const osArch = systemInfo.osArch

const info = `Authme: ${build.version} \n\nTauri: ${tauriVersion}\n${browserName}: ${browserVersion}\n\nOS version: ${osName} ${osArch} ${osVersion}\nHardware info: ${cpu} ${memory} RAM\n\nRelease date: ${build.date}\nBuild number: ${build.number}\n\nCreated by: Lőrik Levente`

Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"typescript": "^5.3.2"
},
"dependencies": {
"@aptabase/web": "^0.4.2",
"@undecaf/barcode-detector-polyfill": "^0.9.16",
"@undecaf/zbar-wasm": "^0.9.13",
"otpauth": "^8.0.3",
Expand Down

0 comments on commit 17a3957

Please sign in to comment.