npm package
@aptabase/tauri review
Choose @aptabase/tauri when you can own the Rust setup and want explicit Aptabase events in a Tauri app.
Installing @aptabase/tauri is only part of adding Aptabase analytics to a Tauri app. The JavaScript bindings call a native Rust plugin, which needs registration and access permissions. This guide covers @aptabase/tauri 0.7.0 and explains the setup, explicit event calls and optional beta error reporting. Its central limit is delivery: awaiting a native command does not confirm that the analytics server received the event.
Choose @aptabase/tauri when you can own the Rust setup and want explicit Aptabase events in a Tauri app. Skip it for durable event records or complete crash capture. Verify one event in your own built app before expanding instrumentation.
Answers from our run
@aptabase/tauri or @aptabase/web: which should you use?
@aptabase/web: Evaluate @aptabase/web for a web application. Its registry describes a JavaScript SDK for Aptabase covering web apps. This supports a platform alternative, not a claim that it can replace the native Tauri integration unchanged. Choose @aptabase/tauri when you can own the Rust setup and want explicit Aptabase events in a Tauri app.
When should you not use @aptabase/tauri?
You need analytics in an ordinary browser page. These bindings invoke a Tauri native command and need the native plugin.
Use it if
Skip it if
Setup reality
No installation, Tauri compilation or event delivery to an Aptabase account is documented in the supplied evidence. All snippets below are documentation-based, unexecuted illustrations. The supplied TypeScript implementation is pinned to the gitHead identified by the npm registry. It supports the illustrated function signatures and native invocation behavior; the published package declarations were not independently checked. These sources do not establish operation on your target desktop or mobile platform.
The 1.3.0 release pairs Rust plugin 1.3.0 with JavaScript bindings 0.7.0. Keep those version numbers distinct. The npm registry declares @tauri-apps/api ^2.10.1 as a dependency, so use this guide for a Tauri 2 integration. The release notes specify Rust 1.85.0. You also need the platform tooling required to build your Tauri app. The supplied sources do not establish that existing lockfiles or native builds will work unchanged.
Install the JavaScript package, add the Rust dependency, then register the plugin on your existing Tauri builder before running it. Get an App Key from the Instructions menu in Aptabase and replace the placeholder in the example. Add aptabase:allow-track-event to the access permissions for the calling window. Error reporting needs the separate aptabase:allow-track-error permission. Installing npm dependencies alone does not perform these native and permission steps.
Start with one named event that contains no user text. Custom event property values are strings or numbers. Convert booleans deliberately and choose a small vocabulary for screen names or export formats. Avoid sending document contents or full local paths merely because a property accepts a string. Review error reports separately: their messages and stack traces can contain details you did not intend to collect.
The README documents event delivery every 60 seconds in release builds and every 2 seconds in debug builds. Events are queued in memory and sent in the background: every 60 seconds in release builds and every 2 seconds in debug builds. Network failures and server 5xx responses leave events queued for a later flush; other unsuccessful statuses drop them. The queue isn't saved to disk. An awaited trackEvent call is therefore not a server receipt. The snippets catch native invocation failures, but their catch blocks cannot detect every later delivery failure. Use another storage mechanism if your workflow needs a durable audit record.
Error reporting is beta. Calling trackError reports a handled error without enabling automatic crash reporting. Automatic reporting requires a separate Builder option and still excludes native crashes outside Rust's panic handler. Error reports also have different delivery rules: the release notes say they are sent immediately, with network errors, 408, 429 and 5xx retried; a 403 for an exhausted monthly error quota and other 4xx responses are dropped. The fatal option marks severity and is forwarded to the native command; the helper does not terminate the application.
Before adoption, build your app on its actual target, trigger one non-sensitive event and one deliberately safe handled error, and inspect both in the Aptabase dashboard. Then check behavior when the app closes or loses its network connection. These are recommended next steps, not completed runtime checks.
Patterns
Pin the JavaScript bindings install-bindings
npm install @aptabase/tauri@0.7.0Run this in your existing Tauri frontend project. It installs the guest bindings, not the Rust plugin. All examples are unexecuted illustrations for this package version.
Add the paired Rust plugin add-native-plugin
[dependencies]
tauri-plugin-aptabase = "=1.3.0"Merge the entry into src-tauri/Cargo.toml without creating a second dependencies table. The exact pin keeps the example on the release that names JavaScript bindings 0.7.0. Its release notes specify Rust 1.85.0.
Register Aptabase on the existing builder register-native-plugin
tauri::Builder::default()
.plugin(tauri_plugin_aptabase::Builder::new("<YOUR_APP_KEY>").build())
.run(tauri::generate_context!())
.expect("error while running tauri application");This is a builder-chain fragment for your existing Rust entry point, not a complete main.rs. Keep other plugins and setup hooks. Replace the placeholder with the App Key from Aptabase before running the app.
Grant event and handled-error permissions allow-frontend-commands
"permissions": [
"core:default",
"aptabase:allow-track-event",
"aptabase:allow-track-error"
]Merge these Aptabase permissions into the existing capability for the calling window. This is a JSON property fragment, not a complete capability file. Keep existing permissions. Omit aptabase:allow-track-error if you do not use error reporting. The pinned README names both Aptabase identifiers.
Send one explicit event send-named-event
import { trackEvent } from '@aptabase/tauri';
async function recordSettingsOpened() {
try {
await trackEvent('settings_opened');
} catch {
console.warn('Analytics command failed');
}
}Call this function when settings actually open inside the Tauri frontend. The supplied implementation awaits the native invocation. Catching its rejection does not establish whether later background HTTP delivery succeeds.
Keep custom properties flat send-event-properties
import { trackEvent } from '@aptabase/tauri';
async function recordExport(format, itemCount) {
try {
await trackEvent('export_completed', {
format,
item_count: itemCount,
});
} catch {
console.warn('Analytics command failed');
}
}Call recordExport('png', 4) only after the application's export succeeds. Pass a string format and numeric count: the Props type in the supplied TypeScript source allows string or number values. Objects, arrays and booleans do not fit that contract. This helper does not perform an export or validate its arguments.
Check an application-owned collection preference respect-local-preference
import { trackEvent } from '@aptabase/tauri';
async function recordThemeChange(analyticsEnabled, theme) {
if (!analyticsEnabled) return;
try {
await trackEvent('theme_changed', { theme });
} catch {
console.warn('Analytics command failed');
}
}analyticsEnabled must come from your app's preference handling. Pass a bounded string such as 'dark' for theme. This guard is application code, not an SDK consent API. It suppresses this call only; it does not clear queued events or disable other instrumentation.
Report an error the application caught report-handled-error
import { trackError } from '@aptabase/tauri';
async function reportHandledError(error) {
try {
await trackError(error);
} catch {
console.warn('Error-report command failed');
}
}Call this from an existing catch block after deciding the error is safe to send. It needs aptabase:allow-track-error. The supplied implementation accepts unknown values, extracts Error name/message/stack, and stringifies other thrown values. This helper does not enable automatic crash reporting.
Label a report as fatal label-fatal-report
import { trackError } from '@aptabase/tauri';
async function reportFatalError(error) {
try {
await trackError(error, { fatal: true });
} catch {
console.warn('Fatal-report command failed');
}
}Use this for an error your application's workflow cannot recover from. The supplied implementation forwards fatal as options?.fatal === true. This helper does not terminate the app, enable crash hooks or confirm server receipt. Error reporting remains beta.
Alternatives
| Package | Registry | Pick it when |
|---|---|---|
| @aptabase/web | npm | Evaluate @aptabase/web for a web application. Its registry describes a JavaScript SDK for Aptabase covering web apps. This supports a platform alternative, not a claim that it can replace the native Tauri integration unchanged. |
| posthog-js | npm | Consider posthog-js for automatic usage capture sent to PostHog. Its registry describes that purpose. This changes the analytics destination and capture approach; the supplied evidence does not establish Tauri compatibility or a drop-in replacement. |
More utils guides
How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.