@getdevteam/analytics-core
Platform-agnostic core client for the DevTeam Analytics & Logging Platform.
Use this directly from Node or any custom JS runtime.
For a browser app use @getdevteam/analytics-web instead.
Install
npm install @getdevteam/analytics-core
Use
import { createClient } from "@getdevteam/analytics-core";
const analytics = createClient({
key: "dti_your_server_key", // DEVTEAM_ANALYTICS_SERVER_KEY, the server ingest key
host: "https://ingest.analytics.getdevteam.ai",
serviceName: "checkout-worker",
});
analytics.track("invoice_generated", { amount: 4200 });
await analytics.flush(); // call before your process exits
Pass release: { version, commit } to attribute every event and log to a build; without it the client reads globalThis.__DEVTEAM_RELEASE__, then DEVTEAM_RELEASE_VERSION / DEVTEAM_COMMIT_SHA from process.env, which Devteam sets on every deploy.
You need an ingest key and the ingest host URL for your environment - see Getting a key in the full SDK docs.
On a server, use the environment's server ingest key (dti_, published by DevTeam as the secret DEVTEAM_ANALYTICS_SERVER_KEY): it can only send data, and what it sends is stamped trust = 'server', while data sent with the public dtp_ key is stamped client.
Never send with the secret dts_ key, which can also read all of the project's data.
Full client API, config options, and release process: src/sdk README.