open-index/open-npm huggingface dataset:
npm package: @kametventures/metrics
Description: ## Install
Latest version: 0.1.4

# Metrics JavaScript client

## Install

```
npm install --save @kametventures/metrics
```

## Configure

```javascript
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

```javascript
import collectorFactory from '@kametventures/metrics/koa/collector';

app.use(collectorFactory(client));
```

You can use the 2nd argument to give a set of options:
```javascript
app.use(collectorFactory(client, options))
```

The supported options are:

1. `additionalAttributes`. <br>
   A function that returns a key-value pair of additional attributes to be sent.

#### Exposing your routes

_When using [koa-router](https://github.com/alexmingoia/koa-router)_

```javascript
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.<br><br>**Example:** `{user: 'username', release: 'something'}`