windsor-node
v1.0.0
Published
Integrate user and event capture with Node applications
Downloads
13
Maintainers
Readme
windsor-node
Send data for Windsor.io from Node
Get started
- Create a Windsor Account
- Setup the Node source
- Create Users on Windsor
- With
windsor-node
, callwindsor.user(...)
everytime a new user signs up or data about a user changes to keep things updated
- With
- Track Events
- You'll want to see every important event or issue your user runs into. Call
windsor.event(...)
for every event you want to know a user has taken. You can setup alerts and more from Windsor
- You'll want to see every important event or issue your user runs into. Call
Read the docs here.
Why?
You care about your users. You probably already have a slack channel filling up with important events, or you search through logs to see what your users are upto. Windsor is a better way. Track the users and events you care about to Windsor so your company can more easily manage and understand your user behavior.
For example, you can create a new Windsor user from any Node app:
windsor.user({
userId: "01nc83ns",
traits: {
name: "Pranay Prakash",
email: "[email protected]",
company: "windsor",
posts: 42,
},
});
And track events you'd like to know your users took
windsor.event({
userId: "01nc83ns",
event: "Post Created",
properties: {
title: "Getting Started",
private: false,
},
});
Then follow the user on Windsor
Installation
$ yarn add windsor-node
Usage
const Windsor = require("windsor-node");
const windsor = new Windsor("token");
windsor.user({
userId: "user id",
traits: {
name: "user name",
email: "user email",
},
});
windsor.event({
event: "event name",
userId: "user id",
});
Advanced Usage
windsor-node
batches and sends multiple events together to improve performance on production systems. When using windsor-node
on a serverless/lambda environment like AWS Lambda, Vercel or Serverless, you need to ensure that all events are sent before responding to the request.
const Windsor = require("windsor-node");
const windsor = new Windsor("token");
exports.handler = async (event) => {
let greeting = "";
if (event.queryStringParameters && event.queryStringParameters.greeting) {
console.log("Received greeting: " + event.queryStringParameters.greeting);
greeting = event.queryStringParameters.greeting;
}
// A promise is returned, but instead of using await here
// we can send multiple analytics events and then await a single
// call to windsor.flush() before returning the response
windsor.event({
event: "Sent Greeting",
properties: {
greeting,
},
});
const message = `${greeting} World.`;
const responseBody = { message };
const response = {
statusCode: 200,
body: JSON.stringify(responseBody),
};
await windsor.flush();
return response;
};
Documentation
Documentation is available at https://docs.windsor.io/docs/analytics
License
Copyright © 2020 Windsor Software Inc. <[email protected]>
See the LICENSE file for details and see the SEGMENT_LICENSE file attribution to the Segment Library this was based off.