Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Automatically log any errors happening in your app!
Browlog is simply just an extension which instantly post to any specified reporter(s).
This means, this extension doesn't have a dashboard like other monitoring tools since this is a very lightweight error logger by utilizing error events.
If this is enough for your needs, then let's get started!
npm i browlog
Browlog uses singleton approach, you need to call the init
as following:
import browlog from 'browlog';
import slackReporter from 'browlog/reporters/slack';
browlog({
reporters: [
slackReporter('<webhook_url>'),
]
});
Browlog will start to listen to any errors happening in your app. Hence, I would suggest to init browlog as early as possible.
Also please remember that this is only for client-side logger, if this code also runs in server (SSR / prerender), you should not init browlog when the code is running in server.
You can import any existing reporters (or create your own), by importing from this path:
import reporter from 'browlog/reporters/<supported_reporter>';
List of currently supported reporters:
'browlog/reporters/slack'
)'browlog/reporters/teams'
)Note: If you don't specify any reporters, browlog will be disabled automatically.
You can add app name to make distinct the logger between one and another. Follow the example below:
import browlog from 'browlog';
import teamsReporter from 'browlog/reporters/teams';
browlog({
reporters: [
teamsReporter('<webhook_url>', {
appName: 'My App', // "appName" will not be combined with "Log" object.
environment: 'staging' // Other keys will be combined with "Log" object
}),
]
});
App name treatment is valid to all types of reporters.
You can, however, add your own custom reporter as such:
const customReporter = (log) => {
// do anything
// as long as you return a promise here.
};
...
browlog({
reporters: [
customReporter,
]
});
You can check what is a Log
object from the typings:
interface Log {
type: string; // event type, could be window:onerror, etc.
referrer: string;
userAgent: string;
timestamp: number; // unix timestamp
time: string; // humanized timestamp, Asia/Jakarta as timezone
href: string;
messages: string[];
}
Below are available options for browlog initialization:
/**
* An array of promises generated from fetch after chain process a log request.
*
* Read more about it here:
* https://github.com/josteph/browlog#reporters
*/
reporters: ((...data: any[]) => void)[];
/**
* Prevent browlog from init & attaching event listeners.
*
* You can call another `browlog.init()` again somewhere.
*/
disable?: boolean;
/**
* An array of regex to filter out unnecessary errors from being logged.
*
* For example:
*
* `[/Message\: Script error\./, /Vue warn/, /Service worker/]`
*/
ignoreErrors?: RegExp[];
/**
* Debounce threshold for the logger to be queued before sending them in parallel.
*
* Default value is `2000` (in ms)
*/
threshold?: number;
FAQs
Instant error reporting from browser to your webhook channel of choice
We found that browlog 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.