diff --git a/package.json b/package.json index 7c55ad9..d4df1dc 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "tauri": "tauri" }, "dependencies": { + "@aptabase/tauri": "^0.2.0", "@polybase/client": "^0.6.2", "@polybase/eth": "^0.6.2", "bluebird": "^3.7.2", @@ -26,7 +27,6 @@ "react": "^18.2.0", "react-chartjs-2": "^5.2.0", "react-dom": "^18.2.0", - "react-ga4": "^2.1.0", "react-hot-toast": "^2.4.1", "react-tooltip": "^5.20.0", "tauri-plugin-sql-api": "https://github.com/tauri-apps/tauri-plugin-sql", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 936bf24..526d8a9 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2312,6 +2312,17 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_info" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" +dependencies = [ + "log", + "serde", + "winapi", +] + [[package]] name = "overload" version = "0.1.1" @@ -3590,6 +3601,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sys-locale" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0b9eefabb91675082b41eb94c3ecd91af7656caee3fb4961a07c0ec8c7ca6f" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + [[package]] name = "system-deps" version = "5.0.0" @@ -3785,6 +3806,25 @@ dependencies = [ "tauri-utils", ] +[[package]] +name = "tauri-plugin-aptabase" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c9e179512deb8e8e88d11edff8d55c2026f737195d275156743fa69a5e4f79" +dependencies = [ + "log", + "os_info", + "reqwest", + "serde", + "serde_json", + "sys-locale", + "tauri", + "thiserror", + "time 0.3.20", + "uuid 1.3.3", + "wry", +] + [[package]] name = "tauri-plugin-sql" version = "0.0.0" @@ -4248,6 +4288,7 @@ dependencies = [ "sqlx", "tauri", "tauri-build", + "tauri-plugin-aptabase", "tauri-plugin-sql", "tokio", "uuid 1.3.3", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 62d4e84..4d4120d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -26,6 +26,7 @@ sqlx = {version = "0.6", features = ["runtime-tokio-rustls", "sqlite"] } tauri = {version = "1.2", features = ["app-all", "dialog-open", "dialog-save", "fs-read-file", "fs-write-file", "http-all", "process-relaunch", "updater"] } tokio = {version = "1", features = ["sync"] } uuid = "1.3.3" +tauri-plugin-aptabase = "0.3" [features] # by default Tauri runs in production mode diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 643b1a7..724828a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,12 +1,16 @@ #[macro_use] extern crate lazy_static; use std::{collections::HashMap, fs}; +use tauri_plugin_aptabase::EventTracker; use tauri::Manager; use track3::{ binance::Binance, ent::Ent, - migration::{init_sqlite_tables, is_first_run, is_from_v01_to_v02, migrate_from_v01_to_v02, init_sqlite_file, is_from_v02_to_v03, migrate_from_v02_to_v03}, + migration::{ + init_sqlite_file, init_sqlite_tables, is_first_run, is_from_v01_to_v02, is_from_v02_to_v03, + migrate_from_v01_to_v02, migrate_from_v02_to_v03, + }, okex::Okex, price::get_price_querier, }; @@ -161,6 +165,8 @@ async fn get_polybase_namespace(handle: tauri::AppHandle) -> Result { setLoading(false); + trackEvent("data_refreshed") if (refreshError) { toast.error(refreshError.message || (refreshError as any)); } else { diff --git a/src/main.tsx b/src/main.tsx index 579e5ea..4381324 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2,9 +2,8 @@ import React from "react"; import ReactDOM from "react-dom/client"; import App from "./App"; import "./style.css"; -import ReactGA from "react-ga4"; -import { getClientID, getVersion } from './utils/app' - +import { getClientID, getVersion } from "./utils/app"; +import { trackEvent } from "@aptabase/tauri"; ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( @@ -13,36 +12,28 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( ); function disableContextmenu() { - if (window.location.hostname !== 'tauri.localhost') { - return + if (window.location.hostname !== "tauri.localhost") { + return; } - document.addEventListener('contextmenu', e => { + document.addEventListener( + "contextmenu", + (e) => { e.preventDefault(); return false; - }, { capture: true }) + }, + { capture: true } + ); } -disableContextmenu() +disableContextmenu(); // ga4 -;(async () => { - const GAID = "G-QTHN28P1Q3" +(async () => { try { - const cid = await getClientID() - const version = await getVersion() - ReactGA.initialize([{ - trackingId: GAID, - gaOptions: { - app_version: version, - clientId: cid - }, - gtagOptions: { - app_version: version, - clientId: cid - } - }]) + const cid = await getClientID(); + trackEvent("app_started", { clientId: cid || "unknown" }); } catch (e) { - ReactGA.initialize(GAID) - throw e + trackEvent("app_started"); + throw e; } -})() +})(); diff --git a/yarn.lock b/yarn.lock index 48f34d6..ba6254c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27,6 +27,13 @@ "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" +"@aptabase/tauri@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@aptabase/tauri/-/tauri-0.2.0.tgz#60bcfb3ff1071ba5d25f8a9dcbc78072c13e2d8c" + integrity sha512-mj/GhwSqcnVhrMvVCVWHXyqC8AXIw/SyUacr9po/d5fFW83YW2fHkhMLNPdvdh/GZ6Rcr/AnLTp45UfvLL5Gqg== + dependencies: + "@tauri-apps/api" "^1.0.0" + "@babel/code-frame@^7.18.6", "@babel/code-frame@^7.21.4": version "7.21.4" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.21.4.tgz#d0fa9e4413aca81f2b23b9442797bda1826edb39" @@ -517,6 +524,11 @@ tweetnacl "^1.0.3" tweetnacl-util "^0.15.1" +"@tauri-apps/api@^1.0.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.4.0.tgz#b4013ca3d17b853f7df29fe14079ebb4d52dbffa" + integrity sha512-Jd6HPoTM1PZSFIzq7FB8VmMu3qSSyo/3lSwLpoapW+lQ41CL5Dow2KryLg+gyazA/58DRWI9vu/XpEeHK4uMdw== + "@tauri-apps/api@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.2.0.tgz#1f196b3e012971227f41b98214c846430a4eb477" @@ -1238,11 +1250,6 @@ react-dom@^18.2.0: loose-envify "^1.1.0" scheduler "^0.23.0" -react-ga4@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/react-ga4/-/react-ga4-2.1.0.tgz#56601f59d95c08466ebd6edfbf8dede55c4678f9" - integrity sha512-ZKS7PGNFqqMd3PJ6+C2Jtz/o1iU9ggiy8Y8nUeksgVuvNISbmrQtJiZNvC/TjDsqD0QlU5Wkgs7i+w9+OjHhhQ== - react-hot-toast@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/react-hot-toast/-/react-hot-toast-2.4.1.tgz#df04295eda8a7b12c4f968e54a61c8d36f4c0994"