Tracks the rate of events.
It's also able to compute the min,max and average interval between events.
Example
constclicks = Trackers.rate();
// Mark when a click happens document.addEventListener(`click`, () =>clicks.mark());
// Get details clicks.perSecond; // How many clicks per second clicks.perMinute; // How many clicks per minute
timeoutInterval is a useful option to make the tracker reset
after some period without mark() being called.
Another useful option is sampleLimit, which sets an upper bound
for how many events to track. A smaller value means the results
will more accurately track, but it might be less smooth.
// Eg reset tracker after 5 seconds of inactivity constclicks = Trackers.rate({ sampleLimit:10, timeoutInterval: { secs:5 } });
Tracks the rate of events. It's also able to compute the min,max and average interval between events.
Example
timeoutInterval
is a useful option to make the tracker reset after some period withoutmark()
being called.Another useful option is
sampleLimit
, which sets an upper bound for how many events to track. A smaller value means the results will more accurately track, but it might be less smooth.