A Node.js client for Segment — The hassle-free way to integrate analytics into any application.
$ npm install analytics-node
const Analytics = require('analytics-node');
const client = new Analytics('write key');
client.track({
event: 'event name',
userId: 'user id'
});
For sending events via kinesis you need to set the flushMethod
option as kinesis
and the host
option with the name of your stream.
And if you need to authenticate on code level, you can send an object with your aws credentials on the first parameter (you can send an empty object if don't need it).
Example:
const Analytics = require('analytics-node');
const awsCredentials = {
accessKeyId: 'xxx',
secretAccessKey: 'xxxx'
};
const client = new Analytics(awsCredentials, {
host: 'MyStramName',
flushMethod: 'kinesis'
});
Documentation is available at https://segment.com/libraries/node.
Copyright © 2017 Segment Inc. <[email protected]>