Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/latentflip/lytic
https://github.com/latentflip/lytic
Last synced: 30 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/latentflip/lytic
- Owner: latentflip
- Created: 2014-03-14T14:53:28.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-19T18:21:16.000Z (over 9 years ago)
- Last Synced: 2024-04-15T02:17:46.544Z (7 months ago)
- Language: JavaScript
- Size: 161 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Generic analytics tracking wrapper
## Current builtin services:
* mixpanel
## Usage
```javascript
var tracking = require('lytic');
require('tracking/services/mixpanel').configure({
key: "";
});tracking.identify("user-id", {
name: "Phil"
});tracking.track("played a video", {
//optional data
startTime: 0,
endTime: 120
});
```## Adding services
Services should call `tracking._addTracker(name, config)` to register themselves. You can either add services here, or application specific ones.
```javascript
//my-custom-tracker.jsvar tracking = require('lytic'); //make relative if actually including in this repo
module.exports.configure = function (config) {
//Export as a configure method for consistencyvar identify = function (userId, userData) {
//identify will receive a userId, and a userData object//do something with the data
};var track = function (event, data) {
//track will receive an event name, and data object (may be empty if not provided
};//Register the tracker
tracking._addTracker('my-tracker', {
identify: identify,
track: track
});
};
```Your application will then use it like so:
```javascript
var tracking = require('lytic');
var custom = require('./my-custom-tracker');
custom.configure({
configItem: 'stuff'
});tracking.track('event name', {
//data
});
```