Skip to content

Node.js Setup

This SDK is for server-side events from a Node.js backend. For client-side events, use the JavaScript SDK.

1. NPM install

Run this in your CLI to install the Sumatra SDK.

npm install @sumatra/sdk-node

2. Load the Sumatra SDK

Add the following code to load the Sumatra SDK, using your private API Key.

import { Sumatra } from '@sumatra/sdk-node';
const sumatra = new Sumatra('{SUMATRA_API_KEY}');


Replace SUMATRA_API_KEY with your private API key.

3. Start tracking events

To send an event and its attributes asynchronously, call the track method as in the example below:

sumatra.track('login', {
    username: "john.doe",
    successful: true

4. Later, fetch enrichments

To synchronously fetch features or take an action in your application, add an enrich call. An enrich call is used to both track and enrich events, so it may replace a track call you previously added.

The following example decides whether or not to allow a user to sign up:

sumatra.enrich('signup', {
    email: "",
    ip: "",
    name: "Darrel Smith",
    browser: {"language": "en-US"}
}).then((enriched) => {
    if (enriched.features.verdict == "Block") {
        // block signup
    } else {
        // allow signup
}).catch((error) => {

The enriched response object will contain all of the features computed by your Scowl code. See the API response docs for the full details.