@kametventures/metrics

0.1.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @kametventures/metrics

Weekly Downloads

5

Version

0.1.4

License

none

Unpacked Size

42.5 kB

Total Files

32

Last publish

Collaborators

  • alistairstead
  • sroze