How To Use In Project

Once you have installed the package you can start using it in your project!

Importing the Package

To import the SDK you can use the following code:

import { Monitro } from 'monitro'

Creating a new client

To create a new client you can use the following code:

const monitroClient = new Monitro('monitro-dev', API_KEY, 
{ hookExceptions: true,
 waitForResponse: true,
 timeout: 5000 });

What does the client expect?

The monitro client expects the following:

Parameters

PropertyTypeDescription
namestringThe name of the client, this can be the app or service name.
apiKeystringThe API key, this can be found on the monitro dashboard once a valid subscription has been purchased, please keep the private for now as we are working on public API keys.
optionsobjectAll of these option are optional, but we reccomend you think about if you want to enable them as they can have a big impact on how you use the client.

Options

PropertyTypeDefaultDescription
hookExceptionsbooleantrueIf this is true, any uncaught exceptions across your application and dependencies will be sent as an event.
waitForResponsebooleantrueif this is false the function will not wait for a response and will always be successful even if the event fails, for example invalid api key, only use this if you really care about the response hanging.
timeoutnumber5000msThe timeout for the request to the monitro servers, adjust this as you wish, but keep in mind that if you set it too low, you may not get the event sent to monitro.
devbooleanfalseIf this is true, no events will be sent to the server. This is useful for development and testing.
devWarningbooleantrueIf this is true, a warning will be logged when developer mode is activated and an event was attempted to be sent.