You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This plugin is only compatible with Tauri v1. To use it on a Tauri v2 app, [follow the instructions on our v2 branch](https://github.com/aptabase/tauri-plugin-aptabase/blob/v2).
25
-
26
24
## Usage
27
25
28
26
First, you need to get your `App Key` from Aptabase, you can find it in the `Instructions` menu on the left side menu.
29
27
30
-
Then you need to register the core plugin with Tauri:
28
+
Then register the plugin with Tauri:
31
29
32
30
`src-tauri/src/main.rs`
33
31
@@ -40,11 +38,12 @@ fn main() {
40
38
}
41
39
```
42
40
41
+
And finally add `aptabase:allow-track-event` to your list Access Control List.
42
+
43
43
You can then start sending events from Rust by importing the `tauri_plugin_aptabase::EventTracker` trait and calling the `track_event` method on `App`, `AppHandle` or `Window`.
44
44
45
45
As an example, you can add `app_started` and `app_exited` events like this:
46
46
47
-
48
47
```rust
49
48
usetauri_plugin_aptabase::EventTracker;
50
49
@@ -83,3 +82,35 @@ A few important notes:
83
82
- Because of this, it's generally recommended to at least track an event at startup
84
83
3. You do not need to await for the `trackEvent` function, it'll run in the background.
85
84
3. Only strings and numbers values are allowed on custom properties
85
+
86
+
## Providing the APTABASE_KEY via .env
87
+
88
+
It's possible to load the APTABASE_KEY from a .env file at compile time using the `dotenvy_macro` crate. The `.env` file needs to be
89
+
in the `src-tauri` directory for the `dotevny_macro` crate to find it properly.
90
+
91
+
Add the `use` declaration to where you are building the tauri app (likely `lib.rs` for Tauri v2), and then call it where you would put the key.
92
+
93
+
```rust
94
+
usetauri_plugin_aptabase::EventTracker;
95
+
usedotenvy_macro::dotenv;
96
+
97
+
#[cfg_attr(mobile, tauri::mobile_entry_point)]
98
+
/// This function sets up and runs a Rust application using the Tauri framework, with various plugins
0 commit comments