Node.js SDK
Server-side event tracking for Node.js applications.
Installation
bash: npm install @vanta-dev/node
npm install @vanta-dev/nodeSetup
typescript: import { Vanta } from '@vanta-dev/node'
import { Vanta } from '@vanta-dev/node'
const vanta = new Vanta({
apiKey: process.env.VANTA_API_KEY
})Sending events
typescript: await vanta.track({
await vanta.track({
event: 'purchase',
data: {
product: 'Premium',
price: 19.99
}
})Identifying users
typescript: await vanta.identify({
await vanta.identify({
userId: 'user_123',
properties: {
email: 'sarah@example.com'
}
})Tracking errors
typescript: try {
try {
// your code
} catch (error) {
await vanta.error(error)
}Configuration
typescript: const vanta = new Vanta({
const vanta = new Vanta({
apiKey: process.env.VANTA_API_KEY,
apiUrl: 'https://vantapi.pancake.wtf', // optional
flushInterval: 10000, // ms between flushes (default: 10000)
flushSize: 20, // events per batch (default: 20)
maxRetries: 3 // retry attempts (default: 3)
})Shutdown
typescript: await vanta.shutdown()
await vanta.shutdown()This flushes queued events and stops the flush timer. Call it before your process exits.