Active User
The active-user
modules allows you to quickly track daily, weekly, and monthly active users in Redis.
Installing and Getting Started
You can install the active-user
module via npm. You will also need to have a Redis server instance running.
npm install active-user
Once active-user
is installed we need a client:
var activeUser = ; var activity = activeUser;
Tracking
activity.track(id, [action]);
Tracking is a very simple operation:
activity;activity;
Where the id is the id of the user you want to track and the action is the action they performed.
activity.untrack(id, [action]);
You may also undo a tracked action for a user with untrack
:
activity;activity;
Reporting
You can fetch the daily, weekly, and monthly active users easily:
activity.daily([action], [date], callback);
// Fetching the number of users who commented on Nov 21, 2013activity; // Fetching the number of daily active users for the current dayactivity;
activity.weekly([action], [date], callback);
// Fetching the number of users who commented the week containing Nov 21, 2013activity; // Fetching the number of daily active users for the current weekactivity;
activity.monthly([action], [date], callback);
// Fetching the number of users who commented the month of Nov 2013activity; // Fetching the number of daily active users for the current monthactivity;