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

@trig.email/ingest-sdk

v0.1.1

Published

SDK for trig.email ingest API - track events and identify profiles

Readme

@trig.email/ingest-sdk

TypeScript SDK for the VanEmail event ingestion API.

Installation

bun add @trig.email/ingest-sdk

Usage

Initialize the client

import { IngestClient } from '@trig.email/ingest-sdk';

const client = new IngestClient({
  apiKey: 'vk_your_api_key_here',
  baseUrl: 'https://ingest.yourdomain.com' // optional, defaults to http://localhost:3001
});

Track events

Track a single event:

const response = await client.track({
  eventType: 'purchase',
  email: '[email protected]',
  properties: {
    amount: 99.99,
    product: 'Premium Plan'
  },
  occurredAt: new Date().toISOString(), // optional
  externalId: 'order_123' // optional, for deduplication
});

console.log(response);
// {
//   success: true,
//   eventId: '...',
//   deduplicated: false,
//   flowsTriggered: 2
// }

Batch track events

Track multiple events in a single request (up to 1000):

const response = await client.batch({
  events: [
    {
      eventType: 'page_view',
      email: '[email protected]',
      properties: { page: '/pricing' }
    },
    {
      eventType: 'button_click',
      email: '[email protected]',
      properties: { button: 'Sign Up' }
    }
  ]
});

console.log(response);
// {
//   success: true,
//   processed: 2,
//   deduplicated: 0,
//   total: 2
// }

Identify profiles

Create or update a user profile:

const response = await client.identify({
  email: '[email protected]',
  externalId: 'user_123', // optional
  traits: {
    name: 'John Doe',
    plan: 'premium',
    signupDate: '2024-01-15'
  }
});

console.log(response);
// {
//   success: true,
//   profileId: '...'
// }

Queued tracking

For high-volume event tracking, use trackWithQueue() to buffer events and send them in batches. Events are automatically flushed when either:

  • The queue reaches 100 events (configurable via queueMaxSize)
  • 1 minute has passed since the first queued event (configurable via queueFlushIntervalMs)
const client = new IngestClient({
  apiKey: 'vk_your_api_key_here',
  queueMaxSize: 100,
  queueFlushIntervalMs: 60000
});

client.trackWithQueue({
  eventType: 'page_view',
  email: '[email protected]',
  properties: { page: '/home' }
});

client.trackWithQueue({
  eventType: 'button_click',
  email: '[email protected]',
  properties: { button: 'Sign Up' }
});

console.log(client.getQueueSize());

const result = await client.flush();
console.log(result);
// {
//   success: true,
//   processed: 2,
//   deduplicated: 0,
//   total: 2
// }

Health check

Check if the ingest server is healthy:

const health = await client.health();
console.log(health);
// {
//   status: 'ok',
//   timestamp: '2024-01-15T10:30:00.000Z',
//   service: 'ingest'
// }

Error Handling

The SDK throws IngestError for all errors:

import { IngestClient, IngestError } from '@trig.email/ingest-sdk';

try {
  await client.track({
    eventType: 'purchase',
    email: 'invalid-email' // will fail validation
  });
} catch (error) {
  if (error instanceof IngestError) {
    console.error('Ingest error:', error.message);
    console.error('Status code:', error.statusCode);
    console.error('Response:', error.response);
  }
}

TypeScript Support

The SDK is written in TypeScript and provides full type safety:

import type {
  TrackEvent,
  TrackResponse,
  BatchEvents,
  BatchResponse,
  IdentifyProfile,
  IdentifyResponse,
  HealthResponse
} from '@trig.email/ingest-sdk';

API Reference

IngestClient

Constructor

new IngestClient(config: IngestClientConfig)
  • config.apiKey (required): Your API key with vk_ prefix
  • config.baseUrl (optional): Base URL of the ingest server (default: http://localhost:3001)
  • config.queueMaxSize (optional): Maximum events to buffer before auto-flush (default: 100)
  • config.queueFlushIntervalMs (optional): Time in ms before auto-flush (default: 60000)

Methods

  • track(event: TrackEvent): Promise<TrackResponse> - Track a single event immediately
  • trackWithQueue(event: TrackEvent): void - Add event to queue for batched sending
  • flush(): Promise<BatchResponse | null> - Manually flush queued events
  • getQueueSize(): number - Get current number of queued events
  • batch(batch: BatchEvents): Promise<BatchResponse> - Track multiple events
  • identify(profile: IdentifyProfile): Promise<IdentifyResponse> - Identify a profile
  • health(): Promise<HealthResponse> - Check server health