Links

Node.js

Use Buildable's Node SDK to send server-side events to various destinations.

SDK Setup Guide

Buildable's Node SDK lets you track and send the events from your Node applications to the specified destinations.
Refer to the Node SDK's GitHub codebase for the implementation-specific details.
Github Badge

Connecting the SDK Source

  1. 1.
    Sign up to Buildable Cloud
  2. 2.
    Connect a Node.js Source from the dashboard. You should be able to see the secret key for this source, as shown:
The Setup tab in the Buildable dashboard (seen above) has the SDK installation snippet containing the secret key. Copy it to integrate the Node SDK into your application.

Installing the Node SDK on your machine

To install the Buildable Node SDK using npm, run the following command:
npm install @buildable/client

Initializing the SDK

Run the following snippet to initialize the Node SDK. It creates a global Buildable client object that can be used for all the subsequent event requests.
import { createClient } from "@buildable/client";
// Init your Web SDK
const client = createClient(process.env.BUILDABLE_SECRET_KEY);

Sending events

Emit

The emit call lets you create and package an event with a name and a payload.
A sample emit call is as shown:
import { createClient } from "@buildable/client";
// Init your Web SDK
const client = createClient(process.env.BUILDABLE_SECRET_KEY);
// Emit Message
client.emit("user.created", user);
The emit parameters are described below:
Field
Required
Type
Description
Event
string
The name of the event
Payload
string
The data associated with the event
Alternatively, you can emit using cURL:
# Using cURL
curl --location --request POST 'https://events.buildable.dev/emit' \
--header 'X-Buildable-Secret: <YOUR SECRET KEY 🤫>' \
--header 'Content-Type: application/json' \
--data-raw '{
"event": "user.created",
"payload": {
"name": "John Doe"
}
}'
Last modified 9d ago