vident-node
v1.0.0
Published
Vident server-side event tracking SDK
Maintainers
Readme
vident-node
Server-side event tracking SDK for Vident.
Installation
npm install vident-nodeQuick Start
import { createClient } from "vident-node"
const vident = createClient({
apiKey: "vd_...",
appName: "my-app",
})
// Track events
vident.trackEvent("signup", { plan: "pro" })
// Identify users
vident.setUser("user-123", { name: "Alice", plan: "pro" })
// Flush before shutdown
await vident.flush()API
createClient(config)
const vident = createClient({
apiKey: "vd_...", // Required
appName: "my-app", // Optional, groups events by app
baseUrl: "https://...", // Optional, default: https://api.vident.dev
flushInterval: 5000, // Optional, default: 5000ms
maxBatchSize: 50, // Optional, default: 50
})When apiKey is missing, all methods silently no-op (safe for dev environments).
vident.trackEvent(name, properties?, options?)
Track a custom event.
vident.trackEvent("purchase", { amount: 99.99, currency: "USD" })
// With session/user correlation
vident.trackEvent("checkout", { items: 3 }, {
sessionId: "sess_abc",
userId: "user_123",
})vident.setUser(userId, traits?, options?)
Identify a user. Sends a user_identified event and updates the session if a sessionId is provided.
vident.setUser("user-123", {
name: "Alice",
email: "[email protected]",
plan: "pro",
})vident.flush()
Flush all queued events. Called automatically on a timer and before process exit.
await vident.flush()vident.destroy()
Stop the client — clears the flush timer and sends remaining events.
vident.destroy()Graceful Shutdown
The SDK automatically flushes on process.beforeExit. For explicit control:
process.on("SIGTERM", async () => {
vident.destroy()
process.exit(0)
})Error Handling
import { VidentError, UnauthorizedError } from "vident-node"License
MIT
