A library to integrate analytics to nodejs applications
This is a wrapper library for popular analytics providers. It abstracts over their methods and offers an API to easily identify users and track events in nodejs applications.
Via npm:
npm install --save analytica
The module exports methods to:
- require the core analytics lib
- require the provided integrations
- add the desired integration
- initialize the library
- track event
Example usage:
Require the core analytics library and the mixpanel integration:
var analytics = require('analytica').core;
var mp = require('analytica').mixpanelIntegration;
analytics.addIntegration(mp);
var options = {token: "<YOUR_TOKEN>"};
analytics.initialize({'Mixpanel': options});
Identify user and track event:
analytics.identify(123, { name: 'testuser', email: 'testemail@test.com', '$distinct_id': 123 },
function () {
console.log('done identifying user');
});
analytics.track('my event', { distinct_id: 123, descr: 'test event' },
function () {
console.log('done tracking event');
});
Run the test suite by doing:
npm test
If you're having any problem, please raise an issue on GitHub
PRs accepted.
Small note: If editing the Readme, please conform to the standard-readme specification.
The project is licensed under the Apache 2.0 license.