This plugin allows you to instrument your app with events that can be analyzed in Aptabase, a privacy-first analytics platform for Desktop and Mobile apps.
Install the Core plugin by adding the following to your Cargo.toml
file:
src-tauri/Cargo.toml
toml
[dependencies]
tauri-plugin-aptabase = "0.1"
You can install the JavaScript Guest bindings using your preferred JavaScript package manager
```bash pnpm add @aptabase/tauri
npm add @aptabase/tauri
yarn add @aptabase/tauri ```
First you need to get your App Key
from Aptabase, you can find it in the Instructions
menu on the left side menu.
Then you need to register the core plugin with Tauri:
src-tauri/src/main.rs
diff
fn main() {
tauri::Builder::default()
+ .plugin(tauri_plugin_aptabase::init("<YOUR_APP_KEY>".into())) // 👈 this is where you enter your App Key
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```js import { trackEvent } from "@aptabase/tauri";
trackEvent("connectclick") // An event with no properties trackEvent("playmusic", { name: "Here comes the sun" }) // An event with a custom property ```
A few important notes:
trackEvent
manually.
trackEvent
function, it'll run in the background.