Socket
Socket
Sign inDemoInstall

reddit-event-tracker

Package Overview
Dependencies
0
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    reddit-event-tracker

send events to the /events endpoint easily


Version published
Weekly downloads
1
decreased by-50%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

Behold, the Event Tracker

Build Status

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 = new EventTracker({
  key: 'MyApp01',
  secret: 'abcdef==',
  postData: jQuery.post, // 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.track('mod_events', 'ban', {
  user_name: 'allthefoxes',
  user_id: 't2_8aioi',
  sr_name: 'noadmins',
  sr_id: 't5_2xakt',
  details_text: 'reason: being an admin',
  target_id: 't2_3bzrh',
  target_name: 'ajacksified',
  target_type: 'user',
}, defaults);

// 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.send(callback);

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.

FAQs

Last updated on 12 Apr 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc