npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@veridia/node-sdk

v1.0.18

Published

Official Node.js SDK for integrating with the [Veridia Platform](https://veridia.io). It provides an easy way to identify users, send tracking events, retrieve user segments, and manage batching with retries and timeouts — all from your backend.

Downloads

166

Readme

Veridia Node SDK

Official Node.js SDK for integrating with the Veridia Platform.
It provides an easy way to identify users, send tracking events, retrieve user segments, and manage batching with retries and timeouts — all from your backend.

npm version


🚀 Installation

npm install @veridia/node-sdk

or with Yarn:

yarn add @veridia/node-sdk

📦 Usage

ESM

import { VeridiaClient } from '@veridia/node-sdk';

const client = new VeridiaClient({
  credentials: {
    accessKeyId: 'your-access-key-id',
    secretAccessKey: 'your-secret-access-key',
  },
  logger: {
    error: (service, msg, ctx) => console.error(`[ERROR] ${service}: ${msg}`, ctx),
    warn: (service, msg, ctx) => console.warn(`[WARN] ${service}: ${msg}`, ctx),
    info: (service, msg, ctx) => console.log(`[INFO] ${service}: ${msg}`, ctx),
  },
});

CommonJS

const { VeridiaClient } = require('@veridia/node-sdk');

const client = new VeridiaClient({
  credentials: {
    accessKeyId: 'your-access-key-id',
    secretAccessKey: 'your-secret-access-key',
  },
  logger: { error: console.error },
});

🧠 API Reference

identify(identifierType, identifierId, attributes)

Identify a user and update their profile attributes. Provided attributes must match the Profile Attributes schema defined in your Veridia dashboard.

await client.identify('userId', '123', {
  email: '[email protected]',
  country: 'US',
  plan: 'premium',
});

| Parameter | Type | Description | | ---------------- | ----------------------- | --------------------------- | | identifierType | "userId" | "email" | How the user is identified. | | identifierId | string | Unique identifier value. | | attributes | Record<string, any> | Arbitrary user attributes. |


track(identifierType, identifierId, eventType, eventId, eventTime, properties)

Track an event performed by a user. Provided attributes must match the event attributes schema defined in your Veridia dashboard.

await client.track('userId', '123', 'purchase', 'evt-001', new Date().toISOString(), {
  productId: 'A-1',
  price: 49.99,
});

| Parameter | Type | Description | | ---------------- | ----------------------- | -------------------------------- | | identifierType | "userId" | "email" | How the user is identified. | | identifierId | string | Unique user identifier. | | eventType | string | Logical name of the event. | | eventId | string | Unique event ID for idempotency. | | eventTime | string | ISO timestamp string. | | properties | Record<string, any> | Optional event properties. |


getUserSegments(identifierType, identifierId, [noSegmentsOnError=true])

Fetches the list of segments the specified user currently belongs to. If the API call fails and noSegmentsOnError is set to false, it will throw an error. Otherwise, it will return an empty array.

const segments = await client.getUserSegments('userId', '123');
console.log(segments); // ['617090ac-a1f6-4c70-a79e-40830a367324', '67f2c139-850f-469f-9ca4-a1c58e6d84ea']

| Parameter | Type | Default | Description | | ------------------- | ---------- | --------- | --------------------------------------------------- | | identifierType | "userId" | "email" | Type of user identifier. | | identifierId | string | — | Unique user ID or email. | | noSegmentsOnError | boolean | true | If true, returns [] instead of throwing an error. |

Returns: Promise<string[]> — Array of segment identifiers.


flush()

Immediately sends all queued identify and track data. Automatically called when buffers reach their configured limits or after the flush interval.

await client.flush();

close()

Flushes any remaining buffered data and closes the client gracefully. Call this before application exit in workers or serverless environments.

await client.close();

⚙️ Configuration Options

| Option | Type | Default | Description | | -------------------------- | --------------- | --------------------------- | --------------------------------------------- | | accessKeyId | string | — | Veridia API access key ID. | | secretAccessKey | string | — | Veridia API secret. | | endpoint | string | https://api.veridia.io/v1 | API base URL. | | region | string | "default" | API region. | | autoFlush | boolean | true | Whether to automatically flush buffered data. | | maxBufferSize | number | 500 | Max number of items before auto-flush. | | maxBufferTimeMs | number | 5000 | Max time (ms) before auto-flush. | | retries | number | 3 | Retry attempts on transient network errors. | | retryBaseDelayMs | number | 500 | Base delay (ms) for exponential backoff. | | timeoutMsGetUserSegments | number | 5000 | Timeout (ms) for getUserSegments calls. | | timeoutMsFlush | number | 30000 | Timeout (ms) for batch flush requests. | | logger | VeridiaLogger | — | Custom logger implementation. |


🧾 Logger Interface

You can integrate your own logger (e.g. Pino, Winston, Bunyan) by providing the following interface:

interface VeridiaLogger {
  info?(service: string, message: string, context?: VeridiaLogContext): void;
  warn?(service: string, message: string, context?: VeridiaLogContext): void;
  error(service: string, message: string, context?: VeridiaLogContext): void;
}

interface VeridiaLogContext {
  status?: number;
  error?: unknown;
  data?: unknown;
  [key: string]: unknown;
}

Example:

import pino from 'pino';
const log = pino();

const client = new VeridiaClient({
  credentials: {
    accessKeyId: 'your-access-key-id',
    secretAccessKey: 'your-secret-access-key',
  },
  logger: {
    info: (s, m, c) => log.info({ service: s, context: c }, m),
    warn: (s, m, c) => log.warn({ service: s, context: c }, m),
    error: (s, m, c) => log.error({ service: s, context: c }, m),
  },
});

🧩 TypeScript Support

The SDK ships with full .d.ts declarations and JSDoc documentation. Hover over any method in VS Code to see inline descriptions and parameter hints.


🧪 Example Usage

import { VeridiaClient } from '@veridia/node-sdk';

const client = new VeridiaClient({
  credentials: {
    accessKeyId: 'your-access-key-id',
    secretAccessKey: 'your-secret-access-key',
  },
  logger: { error: console.error },
});

await client.identify('userId', '123', { plan: 'gold' });
await client.track('userId', '123', 'purchase', 'evt-123', new Date().toISOString());
await client.flush();

const segments = await client.getUserSegments('userId', '123');
console.log('Segments:', segments);

🧱 License

MIT © Veridia