Skip to content

Commit

Permalink
feat: basic anon analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparkenstein committed Mar 11, 2024
1 parent 2efc294 commit a11e104
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 101 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"type-check": "tsc"
},
"dependencies": {
"@aptabase/tauri": "^0.4.1",
"@hello-pangea/dnd": "^16.5.0",
"@loadable/component": "^5.16.3",
"@mantine/charts": "^7.6.1",
Expand Down
114 changes: 113 additions & 1 deletion 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 @@ -36,6 +36,7 @@ oxipng = { version = "9.0", features = [
], default-features = false }
webp = "0.2"
base64 = "0.21.7"
tauri-plugin-aptabase = "0.4"

[features]
default = ["custom-protocol"]
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use commands::ping::ping::ping;
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_aptabase::Builder::new("A-EU-0242299228").build())
.invoke_handler(tauri::generate_handler![
hash,
ping,
Expand Down
30 changes: 29 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Nums from "./Features/number-tools/Nums";
import { data, Navbar } from "./Layout/Navbar";
import { Settings } from "./Layout/Settings";
import { useDisclosure, useWindowEvent } from "@mantine/hooks";
import { trackOtherEvent, trackPageView } from "./utils/analytics";

// Lazy load components
const Welcome = loadable(() => import("./Components/Welcome"));
Expand Down Expand Up @@ -84,6 +85,14 @@ const shortCuts = [
key: "mod + b",
action: "toggle sidebar collapse",
},
{
key: "(mod + k) + (mod + d)",
action: "editor dark theme, anywhere",
},
{
key: "(mod + k) + (mod + l)",
action: "editor light theme, anywhere",
},
];

function App() {
Expand All @@ -109,14 +118,26 @@ function App() {
}
}, []);

useEffect(() => {
trackPageView(location.pathname);
}, [location]);

const listener = (e: KeyboardEvent) => {
if (e.shiftKey && e.key === "?") {
trackOtherEvent("shortcut", {
key: "shift + ?",
action: "open-shortcut",
});
open();
}
if (e.key === "Escape") {
close();
}
if (e.ctrlKey && e.key === "t") {
trackOtherEvent("shortcut", {
key: "mod + t",
action: "toggle-theme",
});
toggleColorScheme();
}
};
Expand Down Expand Up @@ -195,7 +216,14 @@ function App() {
actions={data.map((a) => ({
id: a.to,
label: a.text,
onClick: () => nav(a.to),
onClick: () => {
trackOtherEvent("shortcut", {
key: "mod + k",
action: "spotlight-search",
to: a.to,
});
nav(a.to);
},
icon: a.icon,
}))}
></Spotlight>
Expand Down
4 changes: 4 additions & 0 deletions src/Features/hash/FileHash.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, Group, LoadingOverlay, Stack, Table } from "@mantine/core";
import { dialog, invoke } from "@tauri-apps/api";
import { useState } from "react";
import { trackOtherEvent } from "../../utils/analytics";

const FileHash = () => {
const [fileHashes, setFileHashes] = useState<
Expand Down Expand Up @@ -28,6 +29,9 @@ const FileHash = () => {
);
console.timeEnd("t1");
setLoading(false);
trackOtherEvent("file_hash", {
files: filePaths.length,
});
};

return (
Expand Down
6 changes: 1 addition & 5 deletions src/Features/random/Random.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,7 @@ const Random = () => {
</Box>
<Box>Entropy: {pass.entropy}</Box>
<Text size="xs" color={"dimmed"}>
Note: entropy calculation might be broken.
</Text>
<Text size="xs" color={"dimmed"}>
And even if it&apos;s correct, entropy is not everything do not rely on
it
note: entropy is not everything do not rely on it
</Text>
</Stack>
);
Expand Down
Loading

1 comment on commit a11e104

@farfromrefug
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please allow us to disable this ? I would prefer to wait for a new version without analytics to update

Please sign in to comment.