insomnia-plugin-usage-logger
Advanced tools
Comparing version 1.0.3 to 1.0.5
{ | ||
"name": "insomnia-plugin-usage-logger", | ||
"version": "1.0.3", | ||
"version": "1.0.5", | ||
"description": "An Insomnia plugin for logging request and response details using Resurface. More info at: https://resurface.io", | ||
"main": "./src/plugin.js", | ||
"files": ["src", "test", "assets/plugin"], | ||
"files": [ | ||
"src", | ||
"test", | ||
"assets/plugin" | ||
], | ||
"scripts": { | ||
@@ -46,3 +50,3 @@ "test": "mocha --reporter spec --timeout 10000 --full-trace" | ||
"publisher": { | ||
"name": "Resurface Labs", | ||
"name": "resurface.io", | ||
"icon": "https://raw.githubusercontent.com/resurfaceio/insomnia-plugin/master/assets/plugin/icon-alt.svg" | ||
@@ -49,0 +53,0 @@ }, |
# Resurface Insomnia Plugin | ||
Easily log API requests and responses to your own <a href="https://resurface.io">security data lake</a>. | ||
Log API requests and responses made with Insomnia to your own <a href="https://resurface.io">system of record</a>. | ||
[![License](https://img.shields.io/github/license/resurfaceio/insomnia-plugin)](https://github.com/resurfaceio/insomnia-plugin/blob/master/LICENSE) | ||
[![Contributing](https://img.shields.io/badge/contributions-welcome-green.svg)](https://github.com/resurfaceio/insomnia-plugin/blob/master/CONTRIBUTING.md) | ||
@@ -14,10 +16,19 @@ ## Requirements | ||
<img src="https://github.com/resurfaceio/insomnia-plugin/raw/master/assets/readme/install_plugin.gif" width="768" height="400" /> | ||
<img src="https://github.com/resurfaceio/insomnia-plugin/raw/master/assets/readme/install_plugin.gif" width="768" height="400" /> | ||
(Alternatively, check out the [manual installation](#manual-installation).) | ||
- Create a new Environment to store the [variables](#environment-variables) used by the logger. | ||
(Alternatively, check out the [manual installation](#manual-installation).) | ||
<img src="https://github.com/resurfaceio/insomnia-plugin/raw/master/assets/readme/insomnia_env.gif" width="768" height="400" /> | ||
- Add the [variables](#environment-variables) used by the logger to your Base Environment (or create a separate new Sub Environment for them). | ||
```json | ||
{ | ||
"USAGE_LOGGERS_URL": "http://localhost:7701/message", | ||
"USAGE_LOGGERS_RULES": "include debug" | ||
} | ||
``` | ||
<img src="https://github.com/resurfaceio/insomnia-plugin/raw/master/assets/readme/insomnia_env.gif" width="768" height="400" /> | ||
That's it! | ||
@@ -27,8 +38,12 @@ | ||
- Make sure to select the [environment you created before](#set-up) (also, make sure the plugin is enabled). | ||
- Make sure the plugin is enabled (also, if you created a new sub environment make sure to select it). | ||
- Use Insomnia as you would normally. | ||
- Go to `http://localhost:7700` to explore all your logs using the included <a href="https://resurface.io#explore">API Explorer</a> | ||
<img src="https://github.com/resurfaceio/insomnia-plugin/raw/master/assets/readme/insomnia_usage.gif" width="768" height="400" /> | ||
<img src="https://github.com/resurfaceio/insomnia-plugin/raw/master/assets/readme/insomnia_usage.gif" width="768" height="400" /> | ||
- You can always disable the plugin if you want stop logging API calls temporarily | ||
<img src="https://github.com/resurfaceio/insomnia-plugin/raw/master/assets/readme/insomnia_disable.gif" width="768" height="400" /> | ||
Happy loggin' 📝 | ||
@@ -38,15 +53,13 @@ | ||
This plugin has access to three environment variables, but only one them is required for the logger to work properly. | ||
This plugin has access to four environment variables, but only one them is required for the logger to work properly. | ||
#### ✔ All API calls are sent to the database running inside the docker container | ||
The environment variable `USAGE_LOGGERS_URL` stores this address, which by default should be `http://localhost:7701/message` | ||
The environment variable `USAGE_LOGGERS_URL` stores this address, which by default should be the string `"http://localhost:7701/message"` | ||
#### ✔ All API calls are filtered using a set of rules (Optional) | ||
The environment variable `USAGE_LOGGERS_RULES` stores these rules. [Learn more](#protecting-user-privacy) | ||
#### ✔ What if I want to disable the Logger? (Optional) | ||
You can! By setting the environment variable `USAGE_LOGGERS_DISABLE` to `true` the logger will be disabled and no API calls will be logged. | ||
The environment variable `USAGE_LOGGERS_RULES` stores these [logging rules](#protecting-user-privacy) as a string. Even though this variable is optional, it is recommended to set it to `"include debug"` or `"allow_http_url"` when trying the plugin for the first time. | ||
#### ✔ Reponse bodies are logged up to a certain size (Optional) | ||
If you are working with large response payloads and don't want to log the whole thing, you can use the environment variable `USAGE_LOGGERS_LIMIT`. It stores an integer value corresponding to the number of bytes after which a response body will not be logged (by default, this upper limit is 1 MiB). | ||
#### ✔ The Logger can be disabled even if the plugin is enabled (Optional) | ||
By setting the environment variable `USAGE_LOGGERS_DISABLE` to `true` the logger will be disabled and no API calls will be logged. | ||
In addition, if you're not using any other environment variables, you can just disable the environment and no API calls will be logged until you select the environment again. | ||
<img src="https://github.com/resurfaceio/insomnia-plugin/raw/master/assets/readme/insomnia_env_disable.gif" width="768" height="400" /> | ||
## Manual installation | ||
@@ -69,2 +82,2 @@ | ||
--- | ||
<small>© 2016-2022 <a href="https://resurface.io">Resurface Labs Inc.</a></small> | ||
<small>© 2016-2024 <a href="https://resurface.io">Graylog, Inc.</a></small> |
@@ -1,2 +0,2 @@ | ||
// © 2016-2022 Resurface Labs Inc. | ||
// © 2016-2024 Graylog, Inc. | ||
@@ -79,3 +79,3 @@ const { | ||
if (response_body.length > environment.body_limit) { | ||
response_body = `{"overflowed: ${response_body.length}"}`; | ||
response_body = `{"overflowed": "${response_body.length}"}`; | ||
} else { | ||
@@ -82,0 +82,0 @@ response_body = response_body.toString(); |
@@ -1,2 +0,2 @@ | ||
// © 2016-2021 Resurface Labs Inc. | ||
// © 2016-2024 Graylog, Inc. | ||
@@ -3,0 +3,0 @@ module.exports = { |
@@ -1,2 +0,2 @@ | ||
// © 2016-2021 Resurface Labs Inc. | ||
// © 2016-2024 Graylog, Inc. | ||
@@ -7,6 +7,13 @@ const { expect } = require('chai'); | ||
function getContext() { | ||
const context = { | ||
"USAGE_LOGGERS_QUEUE": [], | ||
"app": { | ||
getInfo() { | ||
return { | ||
"version": "test", | ||
"platform": "test" | ||
} | ||
} | ||
}, | ||
"request": { | ||
@@ -88,4 +95,4 @@ environment: { | ||
expect(msg).to.contain("[\"interval\",\""); | ||
expect(msg).to.contain("[\"request_header:user-agent\",\"insomnia/test\"]"); | ||
expect(msg).to.not.contain("request_body"); | ||
expect(msg).to.not.contain("request_header"); | ||
expect(msg).to.not.contain("request_param"); | ||
@@ -107,2 +114,3 @@ expect(msg).to.not.contain("response_body"); | ||
expect(msg).to.contain("[\"request_url\",\"" + helper.MOCK_URL + "\"]"); | ||
expect(msg).to.contain("[\"request_header:user-agent\",\"insomnia/test\"]"); | ||
expect(msg).to.contain("[\"response_body\",\"" + helper.MOCK_HTML + "\"]"); | ||
@@ -113,3 +121,2 @@ expect(msg).to.contain("[\"response_code\",\"200\"]"); | ||
expect(msg).to.not.contain("request_body"); | ||
expect(msg).to.not.contain("request_header"); | ||
expect(msg).to.not.contain("request_param"); | ||
@@ -129,2 +136,3 @@ }); | ||
expect(msg).to.contain("[\"request_url\",\"" + helper.MOCK_URL + '?' + helper.MOCK_QUERY_STRING + "\"]"); | ||
expect(msg).to.contain("[\"request_header:user-agent\",\"insomnia/test\"]"); | ||
expect(msg).to.contain("[\"request_header:content-type\",\"Application/JSON\"]"); | ||
@@ -149,2 +157,3 @@ expect(msg).to.contain("[\"request_body\",\"" + helper.MOCK_JSON_ESCAPED + "\"]"); | ||
expect(msg).to.contain("[\"request_url\",\"" + helper.MOCK_URL + '?' + helper.MOCK_QUERY_STRING + "\"]"); | ||
expect(msg).to.contain("[\"request_header:user-agent\",\"insomnia/test\"]"); | ||
expect(msg).to.contain("[\"request_header:content-type\",\"Application/JSON\"]"); | ||
@@ -151,0 +160,0 @@ expect(msg).to.contain("[\"request_header:a\",\"1, 2\"]"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
75958
316
80