Skip to content

Adds Rapid7 InsightOps hooks to React to keep track of your application

License

Notifications You must be signed in to change notification settings

olavoparno/react-use-rapid7

Repository files navigation

traffic

react-use-rapid7

Adds Rapid7 InsightOps hooks to React

NPM


Statements Branches Functions Lines
Statements Branches Functions Lines

Table of Contents


Install

npm install --save react-use-rapid7

Usage

  • You can just call for useRapid7 hook and expect the following parameters:
key description example
token Rapid7's API key 29189s8asa-skajskj1298sas-kjsaksjak92
rapid7's optional config Other extra config { print: true }

Examples

const logger = useRapid7('sas1209-cdbb-4afc-b10f-2198sasak', {
  print: true,
});

aSimplePromise()
  .then(() => logger.info('aSimplePromise has been resolved'))
  .catch((error) =>
    logger.error(`aSimplePromise has errored with ${error.message}`)
  );

Documentation

useRapid7() returns a logger with the following methods:

type MessageHandler = (
  message: string | Record<string & number & symbol, string> | Error
) => void;

type LoggersClientReturn = {
  warn: MessageHandler;
  error: MessageHandler;
  info: MessageHandler;
  log: MessageHandler;
};

You can use a simple string or an object for the message.


Contributors

Thanks goes to these wonderful people (emoji key):

Olavo Parno
Olavo Parno

🤔 💻 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!


License

react-use-rapid7 is MIT licensed.


This hook is created using create-react-hook.