The Problem

Developers building Tauri desktop apps need a lightweight, privacy‑first analytics solution that can be called from both Rust (backend) and JavaScript (frontend). Without a dedicated plugin they must instrument HTTP calls themselves, duplicate code, and risk leaking platform‑specific metadata.

What This Does

tauri-plugin-aptabase ships a native Rust library (src/lib.rs, src/commands.rs, src/client.rs) that wraps the Aptabase HTTP API and automatically enriches events with OS, app version, and runtime info. The plugin is exposed to the Tauri runtime via the builder pattern (tauripluginaptabase::Builder::new("<APPKEY>").build()).

On the JavaScript side, the compiled web‑view assets in webview-dist/ provide the @aptabase/tauri NPM package, which re‑exports a thin wrapper around window.TAURIINVOKE_ to call the Rust trackevent command. Example calls (trackEvent("savesettings")) are shown in the README and rely on the generated TypeScript definitions in webview-dist/index.d.ts.

The examples/helloworld folder demonstrates a full end‑to‑end setup: a Svelte UI (src/App.svelte) that imports trackEvent from the NPM package, and a Tauri backend (examples/helloworld/src-tauri/src/main.rs) that registers the plugin and tracks startup/shutdown events.

How To Use It

Add the plugin to the Rust side # examples/helloworld/src-tauri/Cargo.toml [dependencies] tauri-plugin-aptabase = "1.0.0"

Or use the Git source as shown in the README. Register the plugin in your Tauri entry point // examples/helloworld/src-tauri/src/main.rs tauri::Builder::default() .plugin(tauripluginaptabase::Builder::new("<YOURAPPKEY>").build()) .run(tauri::generatecontext!()) .expect("error while running tauri application"); (Optional) Load the key from .env – add dotenvymacro to your Cargo dependencies and replace the literal with dotenv!("APTABASEKEY") as demonstrated in the README. Install the JavaScript bindings npm add @aptabase/tauri

This pulls the package published from webview-dist/ (the repo also contains the source TypeScript in webview-src/). Call from the frontend import { trackEvent } from "@aptabase/tauri";

trackEvent("screenview", { name: "Settings" }); Run the example # From the repository root cd examples/helloworld npm install # installs vite, svelte, and the @aptabase/tauri binding npm run dev # starts the Vite dev server and Tauri window

The example’s vite.config.js and package.json provide the necessary build pipeline.

Real‑World Use

A SaaS desktop client built with Tauri can embed this plugin to record feature‑usage events (e.g., “exportpdf”, “toggledarkmode”) without sending personally identifiable data. The Rust backend can batch and flush events on RunEvent::Exit, ensuring no data loss when the user closes the app.

app.trackevent("fileopened", Some(json!({ "type": "pdf" }))); app.flusheventsblocking(); // guaranteed send before exit

Code Health & Issues

Medium – No test suite – No files under tests/ or src/tests.rs; core commands (trackevent) are untested. Medium – No CI/CD – Repository lacks .github/workflows or other CI configuration, so builds aren’t automatically verified. Low – Missing Cargo.lock – Cargo.toml is present but no Cargo.lock; reproducible builds depend on the consumer’s lockfile. Low – Limited documentation – README covers basic usage, but internal modules (src/dispatcher.rs, src/sys.rs) have no inline docs, making maintenance harder. Low – Permission schema – permissions/autogenerated/commands/trackevent.toml is generated but not referenced in the README; developers may miss the need to add aptabase:allow-track-event to the ACL.

No obvious unsafe Rust code or secret leakage is visible. The example compiles with the current Tauri toolchain, indicating reasonable compatibility.

The Bottom Line

tauri-plugin-aptabase provides a minimal, well‑structured bridge for Aptabase analytics in Tauri apps, with clear Rust and JavaScript entry points and a functional example. The primary drawbacks are the lack of automated testing/CI and missing lockfile, which could affect reliability for production teams. It is suitable for developers who need quick analytics integration and are comfortable adding their own test and CI scaffolding.