@kametventures/metrics
v0.1.4
Published
## Install
Downloads
14
Readme
Metrics JavaScript client
Install
npm install --save @kametventures/metrics
Configure
import { createClient } from '@kametventures/metrics/client/factory';
const client = createClient({
token: 'ez1234...'
});
See the reference for all the configuration options.
Plug into your framework
Koa
Collecting metrics
import collectorFactory from '@kametventures/metrics/koa/collector';
app.use(collectorFactory(client));
You can use the 2nd argument to give a set of options:
app.use(collectorFactory(client, options))
The supported options are:
additionalAttributes
. A function that returns a key-value pair of additional attributes to be sent.
Exposing your routes
When using koa-router
import Router from 'koa-router';
import routesFactory from '@kametventures/metrics/koa/routes';
const router = new Router();
// You register all your routes...
app.use(routesFactory(router));
References
Configuration options
Name | Description | Required
-----|-------------|---------
token
| Your authentication token to the collection API | Yes
apiBaseUrl
| Base URL used for the API. | No
globalAttributes
| List of attributes to be added to every sent event.Example: {user: 'username', release: 'something'}