
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
errorception-hooks
Advanced tools
Errorception is a service that collects and reports JavaScript errors as they occur in your users' browsers. You might want real-time notifications about such errors as they happen. There could be several ways in which you might prefer to receive these notifications, maybe even using third-party tools and services. This repo houses a collection of such notification integrations – the service hooks.
Want your favorite service on Errorception? Create an issue, or even better, send a pull request. Contributions highly encouraged.
The hooks are ridiculously easy to implement. A typical hook implementation is just one function (onError
) with very few lines of code (usually just making an HTTP call). For example, the following code is a complete WebHooks implementation:
exports.onError = function(error, settings, done) {
request({
url: settings.url,
method: "post",
body: JSON.stringify(error)
}, done);
}
Check it out – the actual WebHook code in production use at Errorception isn't too different from this.
error
argumentThe error
argument contains information about the error, quite unsurprisingly. A typical error object looks as follows:
{
isInline: true,
message: "\"_WidgetManager\" is undefined",
userAgent: "Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; GT-I9100G Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
when: "after",
scriptPath: null,
page: "http://blog.rakeshpai.me/2007/02/ies-unknown-runtime-error-when-using.html",
date: "2012-11-12T15:31:02.576Z",
isFirstOccurrence: true,
webUrl: "http://errorception.com/projects/4e4b1652f384ef4d2d000002/errors/4ecc86a0fc68e61a1a06fdfc",
apiUrl: "https://api.errorception.com/projects/4e4b1652f384ef4d2d000002/errors/4ecc86a0fc68e61a1a06fdfc"
}
Depending on the service, different fields might be interesting. Probably the most interesting of the lot is the webUrl
key in the object, since it's a link to the error's details page in Errorception.
settings
argumentThe settings
argument contains configuration settings for the service. These settings are configured at the time of enabling the service in Errorception's settings.
The settings
object's specific keys and values depends on the service that's being implemented. For example, in the WebHook implementation, a service.url
key is available for use. The service.url
is populated by Errorception's settings UI. You would typically use settings
for things like API keys or security tokens – stuff that's different for each project and that you don't want to share publicly.
Currently, the settings UI (and consecutively the keys in the settings
object) is managed manually. That is, if you want to integrate a service hook, you'll have to send me a pull request, and I'll make the necessary UI to ensure that the settings
object has the keys you want. Details below.
The settings object's values are pre-validated so that the hook code can be minimal. The hooks neither need to validate the presence of keys nor the preferred format of their values.
done
argumentdone
is just a function that should be called when the job of making the service hook call is complete. This is the standard node.js style of notifying the caller that the function's task is complete.
Service hook contributions will be accepted for:
If you want a hook for a home-grown internal application that no one else might be interested in, you probably just want to use a WebHook.
Prerequisites: You will need to have git installed on your computer (get it here), and will need a GitHub account. You will also need a recent version of node.js (get it here).
hooks/
, for your hook code.index.js
file in this hooks/service-name
directory. Use the following template to get started:
var request = require("request");
exports.serviceName = "MyServiceName"; // Replace this with an appropriate value
exports.author = {
// Fill in as many fields as you can
name: "Your name",
email: "your.email@domain.com",
github: "yourGithubHandle",
twitter: "yourTwitterHandle"
};
exports.onError = function(error, settings, done) {
// Your code for the hook implementation goes here
}
Your personal details are required so that credit can be given where it's due, and so that there's a way to contact you in case the need arises.npm install
in the root of your clone directory.npm install --save <dependancy-name>
.README.md
file in hooks/service-name
with detailed documentation about your service hook. This file is used to render documentation in Errorception's UI when a user is enabling the service hook, so should consist of documentation of the fields that are needed to make the hook work.Once your pull request has been accepted and merged in, I'll manually make the UI for collecting the data you'd want in your copy of the settings
object. Once that's done, your hook will be live on Errorception. This process will only take a day or two.
You can use the simulate-hook.js
script from the command-line to simulate a service hook call. The usage is as follows:
$ node simulate-hook.js <service-name> '{"json": "settings"}'
service-name
is the name of the directory you've created in hooks/
.onError
as the settings
object.error-payload.json
.For example, when I was developing the webhook
service hook, I was using the following command.
$ node simulate-hook.js webhook '{"url": "http://localhost:5555/hook"}'
Combine that with nc -l 5555
on a different shell, and I could see the WebHook's HTTP POST coming to my settings.url
. Easy peasy!
MIT
FAQs
Service hooks for Errorception
We found that errorception-hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.