logger-tracker
v0.0.23
Published
tracks and logs
Downloads
30
Readme
Logger tracker
Event tracking and logging
Tracker
Exports a TRACKER
variable
Usage
import { TRACKER } from 'request-tracker';
// initialize the tracker
TRACKER.init(options);
// call track wherever you want to track events
TRACKER.track(options);
Functions
####TRACKER.init(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 { LOGGER } from 'request-tracker';
LOGGER.init();
LOGGER.log('hello');
LOGGER.warn('warning');
LOGGER.error('error');