prodap-master-metrics
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Prodap Master Metrics

This library was created for collecting metrics from Prodap Views Master.

Installation

$ npm install prodap-master-metrics

Usage

To use it you will need a service account key from prodap-x project on GCP.

There are two ways to use Prodap Master Metrics.

First way is using the logEvent function. This function receives a event object as parameter and send it to a PubSub topic on GCP.

import {ProdapMasterMetrics, Event, EventType} from 'prodap-master-metrics'

const prodapMasterMetrics = new ProdapMasterMetrics({
    projectId: 'prodap-x',
    keyFilename: '../../prodap-x-123456.json',
    topicName: 'metricas_master',
    disabled: false
})

/*
Code code code
*/

const event: Event = {
    event: EventType.VISUALIZA_COLETA_SAL,
    eventDate: new Date(),
    farmId: 1,
    userId: 1,
    user: 'user',
    userEmail: 'user@email.com',
    route: '/api/route'
}

prodapMasterMetrics.logEvent(event)

The second way to use it is using the logEventMiddleware. This middleware receives an EventType as parameter and returns a Express.js middleware function.

import {ProdapMasterMetrics, Event, EventType} from 'prodap-master-metrics'

const prodapMasterMetrics = new ProdapMasterMetrics({
    projectId: 'prodap-x',
    keyFilename: '../../prodap-x-123456.json',
    topicName: 'metricas_master',
    disabled: false
})

/*
Code code code
*/

router.get(
    '/supplementations',
    prodapMasterMetrics.logEventMiddleware(EVENTS.LIST_SUPPLEMENTATIONS)
    supplementationController.find
);

Readme

Keywords

none

Package Sidebar

Install

npm i prodap-master-metrics

Weekly Downloads

10

Version

1.1.0

License

ISC

Unpacked Size

21.2 kB

Total Files

44

Last publish

Collaborators

  • heitor-prodap