Atune Docs
Guides

Express

Send events from Express with track() and query understanding.

Atune isn't Next-only. track(), understand(), identify() and group() are plain HTTP under the hood and work in any Node 18+ server.

Install and configure

npm install atune
.env
ATUNE_API_KEY=<YOUR_API_KEY>ATUNE_URL=https://test.useatune.com

Sign in to find your API key in Settings.

Capture behavior

Call track() where a route already knows the customer account. Don't await it:

import express from "express";
import { track } from "atune";

const app = express();

app.post("/reports", requireAuth, async (req, res) => {
  const report = await createReport(req.body);
  void track("feature.report.generated", { accountId: req.user.orgId, userId: req.user.id });
  res.json(report);
});

track() needs atune 0.1.3 or later. See Any backend for which actions to pick and the HTTP API for other languages.

The one rule

Whatever framework you're on, capture must be fire-and-forget. A slow or down Atune can never delay or break your app.

Query understanding

understand() works the same everywhere — it's just an authenticated HTTP call:

import { understand } from "atune";

const r = await understand("portfolio", "who is at risk this week?");
if (r.knows) console.log(r.answer, r.citations);

Identity

import { identify, group } from "atune";

await identify("u_123", { name: "Kari Nordmann", email: "kari@acme.no" }, { accountId: "acme" });
await group("acme", { company: "Acme AS" });

Same DPA rules apply — see Identity, PII & the DPA.

On this page