@splitbee/node

The Splitbee Node.js library provides Splitbee tracking functionality in server-side applications built using Node.js. This is the way to go if you want to send data from your Node server.

Installation

Use npm or yarn to install the package @splitbee/node

yarn add @splitbee/node

Usage

Getting Started

To get started, initialise the package by replacing the TOKEN with your project token. You can find it in your project settings.

Make sure to provide a userId. It is required to link events to the correct user.

const { SplitbeeAnalytics } = require('@splitbee/node');
const analytics = new SplitbeeAnalytics('TOKEN');
// Track an event
analytics.track({
userId: 'my-custom-user-id',
event: 'Payment confirmed',
data: {
paymentId: '1234567890',
},
});

Updating user data

Set custom user properties with this function. Data is automatically merged with existing data.

analytics.user.set({
userId: 'my-custom-user-id',
userData: {
username: 'Custom Name',
isTrial: true,
},
});