From 8975df74377100d908f093c067162653fa50c1a3 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 22 Jan 2025 16:56:43 +0100 Subject: [PATCH] feat: add umami analytics --- index.html | 2 ++ package.json | 1 + pnpm-lock.yaml | 8 +++++++ src/index.tsx | 9 +++++++- src/pages/home.tsx | 30 ++++++++++++++------------- src/pages/overview/overview-table.tsx | 21 +++++++++++++++---- tsconfig.json | 2 +- 7 files changed, 53 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index db87507..3c1a14c 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,8 @@ + diff --git a/package.json b/package.json index 9df1a1e..4ad91eb 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "@solidjs/router": "^0.15.3", "@sqlite.org/sqlite-wasm": "3.48.0-build2", "@tanstack/solid-table": "^8.20.5", + "@types/umami": "^2.10.0", "chart.js": "^4.4.7", "chartjs-chart-wordcloud": "^4.4.4", "chartjs-plugin-deferred": "^2.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf4764d..277ba26 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,9 @@ importers: '@tanstack/solid-table': specifier: ^8.20.5 version: 8.20.5(solid-js@1.9.4) + '@types/umami': + specifier: ^2.10.0 + version: 2.10.0 chart.js: specifier: ^4.4.7 version: 4.4.7 @@ -800,6 +803,9 @@ packages: '@types/node@22.10.7': resolution: {integrity: sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==} + '@types/umami@2.10.0': + resolution: {integrity: sha512-iWcs1KkcO3ooIi2rR9M5drmpQzlsT+sFiyWElIGmVwjdGlp+vQmy/VYIChYnF5ETqx7KrL80JfSkroS6dm37Hg==} + JSONStream@1.3.5: resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} hasBin: true @@ -2739,6 +2745,8 @@ snapshots: dependencies: undici-types: 6.20.0 + '@types/umami@2.10.0': {} + JSONStream@1.3.5: dependencies: jsonparse: 1.3.1 diff --git a/src/index.tsx b/src/index.tsx index 097844a..337c61c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -42,7 +42,14 @@ if (root) { There is currently no backup database loaded, but you can watch statistics that have been cached, meaning only chats you already opened or chats that were preloaded.
- Watch cached statistics + { + umami.track("Watch cached statistics"); + }} + > + Watch cached statistics + } diff --git a/src/pages/home.tsx b/src/pages/home.tsx index 5ca7fa3..f966207 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -37,7 +37,7 @@ export const Home: Component = () => { const [loadingProgress, setLoadingProgress] = createSignal(); // const [isLoadingDatabase, setIsLoadingDatabase] = createSignal(false); - const onSubmit: JSX.EventHandler = async (event) => { + const onSubmit: JSX.EventHandler = (event) => { event.preventDefault(); const currentBackupFile = backupFile(); @@ -53,22 +53,24 @@ export const Home: Component = () => { // setDbHash(hash); - try { - const decrypted = await decryptBackup(currentBackupFile, currentPassphrase, setDecryptionProgress); + decryptBackup(currentBackupFile, currentPassphrase, setDecryptionProgress) + .then(async (decrypted) => { + umami.track("Decrypt backup"); + setDecryptionProgress(undefined); + // setIsLoadingDatabase(true); + setLoadingProgress(0); - setDecryptionProgress(undefined); - // setIsLoadingDatabase(true); - setLoadingProgress(0); + await loadDb(decrypted.database_statements, setLoadingProgress); + umami.track("Load database"); - await loadDb(decrypted.database_statements, setLoadingProgress); + // setIsLoadingDatabase(false); + setLoadingProgress(undefined); - // setIsLoadingDatabase(false); - setLoadingProgress(undefined); - - navigate("/overview"); - } catch (error) { - console.error("Decryption failed:", error); - } + navigate("/overview"); + }) + .catch((error) => { + console.error("Decryption failed:", error); + }); } }; diff --git a/src/pages/overview/overview-table.tsx b/src/pages/overview/overview-table.tsx index 811f7e8..d0533e0 100644 --- a/src/pages/overview/overview-table.tsx +++ b/src/pages/overview/overview-table.tsx @@ -94,6 +94,7 @@ export const columns = [