Skip to main content
Events are the immutable history of what happens in your application. An event consists of a name, a timestamp, and a JSON payload.

Event Structure

A valid event object contains the following fields:
FieldTypeRequiredDescription
namestringYesThe name of the event (e.g., signup.completed).
user_idstringNoThe ID of the user who performed the action.
dataobjectNoArbitrary JSON object with event properties.
timestampstringNoISO 8601 timestamp. Defaults to now.

Sending Events

Use the events.capture method to record an event.
import Seerstack from 'seerstack';

const client = new Seerstack({
  apiKey: process.env['SEERSTACK_API_KEY'],
});

await client.events.capture({
  name: 'invoice.paid',
  user_id: 'cus_8374',
  data: {
    invoice_id: 'inv_993',
    amount: 2000,
    currency: 'usd'
  }
});

Naming Conventions

We recommend using a noun.verb syntax for your event names. This keeps your data organized and easy to search.

Good

  • project.created
  • user.signup
  • payment.failed

Bad

  • created project
  • User Clicked Signup Button
  • fail