@inslytic/sdk-node
v0.1.5
Published
Node.js server-side SDK for Inslytic — AI-powered product analytics
Downloads
166
Maintainers
Readme
@inslytic/sdk-node
Node.js server-side SDK for Inslytic — AI-powered product analytics.
Install
npm install @inslytic/sdk-nodeRequires Node.js 18+.
Usage
import { InslyticNode } from "@inslytic/sdk-node";
const inslytic = new InslyticNode({ apiKey: "your-api-key" });
// Track events
inslytic.track({
eventName: "subscription_created",
userId: "user-123",
anonymousId: "anon-456",
properties: { plan: "pro" },
});
// Identify users
inslytic.identify("user-123");
// Flush pending events and shut down gracefully
await inslytic.shutdown();Sessions on the server
Server-side calls rarely have a real session concept. If you don't pass a
sessionId, the SDK uses the anonymousId as the session identifier so the
event still satisfies the ingestion API's non-empty sessionId requirement.
Pass an explicit sessionId whenever you have one (e.g. forwarded from a
browser request).
Configuration
const inslytic = new InslyticNode({
apiKey: "your-api-key",
endpoint: "https://api.inslytic.com", // default
flushInterval: 10000, // batch flush interval in ms
maxBatchSize: 20, // max events per batch
maxRetries: 3, // retry attempts on failure
});API
| Method | Description |
|---|---|
| track(event) | Track a server-side event |
| identify(userId, traits?) | Track an identify event |
| flush() | Flush all queued events |
| shutdown() | Flush and stop the SDK |
| pending | Number of queued events |
The SDK automatically flushes on SIGTERM and SIGINT for graceful shutdown.
License
MIT
