| Crates.io | tauri-plugin-better-posthog |
| lib.rs | tauri-plugin-better-posthog |
| version | 0.1.3 |
| created_at | 2025-12-20 08:55:47.019563+00 |
| updated_at | 2026-01-25 09:26:02.943839+00 |
| description | Tauri integration with PostHog |
| homepage | |
| repository | https://github.com/niusia-ua/better-posthog-rust |
| max_upload_size | |
| id | 1996236 |
| size | 162,405 |
tauri-plugin-better-posthogTauri integration with PostHog.
npm install posthog-js tauri-plugin-better-posthog
cargo add better-posthog tauri-plugin-better-posthog
Initialize the PostHog client and register the plugin in your Tauri application:
fn main() {
// Initialize the client (keep the guard alive for the application lifetime).
let _guard = better_posthog::init(better_posthog::ClientOptions {
api_key: Some("phc_your_api_key".into()),
..Default::default()
});
// Register the plugin.
tauri::Builder::default()
.plugin(tauri_plugin_better_posthog::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Configure posthog-js to route all events through the Rust backend:
import posthog from "posthog-js";
import { captureEvent } from "tauri-plugin-better-posthog";
posthog.init("dummy_api_key", {
// other options...
// Route all events through the Rust backend.
before_send: [
// Keep this function last.
(captureResult) => {
if (captureResult) {
const { event, properties } = captureResult;
captureEvent(event, properties).catch(console.error);
}
// Return `null` to prevent `posthog-js` from sending directly.
return null;
},
],
});