Node.js analytics for API servers, CLIs, scripts and crons
Track events from API servers, CLIs, scripts and cron jobs.
Install#
npm i @shipabase/jsUse the Node entry#
import { init, trackEvent, flush } from "@shipabase/js/node"; init(process.env.SHIPABASE_KEY!, { appVersion: "2.3.0" }); trackEvent("report_generated", { pages: 12, format: "pdf" }); // Short-lived process? Flush before exit.await flush();- Uses the global
fetch(Node 18+). - Reads the OS from
process.platformandos.release(), and the locale fromIntl. - Its timer never keeps your process alive. In short-lived processes,
await flush()before exit.
Related guides
DocsAPI reference: init, trackEvent, flushThree functions. None of them throw, and calls before init are ignored.DocsHow to name analytics eventsShort, stable names make every chart readable.DocsEvent props without personal data: limits and the PII guardAdd context to events without collecting personal data.