0.1.4 • Published 6 years ago

@kametventures/metrics v0.1.4

Weekly downloads
-
License
-
Repository
-
Last release
6 years ago

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

NameDescriptionRequired
tokenYour authentication token to the collection APIYes
apiBaseUrlBase URL used for the API.No
globalAttributesList of attributes to be added to every sent event.Example: {user: 'username', release: 'something'}
0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago