Integration Guides

Tauri

Add Fluxner analytics to your Tauri app

SDK release pending

The Fluxner web SDK is not published to npm. The SDK tab below is reference only; do not install similarly named packages. Review the Script tag option against your app's security policy and the platform limitations below, or wait for an official SDK release. See Web SDK availability.

Tauri v2 bundles your frontend into the app and serves it to the system webview. Install the @fluxner/js SDK in the frontend (or put the snippet in its index.html), then allow https://fluxner.com in the app.security.csp block of src-tauri/tauri.conf.json.

Get your tracking snippet

In your Fluxner dashboard, open Site Settings → Tracking Script and copy your snippet. It looks like this:

<script src="https://fluxner.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>

YOUR_SITE_ID is the numeric ID of your site. If you self-host Fluxner on another domain, replace fluxner.com with your instance's domain.

Add the snippet to Tauri

Tauri's security guide advises against loading remote scripts such as CDN-hosted files. The SDK keeps all executable code inside the bundle, so it is the recommended method.

  1. Install the package in your frontend project:
# No npm installation is available yet. Review the Script tag option or wait.
  1. Initialise it once in the frontend entry file (src/main.ts or equivalent):
src/main.ts
import fluxner from "@fluxner/js";

await fluxner.init({
  analyticsHost: "https://fluxner.com/api",
  siteId: "YOUR_SITE_ID",
});
  1. Allow the analytics host in connect-src. Keep ipc: and http://ipc.localhost, which Tauri needs for frontend-to-Rust calls:
src-tauri/tauri.conf.json
{
  "app": {
    "security": {
      "csp": {
        "default-src": "'self'",
        "connect-src": ["ipc:", "http://ipc.localhost", "https://fluxner.com"]
      }
    }
  }
}
  1. Paste the snippet into the <head> of your frontend's index.html:
index.html
<script src="https://fluxner.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
  1. Allow the host in both script-src and connect-src:
src-tauri/tauri.conf.json
{
  "app": {
    "security": {
      "csp": {
        "default-src": "'self'",
        "script-src": ["'self'", "https://fluxner.com"],
        "connect-src": ["ipc:", "http://ipc.localhost", "https://fluxner.com"]
      }
    }
  }
}

If app.security.csp is unset, Tauri applies no CSP and neither change is needed. Route changes inside the app are tracked automatically: the tracker wraps history.pushState and history.replaceState and listens for popstate and hashchange.

Verify installation

Open your live site in a new tab and click through a few pages. Within a few seconds the pageviews appear in the Fluxner dashboard.

If nothing shows up:

  • View the page source and search for script.js?siteId= to confirm the snippet is on the page.
  • Open the browser Network tab and check that script.js returns 200 and that POST requests go to /api/track.
  • Disable ad blockers, or set up a proxy so the script loads from your own domain.
  • See the script troubleshooting guide for other common causes.

Troubleshooting

  • Works in tauri dev but not in the built app on macOS, Linux or iOS: in development the frontend is served from your dev server (http://localhost:1420 by default), which is a normal http origin. Production builds serve it from http://tauri.localhost on Windows and Android but from the custom scheme tauri://localhost on macOS, Linux and iOS. Fluxner's tracking endpoints answer CORS preflights for http:// and https:// origins only, so requests from tauri://localhost are blocked by the webview. On Windows and Android, app.windows[].useHttpsScheme: true switches the origin to https://tauri.localhost; both forms work.
  • CSP violation in the webview console: the message names the blocked directive. Add https://fluxner.com there; the SDK only needs connect-src, the script tag also needs script-src.
  • Object vs string CSP: app.security.csp accepts either a single policy string or the object form shown above. Do not mix the two.

Next steps

On this page