request-tracker

0.0.7 • Public • Published

Request tracker

Event tracking and logging

Tracker

Exports a TRACKER variable

Usage

import { initTracker, TRACKER } from 'request-tracker';
 
// initialize the tracker
requestTracker.initTracker(options);
 
// call track wherever you want to track events
requestTracker.TRACKER.track(options);

Functions

initTracker(options)

Initializes the TRACKER constant with supplied options Supports the following options:

version (string): version of the application you're tracking

url (string): The URL that the event logs will be posted to

context (string): a map of tracker-wide context values that will be added to each event

TRACKER.track(options)

Can be called inside routes or middleware functions with option values being functions of request objects (and additional middleware functions like morgan). These options will be added to the event entry. Supports the following options:

eventType (string): required type of event you're tracking for example 'login'

metric (string): required The name of the metric you're tracking

value (number): required The value of the metric you're tracking

user ({[k: string]: v: any}): JSON representation of a user on which you can specify attribute that will be written to the resulting event entry. Currently supported attribute are id and email

attr ({[k: string]: v: string}): Maps custom attribute names to string properties.

Logger

A small utility that ensures this is bound to the console object. Exports a LOGGER variable to interface with.

Usage

import { initLogger, LOGGER } from 'request-tracker';
 
initLogger();
 
LOGGER.log('hello');
LOGGER.warn('warning');
LOGGER.error('error');
 

Readme

Keywords

none

Package Sidebar

Install

npm i request-tracker

Weekly Downloads

6

Version

0.0.7

License

none

Last publish

Collaborators

  • evaimply