Install — Desktop
Install AnyReplay in a Tauri App
Record Tauri v2 app windows with @anyreplay/tauri: one call in your frontend, the identifier read from tauri.conf.json, and the CSP and capabilities to allow.
A Tauri window is a web page in the system's web view, so the Tauri SDK records it with the browser SDK — the same masking, the same delivery, the same player. It is JavaScript only, with no Rust plugin, and adds what a web page cannot know: the app's identifier and version, and when the window loses focus.
Install
npm install @anyreplay/tauri @tauri-apps/apipnpm add @anyreplay/tauri @tauri-apps/apiyarn add @anyreplay/tauri @tauri-apps/apiStart recording
import { init } from '@anyreplay/tauri';
// The app id is the identifier in tauri.conf.json; list it under the
// project's allowed apps. Allow https://in.anyreplay.com in your CSP's connect-src.
init({
projectKey: 'YOUR_PROJECT_KEY',
ingestUrl: 'https://in.anyreplay.com',
// Stop recording after this many sessions in a calendar month.
// maxSessionsPerMonth: 10000,
// Form fields are masked: what visitors type replays as asterisks.
// Passwords, one-time codes and card fields are masked either way.
// Uncomment the first line to record what visitors type, or the
// second to hide rich-text editors too.
// maskAllInputs: false,
// maskAllTyping: true
});init takes every option of the browser SDK. It returns at once and starts recording when the app info arrives a moment later; calls made before then are queued.
| Option | Default | What it does |
|---|---|---|
appId | identifier from tauri.conf.json | Read with getIdentifier(), which needs Tauri 2.4 or later. |
appVersion | getVersion() | The version shown with each session. |
flushOnBlur | true | Sends what was recorded whenever the window loses focus. |
flushOnClose | false | Sends it before the window closes. Needs core:window:allow-destroy; see below. |
Capabilities
core:default already allows what the SDK reads: the identifier, name and version, and the window's focus event. Turning on flushOnClose means the window is closed from JavaScript once the recording is sent, so add core:window:allow-destroy to the window's capability — without it the window would not close.
Content Security Policy
When app.security.csp is set in tauri.conf.json, add the ingest host to connect-src, or recordings are blocked before they leave the window.
{
"app": {
"security": {
"csp": "default-src 'self'; connect-src 'self' ipc: http://ipc.localhost https://in.anyreplay.com"
}
}
}The app id and sessions
A Tauri window is served from tauri://localhost on macOS and Linux and http://tauri.localhost on Windows. Neither is a website, so a project that lists allowed domains or apps admits it by its identifier: list it under the project's Allowed apps. Each window is its own session; the visitor id lives in localStorage, which Tauri keeps between launches. Styles, fonts and images are recorded into the session itself, because the player cannot fetch them from the app later.