Links

Sources

A guide on how to use Event's modern and lightweight SDK to programmatically manage your Sources of data
Event's SDK requires an Event API Key, which can be created via the settings page in your Developer Dashboard

Getting Started

To start using the Event SDK, install the package:
Node.js
npm install @event-inc/connections

Initialize

We'll start off by initializing the client, which requires your Event API key. You can specify the environment as either "sandbox" or "production".
Node.js
import { createClient } from '@event-inc/connections';
const client = createClient(process.env.EVENT_INC_API_KEY, {
environment: "sandbox"
});

Create a Source

Next, we'll create a source using the createSource function. Here's an example:
JavaScript
TypeScript
import { createSource } from '@event-inc/connections';
const source = await createSource(client, {
type: "stripe",
group: "customer-abc",
label: "Production Stripe",
config: {
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,
},
});
import { createSource } from '@event-inc/connections';
const source = await createSource<"stripe">(client, {
type: "stripe",
group: "customer-abc",
label: "Production Stripe",
config: {
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,
}
});
The createSource function requires the following parameters:
Name
Required
Description
type
Type of Source to create (i.e., Stripe, Shopify, FTP Server, etc..)
group
A meaningful and unique group for the data (i.e., Customer ID)
label
A human-readable label to easily identify the source later
config
Any additional configuration settings (i.e., access credentials)
Upon successful source creation, the createSource function will return a response with details about the created source.
{
_id: 'conn_src_MTY4NjE2MDY2ODk4Mw::NDFkMjMxZjAtY2MwOS00ZmRiLWIxZGEtNWFhMmM3NDE1MDQ3',
_v: '1.0.0',
type: 'stripe',
group: 'customer-abc',
label: 'Production Stripe',
key: 'source::stripe::customer-abc',
identifiers: {
live: 'id_live_1_KJ-JzUIrtTz2m3kGR1RqcaYPOCoP5t9MI85g7liWuNLqpJJ8RtJ90bxOtEUl8_cv9oRl_YM9DjLOadl-pLHcTV85wrU1oKonJMSfVvn8uVvtSqYBnQaH97z1D2fqN9SHMJ7nmFBRppP4gNN2Arn9P7IhLzI87-6rBaBxBetu9eaSVuuo6YMB9Bu2lW-eg9rvAPuOb7IqLRbG'
},
integrationDefinitionId: '627aceaf971c67182d1d76ca',
integrationApiVersion: '2020-03-02',
createdAt: 1686160668983,
createdDate: '2023-06-07T17:57:48.983Z',
active: true,
deleted: false,
deprecated: false,
// ...
}

Set your Event Subscriptions

Having set up our source, we'll subscribe to events using the setEvents function. Here's an example:
JavaScript
TypeScript
import { setEvents } from '@event-inc/connections';
await setEvents(client, {
type: "stripe",
key: source.key,
events: ["customer.created"],
});
import { setEvents } from '@event-inc/connections';
await setEvents<"stripe">(client, {
type: "stripe",
key: source.key,
events: ["customer.created"],
});
The setEvents function requires the following parameters:
Name
Required
Description
type
Type of Source to configure (i.e., Stripe, Shopify, FTP Server, etc..)
key
The Source's unique key
events
The events you'd like to ingest
Once successfully subscribed, you will receive a response confirming the subscription to the specified events.
{ success: true }

View Live Events

Once your Connection is live and subscription is configured, you'll start to ingest events in real-time according to your source setup. You can view a full list of successfully ingested events in the Live Events tab of the Developer Dashboard.