@kametventures/metrics

## Install

Stats

StarsIssuesVersionUpdatedCreatedSize
@kametventures/metrics
0.1.44 years ago4 years agoMinified + gzip package size for @kametventures/metrics in KB

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:

  1. 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'}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.