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
Property | Type | Description |
---|---|---|
name | string | The name of the client, this can be the app or service name. |
apiKey | string | The 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. |
options | object | All 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
Property | Type | Default | Description |
---|---|---|---|
hookExceptions | boolean | true | If this is true, any uncaught exceptions across your application and dependencies will be sent as an event. |
waitForResponse | boolean | true | if 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. |
timeout | number | 5000ms | The 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. |
dev | boolean | false | If this is true, no events will be sent to the server. This is useful for development and testing. |
devWarning | boolean | true | If this is true, a warning will be logged when developer mode is activated and an event was attempted to be sent. |