Are you over 18 and want to see adult content?
More Annotations
A complete backup of https://vistarmedia.com
Are you over 18 and want to see adult content?
A complete backup of https://fc-sion.ch
Are you over 18 and want to see adult content?
A complete backup of https://oldracingcars.com
Are you over 18 and want to see adult content?
A complete backup of https://openvallejo.org
Are you over 18 and want to see adult content?
A complete backup of https://dupagechildrensmuseum.org
Are you over 18 and want to see adult content?
A complete backup of https://fareasthospitality.com
Are you over 18 and want to see adult content?
A complete backup of https://spearmintlove.com
Are you over 18 and want to see adult content?
A complete backup of https://getcleartouch.com
Are you over 18 and want to see adult content?
A complete backup of https://creditas.com.br
Are you over 18 and want to see adult content?
A complete backup of https://over-board.co.uk
Are you over 18 and want to see adult content?
Favourite Annotations
A complete backup of gwen-howard-644b.squarespace.com
Are you over 18 and want to see adult content?
A complete backup of simplelivingcreativelearning.com
Are you over 18 and want to see adult content?
A complete backup of adaddanuarta.blogspot.com
Are you over 18 and want to see adult content?
A complete backup of hunksofbeef.tumblr.com
Are you over 18 and want to see adult content?
A complete backup of jornalmeuemprego.com.br
Are you over 18 and want to see adult content?
Text
Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND The best JavaScript and Node.js logging service and logging npm package - Cabin. Cabin is the best JavaScript and Node.js logging service and logging npm package. Supports Node v6.4+, Browsers (IE 10+), Express, Koa, and Lad. Cabin is a drop-in replacement and the best alternative to Sentry, Timber, Airbrake, Papertrail, Loggly,Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE The best JavaScript and Node.js logging service and logging npm package - Cabin. Cabin is the best JavaScript and Node.js logging service and logging npm package. Supports Node v6.4+, Browsers (IE 10+), Express, Koa, and Lad. Cabin is a drop-in replacement and the best alternative to Sentry, Timber, Airbrake, Papertrail, Loggly,Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND The best JavaScript and Node.js logging service and logging npm package - Cabin. Cabin is the best JavaScript and Node.js logging service and logging npm package. Supports Node v6.4+, Browsers (IE 10+), Express, Koa, and Lad. Cabin is a drop-in replacement and the best alternative to Sentry, Timber, Airbrake, Papertrail, Loggly,Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND The best JavaScript and Node.js logging service and logging npm package - Cabin. Cabin is the best JavaScript and Node.js logging service and logging npm package. Supports Node v6.4+, Browsers (IE 10+), Express, Koa, and Lad. Cabin is a drop-in replacement and the best alternative to Sentry, Timber, Airbrake, Papertrail, Loggly,Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE The best JavaScript and Node.js logging service and logging npm package - Cabin. Cabin is the best JavaScript and Node.js logging service and logging npm package. Supports Node v6.4+, Browsers (IE 10+), Express, Koa, and Lad. Cabin is a drop-in replacement and the best alternative to Sentry, Timber, Airbrake, Papertrail, Loggly,Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND The best JavaScript and Node.js logging service and logging npm package - Cabin. Cabin is the best JavaScript and Node.js logging service and logging npm package. Supports Node v6.4+, Browsers (IE 10+), Express, Koa, and Lad. Cabin is a drop-in replacement and the best alternative to Sentry, Timber, Airbrake, Papertrail, Loggly,Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND The best JavaScript and Node.js logging service and logging npm package - Cabin. Cabin is the best JavaScript and Node.js logging service and logging npm package. Supports Node v6.4+, Browsers (IE 10+), Express, Koa, and Lad. Cabin is a drop-in replacement and the best alternative to Sentry, Timber, Airbrake, Papertrail, Loggly,Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND The best JavaScript and Node.js logging service and logging npm package - Cabin. Cabin is the best JavaScript and Node.js logging service and logging npm package. Supports Node v6.4+, Browsers (IE 10+), Express, Koa, and Lad. Cabin is a drop-in replacement and the best alternative to Sentry, Timber, Airbrake, Papertrail, Loggly,Bugsnag, or
THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. THE BEST JAVASCRIPT AND NODE.JS LOGGING SERVICE AND Cabin is a drop-in replacement and alternative to Sentry, Timber, Airbrake, Papertrail, Loggly, Bugsnag, or . Built by @niftylettuce. * The best JavaScript and Node.js logging service and logging npmpackage
* Table of Contents
* Quick Start
* Features
* Security, Privacy, and Business Focused * Reduce Disk Storage Costs * Cross-Platform and Cross-Browser Compatible * Integrate with Slack Using Custom Logging Hooks * Bring Your Own Logger ("BYOL") * Save Time With Easy Debugging* Install
* Usage
* Logging
* Route Middleware
* Node
* Koa
* Express
* Convenience Methods* Express
* Koa
* Browser
* VanillaJS
* Required Browser Features* Bundler
* Automatic Request Logging* Server
* Browser
* HTML
* Pug
* Bundler
* Stack Traces and Error Handling* Node
* Browser
* StackTrace
* TraceKit
* Automatic Try Catch Wrapping* Gulp
* Webpack
* Display Metadata and Stack Traces * Show/Hide Metadata * Show/Hide Stack Traces* Options
* Metadata
* Related
* Contributors
* Trademark Notice
* License
CABIN
* The best JavaScript and Node.js logging service and logging npmpackage
Cabin is the best JavaScriptand Node.js
logging service
and logging npm
package
Supports Node v6.4+, Browsers (IE 10+), Express, Koa , and Lad
------------------------- Cabin is a drop-in replacement for Sentry , Timber , Airbrake , Papertrail, Loggly ,
Bugsnag , orFOSS
on
Patreon or PayPal
🦄
TABLE OF CONTENTS
* Quick Start
* Features
* Security, Privacy, and Business Focused * Reduce Disk Storage Costs * Cross-Platform and Cross-Browser Compatible * Integrate with Slack Using Custom Logging Hooks * Bring Your Own Logger ("BYOL") * Save Time With Easy Debugging* Install
* Usage
* Logging
* Route Middleware
* Node
* Browser
* Automatic Request Logging * Stack Traces and Error Handling * Display Metadata and Stack Traces * Show/Hide Metadata * Show/Hide Stack Traces* Options
* Metadata
* Related
* Contributors
* Trademark Notice
* License
QUICK START
npm install cabin
const express = require('express'); const Cabin = require('cabin'); // <-- step 1 const app = express(); const cabin = new Cabin(); // <-- step 2 app.use(cabin.middleware); // <-- step 3app.listen(3000);
> See our USAGE SECTION BELOW for a much more detailed and > feature-rich example setup.FEATURES
SECURITY, PRIVACY, AND BUSINESS FOCUSED Cabin will automatically detect and mask the following list of extremely sensitive types of data in your logs: * 1600+ Sensitive Field Names * Credit Card Numbers** BasicAuth Headers
* Social Security Numbers * JSON Web Tokens ("JWT") * API Keys, CSRF Tokens, and Stripe Tokens * Passwords, Salts, and Hashes * Bank Account Numbers and Bank Routing Numbers > *Credit card numbers from the following providers are automatically > detected and masked: Visa, Mastercard, American Express, Diners > Club, Discover, JCB, UnionPay, Maestro, Mir, Elo, Hiper, Hipercard REDUCE DISK STORAGE COSTS Reduce your disk storage costs through Cabin's automatic conversion of Streams, Buffers, and ArrayBuffers to simplified, descriptive-only objects that otherwise would be unreadable (and obviously pollute your log files and disk storage).> Before:
{
"request": {
"body": {
"file": {
"type": "Buffer",
"data":
}
}
}
}
> After
{
"request": {
"body": {
"file": {
"type": "Buffer",
"byteLength": 2787
}
}
}
}
CROSS-PLATFORM AND CROSS-BROWSER COMPATIBLE Cabin works with the most popular Node.js HTTP frameworks (e.g. Express and Koa ), request body handling packages (e.g. multerand body-parser
), and the passport
authentication framework. It supports NODE V6.4+ and IE 10+ out of the box, and its browser-ready bundle IS ONLY 36 KB (minified and gzipped).npx browserslist
and_chr 74
and_ff 66
and_qq 1.2
and_uc 11.8
android 67
baidu 7.12
bb 10
bb 7
chrome 74
chrome 73
chrome 72
edge 18
edge 17
firefox 66
firefox 65
ie 11
ie 10
ie_mob 11
ie_mob 10
ios_saf 12.2
ios_saf 12.0-12.1
kaios 2.5
op_mini all
op_mob 46
op_mob 12.1
opera 58
opera 57
safari 12.1
safari 12
samsung 9.2
samsung 8.2
INTEGRATE WITH SLACK USING CUSTOM LOGGING HOOKS Axe is the underlying logging add-on that allows you to record, store, back-up, and customize your log handling over HTTP or with your own custom logic. You will find an entire example for logging errors (and more) to your Slack channel under its section Send Logs To Slack.
BRING YOUR OWN LOGGER ("BYOL") Cabin was built by an expert based off best practices; over a decade of experience in logging and application development – and most importantly from their agony with existing tools, services, packages,and platforms.
It was made to be both a SIMPLE AND QUICK DROP-IN REPLACEMENT for existing services. YOU CAN EVEN BRING YOUR OWN LOGGER! Want to use Axe, pino
, signale
, morgan
, bunyan
, winston
, or another logger? No problem. SAVE TIME WITH EASY DEBUGGING No need for rubber duck debugging – Cabin makes everything transparent at a glance. Rich metadata is automatically added to your logs, so that you can easily record, analyze, and detect user behavior and application events, errors, and more: > Example Application: const express = require('express'); const Cabin = require('cabin'); const multer = require('multer'); const requestReceived = require('request-received'); const responseTime = require('response-time'); const requestId = require('express-request-id'); const app = express(); const cabin = new Cabin(); const upload = multer(); app.use(requestReceived); app.use(responseTime()); app.use(requestId()); app.use(cabin.middleware);app.post(
'/',
upload.fields(),
(req, res) => {
req.logger.info('visited home page'); res.send('hello world');}
});
app.listen(3000);
> Example Console Output (using Signale> ):
ℹ info visited home page { id: '5d1b9e484ebd2adcdfd29bf4', timestamp: '2019-07-02T18:11:20.000Z',request:
{ method: 'POST',
query: { foo: 'bar', beep: 'boop' },headers:
{ host: '127.0.0.1:55370', 'accept-encoding': 'gzip, deflate', 'user-agent': 'node-superagent/3.8.3', authorization: 'Basic ********************', accept: 'application/json', cookie: 'foo=bar;beep=boop','content-type':
'multipart/form-data; boundary=--------------------------028474125060986605281677', 'content-length': '1599', connection: 'close' }, cookies: { foo: 'bar', beep: 'boop' }, url: '/?foo=bar&beep=boop',body:
'{"product_id":"5d0350ef2ca74d11ee6e4f00","name":"nifty","surname":"lettuce","bank_account_number":"**********","card":{"number":"****-****-****-****"},"stripe_token":"***************","favorite_color":"green"}', timestamp: '2019-07-02T18:11:20.331Z', id: '33afc3c5-1571-4249-b024-876b6f687b65', http_version: '1.1',files:
'{"avatar":,"boop":}' }, user: { ip_address: '::ffff:127.0.0.1' }, duration: 1.741299,app:
{ name: 'parse-request',version: '2.0.1',
node: 'v10.15.3',
hash: '75783ef9d0a9c1c71f83ee352754a14ead0a3138',tag: 'v2.0.1',
environment: 'test', hostname: 'jacks-MacBook-Pro.local',pid: 56543 } }
ℹ info ::ffff:127.0.0.1 user POST /?foo=bar&beep=boop HTTP/1.1 200 1951 - 67.819 ms { id: '5d1b9e484ebd2adcdfd29bf5', timestamp: '2019-07-02T18:11:20.000Z',request:
{ method: 'POST',
query: { foo: 'bar', beep: 'boop' },headers:
{ host: '127.0.0.1:55370', 'accept-encoding': 'gzip, deflate', 'user-agent': 'node-superagent/3.8.3', authorization: 'Basic ********************', accept: 'application/json', cookie: 'foo=bar;beep=boop','content-type':
'multipart/form-data; boundary=--------------------------028474125060986605281677', 'content-length': '1599', connection: 'close' }, cookies: { foo: 'bar', beep: 'boop' }, url: '/?foo=bar&beep=boop',body:
'{"product_id":"5d0350ef2ca74d11ee6e4f00","name":"nifty","surname":"lettuce","bank_account_number":"**********","card":{"number":"****-****-****-****"},"stripe_token":"***************","favorite_color":"green"}', timestamp: '2019-07-02T18:11:20.331Z', id: '33afc3c5-1571-4249-b024-876b6f687b65', http_version: '1.1',files:
'{"avatar":,"boop":}' }, user: { ip_address: '::ffff:127.0.0.1' },response:
{ headers:
{ 'x-request-id': '33afc3c5-1571-4249-b024-876b6f687b65', 'content-type': 'application/json; charset=utf-8', 'content-length': '1951', 'x-response-time': '67.819ms', date: 'Tue, 02 Jul 2019 18:11:20 GMT', connection: 'close' }, http_version: '1.1',status_code: 200,
reason_phrase: 'OK', timestamp: '2019-07-02T18:11:20.000Z', duration: 67.819 }, duration: 2.320237,app:
{ name: 'parse-request',version: '2.0.1',
node: 'v10.15.3',
hash: '75783ef9d0a9c1c71f83ee352754a14ead0a3138',tag: 'v2.0.1',
environment: 'test', hostname: 'jacks-MacBook-Pro.local',pid: 56543 } }
INSTALL
npm :
npm install cabin
yarn :
yarn add cabin
USAGE
> Don't want to configure this yourself? You can simply use Lad > which has this all built-in for you.LOGGING
const Cabin = require('cabin'); const cabin = new Cabin(); cabin.info('hello world'); cabin.error(new Error('oops!')); Each log level should be invoked with two arguments message and meta. * message (String or Error) - this should be either a String or anError object
* meta (Object or Error) - this is optional and will automatically be set to an object that inherits properties from config.meta and requests parsed. If this is an Error object, then this error will be automatically added and transformed to the meta object's meta.err property (e.g. { err:ROUTE MIDDLEWARE
app.use(cabin.middleware); See either the Node or Browser instructions below for further route middleware usage and proper setup.NODE
> The examples below show how to use Cabin in combination with Axe> , Signale
> logging utility (for > development), Pino logging utility > (for production), and how to add an accurate X-Response-Time > response time metric to your logs and response headers> automatically.
KOA
> Don't want to configure this yourself? We HIGHLY RECOMMEND to use > Lad instead of configuring this yourself as it > has all of this pre-configured for you with best-practices. However > if you already have an existing Koa based > project the example below will sufficiently serve as a guide for> implementation.
*
Install required and recommended dependencies: npm install koa cabin signale pino request-received response-time koa-connect express-request-id*
Implement the example code below (also found here ): const Koa = require('koa'); const Cabin = require('cabin'); const Router = require('koa-router'); const koaConnect = require('koa-connect'); const requestReceived = require('request-received'); const responseTime = require('response-time'); const requestId = require('express-request-id'); const { Signale } = require('signale'); const pino = require('pino')({customLevels: {
log: 30
}
});
const env = process.env.NODE_ENV || 'development'; const app = new Koa(); const router = new Router(); const cabin = new Cabin({ // (optional: your free API key from https://cabinjs.com) // key: 'YOUR-CABIN-API-KEY',axe: {
logger: env === 'production' ? pino : new Signale()}
});
// adds request received hrtime and date symbols to request object // (which is used by Cabin internally to add `request.timestamp` to logs app.use(requestReceived); // adds `X-Response-Time` header to responses app.use(koaConnect(responseTime())); // adds or re-uses `X-Request-Id` header app.use(koaConnect(requestId())); // use the cabin middleware (adds request-based logging and helpers) app.use(cabin.middleware); // add your user/session management middleware here (e.g. passport)// ...
// an example home page route router.get('/', ctx => { ctx.logger.info('visited home page'); ctx.body = 'hello world';});
// this assumes that you are using passport which // exposes `ctx.logout` to log out the logged in user router.get('/logout', ctx => { ctx.logger.warn('Logged out');ctx.logout();
ctx.redirect('/');
});
app.use(router.routes()); app.use(router.allowedMethods()); app.listen(3000, () => { cabin.info('app started');});
*
See Koa convenience methods below for helper utilities you can usewhile writing code.
EXPRESS
*
Install required and recommended dependencies: npm install koa cabin signale pino request-received response-time express-request-id*
Implement the example code below (also found here):
const express = require('express'); const Cabin = require('cabin'); const requestReceived = require('request-received'); const responseTime = require('response-time'); const requestId = require('express-request-id'); const { Signale } = require('signale'); const pino = require('pino')({customLevels: {
log: 30
}
});
const env = process.env.NODE_ENV || 'development'; const app = express(); const cabin = new Cabin({ // (optional: your free API key from https://cabinjs.com) // key: 'YOUR-CABIN-API-KEY',axe: {
logger: env === 'production' ? pino : new Signale()}
});
// adds request received hrtime and date symbols to request object // (which is used by Cabin internally to add `request.timestamp` to logs app.use(requestReceived); // adds `X-Response-Time` header to responses app.use(responseTime()); // adds or re-uses `X-Request-Id` header app.use(requestId()); // use the cabin middleware (adds request-based logging and helpers) app.use(cabin.middleware); // add your user/session management middleware here (e.g. passport)// ...
// an example home page route app.get('/', (req, res) => { req.logger.info('visited home page'); res.send('hello world');});
// this assumes that you are using passport which // exposes `req.logout` to log out the logged in user app.get('/logout', (req, res) => { req.logger.warn('logged out');req.logout();
res.redirect('/');
});
app.listen(3000, () => { cabin.info('app started');});
*
See Express convenience methods below for helper utilities you can usewhile writing code.
CONVENIENCE METHODS
In order to easily interact and use the logger utility function exposed by app.use(cabin.middleware), we expose convenient helper methods in Express and Koa:EXPRESS
* req.log
* req.logger
* res.log
* res.logger
KOA
* ctx.log
* ctx.logger
* ctx.request.log
* ctx.request.logger* ctx.response.log
* ctx.response.loggerBROWSER
VANILLAJS
This is the solution for you if you're just using REQUIRED BROWSER FEATURES We recommend using https://polyfill.io (specifically with the bundle mentioned in VanillaJS above): * Map is not supported in IE 10 * Map.prototype() is not supported in IE 10 * Math.sign() is not supported in IE 10 * Promise is not supported in Opera Mobile 12.1, Opera Mini all, IE Mobile 10, IE 10, Blackberry Browser 7 * Reflect is not supported in IE 10 * Symbol is not supported in IE 10 * Symbol.iterator() is not supported in IE 10 * Symbol.prototype() is not supported in IE 10 * Symbol.toPrimitive() is not supported in IE 10 * Symbol.toStringTag() is not supported in IE 10 * Uint32Array is not supported in IE Mobile 10, IE 10, BlackberryBrowser 7
* window.crypto() is not supported in IE 10BUNDLER
This assumes you are using browserify, webpack
, rollup
, or another bundler. const Cabin = require('cabin'); const cabin = new Cabin({ key: 'YOUR-CABIN-API-KEY' });cabin.setUser({
id: '1',
email: 'niftylettuce@gmail.com', full_name: 'niftylettuce'});
cabin.info('viewed docs'); AUTOMATIC REQUEST LOGGINGSERVER
For server-side logging of requests, the Cabin middleware cabin.middleware will automatically log requests for you upon completion. Just make sure you are using express-request-id middleware like in the examples above in order for the X-Request-Id header to be set (and re-used if already exists, e.g. generated from client side as in below). If you're using Koa make sure to wrap with koaConnect as shown in the examples above.BROWSER
WE STRONGLY RECOMMEND THAT YOU IMPLEMENT ONE OF THE FOLLOWING CODE SNIPPETS WITH XHOOK (FOR EITHER VANILLAJS OR BUNDLER APPROACHES) SO THAT ALL YOUR XHR REQUESTS HAVE A X-REQUEST-ID AUTOMATICALLY ADDED (WHICH IN TURN ENSURES BOTH CLIENT AND SERVER HAVE MATCHING REQUEST ID'S). IMAGINE HOW AWESOME YOUR LOGS WILL BE WHEN YOU CAN SEE THE FULL TRACE STARTING WITH THE CLIENT!HTML
(function() {
var cabin = new Cabin({ key: 'YOUR-CABIN-API-KEY', capture: true });cabin.setUser({
id: '1',
email: 'niftylettuce@gmail.com', full_name: 'niftylettuce'});
xhook.before(function(req) { if (typeof req.headers !== 'object') req.headers = {};if (!req.headers)
req.headers = cuid();if (!req.headers)
req.headers = window.navigator.userAgent;if (!req.headers)
req.headers = window.document.referrer;if (!req.headers)
req.headers = window.document.cookie; cabin.info('xhr', parseRequest({ req: req }));});
})();
PUG
> You can do a similar approach with React, EJS, or another templating> language.
script(src='https://polyfill.io/v3/polyfill.min.js?features=es6,es7,Map,Map.prototype,Math.sign,Promise,Reflect,Symbol,Symbol.iterator,Symbol.prototype,Symbol.toPrimitive,Symbol.toStringTag,Uint32Array,window.crypto') script(src='https://unpkg.com/xhook') script(src='https://unpkg.com/cabin') script(src='https://unpkg.com/parse-request') script(src='https://unpkg.com/cuid')script.
(function() {
var cabin = new Cabin({ key: 'YOUR-CABIN-API-KEY', capture: true });cabin.setUser({
id: '1',
email: 'niftylettuce@gmail.com', full_name: 'niftylettuce'});
xhook.before(function(req) { if (typeof req.headers !== 'object') req.headers = {};if (!req.headers)
req.headers = cuid();if (!req.headers)
req.headers = cuid();if (!req.headers)
req.headers = window.navigator.userAgent;if (!req.headers)
req.headers = window.document.referrer;if (!req.headers)
req.headers = window.document.cookie; cabin.info('xhr', parseRequest({ req: req }));});
})();
BUNDLER
npm :
npm install cabin xhook cuidyarn :
yarn add cabin xhook cuid const Cabin = require('cabin'); const xhook = require('xhook'); const parseRequest = require('parse-request'); const cuid = require('cuid'); const cabin = new Cabin({ key: 'YOUR-CABIN-API-KEY', capture: true });cabin.setUser({
id: '1',
email: 'niftylettuce@gmail.com', full_name: 'niftylettuce'});
xhook.before(req => { if (typeof req.headers !== 'object') req.headers = {};if (!req.headers)
req.headers = cuid();//
// NOTE: you may want to add User-Agent, Referer, and Cookie (see above)//
cabin.info('xhr', parseRequest({ req: req }));});
STACK TRACES AND ERROR HANDLING We leave it up to you to decide how you wish to handle stack traces and errors, but we've documented our approaches for Node and Browserenvironments below.
NODE
If you're using Lad , then you don't need to worry about error handling, as it's built-in (complete with graceful reloading, even for database connections). However you can otherwise use a tool such as uncaughtto listen for
errors, or bind purely to process events emitted as shown below: const Cabin = require('cabin'); const cabin = new Cabin({ key: 'YOUR-CABIN-API-KEY' }); process.on('uncaughtException', err => {cabin.error(err);
process.exit(1);
});
process.on('unhandledRejection', err => {cabin.error(err);
});
BROWSER
Since cross-browser support is very limited and unstandardized for errors and stack traces, we highly recommend to use either StackTrace or TraceKit as documented below.STACKTRACE
We recommend to use StackTrace instead of TraceKit as it is a more modern alternative and provides much similarity between your Browser and your Node errors (stackframes are basically similar to representations in Gecko and V8, aka the ones youget with Node).
It does require you to have a polyfill if you're using it in the browser (only if you're supporting browsers that don't support standardized Promises/JSON). You'll basically need es6-promise and json3 polyfills for browsers you wish to support that don't have them. The example below shows you how to polyfill, don't worry! You can reference Caniuse data on Promisesand JSON
respectively if you need. The example below demonstrates using StackTrace with uncaughtto catch global
errors below, but note that uncaught only supports IE11+, so if you need < IE11 support you probably should use TraceKitinstead.
If you're curious why it won't work in IE11, please see this great documentation on JavaScript errors cross-browser here- in
particular the section on "No Error object provided".TRACEKIT
This is a legacy stack trace package with support for very old browsers. You can view TraceKit's full documentation here.
It is widely used by logging services and seems to be the most popular tool. Note that in the example code below, you will notice a repetitive pattern you'll encounter of wrapping code with a try and catch block. Don't worry, because if you're using webpack or gulp, you can easily wrap your bundled files with try and catch blocks! See Automatic Try Catch Wrapping below. AUTOMATIC TRY CATCH WRAPPINGGULP
npm install -D gulp-wrap const wrap = require('gulp-wrap'); gulp.src('./asset.js').pipe(wrap(`
try {
<%= contents %>
} catch (err) {
TraceKit.report(err);}
`))
.pipe(gulp.dest('./dist'));WEBPACK
npm install -D wrapper-webpack-plugin const WrapperPlugin = require('wrapper-webpack-plugin'); module.exports = { // other webpack config hereplugins:
};
DISPLAY METADATA AND STACK TRACES Under the hood, Cabin uses Axe which provides us with several options, including one to show metadata (e.g. request headers, body, and user) and another to show stack traces forerrors.
You can pass these options through the axe option (see Options below), or you could pass environment flags when you need to. BY DEFAULT, AXE DOES NOT OUTPUT ANY METADATA AND ONLY OUTPUTS STACK TRACES IN NON-PRODUCTION ENVIRONMENTS.SHOW/HIDE METADATA
To hide metadata, pass a falsey value for the process environmentvariable SHOW_META.
> (e.g. SHOW_META=0 or SHOW_META=false before running your script, > such as SHOW_META=false node app). Similarly if you pass a truthy value of 1 or true it will show metadata (which is the default behavior). SHOW/HIDE STACK TRACES To hide stack traces, pass a falsey value for the process environment variable SHOW_STACK. > (e.g. SHOW_STACK=0 or SHOW_STACK=false before running your script, > such as SHOW_STACK=false node app). Similarly if you pass a truthy value of 1 or true it will show metadata (which is the default behavior).OPTIONS
* key (String) - defaults to an empty string, THIS IS WHERE YOU PUT YOUR CABIN API KEY, which you can get for free at Cabin * capture (Boolean) - defaults to false in browser (all environments) and server-side (non-production only) environments, whether or not to POST logs to the endpoint (see Axedocs for more info)
* axe (Object) - defaults to an empty Object {}, but you can pass options here for Axe * logger (Object) - if you have a custom logger you wish to use instead of Axe , but note that Axe accepts a logger option, so you should use that instead, see Axedocs for more info
* meta (Object) - defaults to an empty object - this will get passed as metadata (e.g. you could set a custom meta.user object here forevery request)
* parseRequest (Object) - defaults to an empty object, which means it will use the defaults from parse-request (see Metadata below) * errorProps (Array) - a list of properties to cherry-pick from the error object parsed out of err thanks to parse-err (by default all properties are returned; even non-enumerable ones and ones on the prototype object) (see Metadata below) * message (Function) - inspired by morgan , and defaults to a dev-friendlyformat (or if in
production mode, then it uses a standard Apache common log format )). – when requests finish, it will utilize logger to output an error, warn, or info level log based off the status code, and this function is used to determine the string sent to the logger. It accepts one argument options, which is comprised of options.level, options.req, options.res, and optionally (if and only if Koa) options.ctx. It is required that this function return a String. See src/message.js for the default message functionMETADATA
We use the package parse-request to parse the request metadata for you autoamaticaly. Here's an example of a parsed metadata object:{
request: {
method: 'POST',
query: {
foo: 'bar',
beep: 'boop'
},
headers: {
host: '127.0.0.1:63955', 'accept-encoding': 'gzip, deflate', 'user-agent': 'node-superagent/3.8.3', authorization: 'Basic ********************', accept: 'application/json', cookie: 'foo=bar;beep=boop', 'content-type': 'multipart/form-data; boundary=--------------------------930511303948232291410214', 'content-length': '1599', connection: 'close'},
cookies: {
foo: 'bar',
beep: 'boop'
},
body: '{"product_id":"5d0350ef2ca74d11ee6e4f00","name":"nifty","surname":"lettuce","bank_account_number":"1234567890","card":{"number":"****-****-****-****"},"stripe_token":"***************","favorite_color":"green"}', url: '/?foo=bar&beep=boop', timestamp: '2019-06-14T07:46:55.568Z', id: 'fd6225ed-8db0-4862-8566-0c0ad6f4c7c9', http_version: '1.1', files: '{"avatar":,"boop":}'},
user: {
ip_address: '::ffff:127.0.0.1'},
id: '5d0350ef2ca74d11ee6e4f01', timestamp: '2019-06-14T07:46:55.000Z',duration: 6.651317
}
RELATED
* forwardemail - Free, encrypted, and open-source email forwarding service for custom domains * lad - Scaffold a Koa webapp and API framework for Node.js * koa-better-error-handler- A better
error-handler for Lad and Koa. Makes ctx.throw awesome! * axe - Logging utility for Node and Browser environments. Chop up your logs! * lass - Scaffold a modern boilerplate forNode.js
* lipo - Free image manipulation API service builton top of Sharp
CONTRIBUTORS
NAME
WEBSITE
NICK BAUGH
http://niftylettuce.com/TRADEMARK NOTICE
Axe, Lad, Lass, Cabin, Lipo, and their respective logos are trademarks of Niftylettuce LLC. These trademarks may not be reproduced, distributed, transmitted, or otherwise used, except with the prior written permission of Niftylettuce LLC. If you are seeking permission to use these trademarks, then please contact us.LICENSE
MIT © Nick Baugh
##
Details
Copyright © 2024 ArchiveBay.com. All rights reserved. Terms of Use | Privacy Policy | DMCA | 2021 | Feedback | Advertising | RSS 2.0