Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace ga to aptabase #113

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
41 changes: 41 additions & 0 deletions src-tauri/Cargo.lock

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

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down Expand Up @@ -161,6 +165,8 @@ async fn get_polybase_namespace(handle: tauri::AppHandle) -> Result<String, Stri

fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_sql::Builder::default().build())
.plugin(tauri_plugin_aptabase::Builder::new("A-EU-6972874637").build())
.setup(|app| {
let app_version = app.package_info().version.to_string();
let resource_path = app.path_resolver();
Expand All @@ -177,7 +183,7 @@ fn main() {
// upgrade from v0.1 to v0.2
migrate_from_v01_to_v02(app_dir.as_path(), resource_dir.as_path());
}

if is_from_v02_to_v03(app_dir.as_path()).unwrap() {
migrate_from_v02_to_v03(app_dir.as_path(), resource_dir.as_path());
}
Expand All @@ -193,7 +199,6 @@ fn main() {
close_debank_window,
get_polybase_namespace,
])
.plugin(tauri_plugin_sql::Builder::default().build())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
2 changes: 2 additions & 0 deletions src/components/refresh-data/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { refreshAllData } from "../../middlelayers/charts";
import { toast } from "react-hot-toast";
import { LoadingContext } from "../../App";
import { updateAllCurrencyRates } from "../../middlelayers/currency";
import { trackEvent } from '@aptabase/tauri'

const retries = 3;
const retryInterval = 3000; // 3s
Expand Down Expand Up @@ -50,6 +51,7 @@ const App = ({
})
.finally(() => {
setLoading(false);
trackEvent("data_refreshed")
if (refreshError) {
toast.error(refreshError.message || (refreshError as any));
} else {
Expand Down
43 changes: 17 additions & 26 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<React.StrictMode>
Expand All @@ -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;
}
})()
})();
17 changes: 12 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Loading