Adds Rapid7 InsightOps hooks to React
| Statements | Branches | Functions | Lines |
|---|---|---|---|
npm install --save react-use-rapid7- 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 } |
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}`)
);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.
Thanks goes to these wonderful people (emoji key):
Olavo Parno 🤔 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
react-use-rapid7 is MIT licensed.
This hook is created using create-react-hook.