Behold, the Event Tracker
Usage:
// key, secret, clientName, and endpoint can also be configured via the environment// variables TRACKER_KEY, TRACKER_SECRET, TRACKER_CLIENT_NAME and TRACKER_ENDPOINT. var tracker = key: 'MyApp01' secret: 'abcdef==' postData: jQuerypost // function to use for ajax: `post(url, data)` calculateHash: createHmac // A function that takes (key, string) and returns an HMAC endpoint: 'https://events-test.redditmedia.com/v1' // collector endpoint clientName: 'desktopWeb' // client name, prepended to event type in payload appendClientContext: true // automatically adds user_agent, path, and domain to payload bufferTimeout: 100 // flush buffer of events after 100ms bufferLength: 40 // flush buffer events after buffer length is 40 debug: true // log events instead of sending them.); tracker; // send immediately rather than buffering. Without calling `send()`, the event// will be sent after buffer timeout (100ms) or buffer max length (40) is// reached. `send` flushes the current buffer of events and resets the timer.// send optionally takes a callback.tracker;
Testing
- Install node
- Run
npm test
Using It
- Either use it as a git-linked NPM package, copypaste it into your project, or git-submodule it.