All Projects → TokioXx → egg-sentry

TokioXx / egg-sentry

Licence: MIT license
Sentry Plugin For Egg.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to egg-sentry

Egg Cancan
cancancan like authorization plugin for Egg.js
Stars: ✭ 47 (+161.11%)
Mutual labels:  egg, egg-plugin, eggjs
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (+550%)
Mutual labels:  egg, egg-plugin, eggjs
egg-rbac
Role Based Access Control for eggjs
Stars: ✭ 32 (+77.78%)
Mutual labels:  egg, egg-plugin, eggjs
Egg Graphql
Stars: ✭ 345 (+1816.67%)
Mutual labels:  egg, egg-plugin, eggjs
Egg Oauth2 Server
🌟 OAuth2 server plugin for egg.js based on node-oauth2-server
Stars: ✭ 174 (+866.67%)
Mutual labels:  egg, egg-plugin, eggjs
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (+944.44%)
Mutual labels:  egg, egg-plugin, eggjs
egg-parameters
Merge all parameters (ctx.params, ctx.request.query, ctx.request.body) into ctx.params like Rails application.
Stars: ✭ 24 (+33.33%)
Mutual labels:  egg, egg-plugin, eggjs
Egg 24time
A Twitter-like news and social server for Egg. 微信小程序社区全栈解决方案
Stars: ✭ 493 (+2638.89%)
Mutual labels:  egg, egg-plugin, eggjs
Egg Authz
egg-authz is an authorization middleware for Egg.js based on Casbin
Stars: ✭ 50 (+177.78%)
Mutual labels:  egg, egg-plugin, eggjs
Blog
天猪部落阁 http://atian25.github.io
Stars: ✭ 1,527 (+8383.33%)
Mutual labels:  egg, eggjs
Egg View React Ssr
Egg React Server Side Render (SSR) Plugin
Stars: ✭ 55 (+205.56%)
Mutual labels:  egg, egg-plugin
Egg Redis
redis plugin for egg
Stars: ✭ 234 (+1200%)
Mutual labels:  egg, egg-plugin
Egg Passport
passport plugin for egg
Stars: ✭ 98 (+444.44%)
Mutual labels:  egg, egg-plugin
Egg Schedule
Schedule plugin for egg
Stars: ✭ 76 (+322.22%)
Mutual labels:  egg, egg-plugin
Egg Socket.io
socket.io plugin for eggjs.
Stars: ✭ 209 (+1061.11%)
Mutual labels:  egg, egg-plugin
Egg Validate
validate plugin for egg
Stars: ✭ 224 (+1144.44%)
Mutual labels:  egg, egg-plugin
Egg View Ejs
egg view plugin for ejs.
Stars: ✭ 54 (+200%)
Mutual labels:  egg, egg-plugin
Egg View Vue
vue view plugin for egg
Stars: ✭ 136 (+655.56%)
Mutual labels:  egg, egg-plugin
egg-exporter
Egg.js 的 Prometheus 指标收集插件,附带 Grafana 看板。
Stars: ✭ 24 (+33.33%)
Mutual labels:  egg, egg-plugin
egg-kafka-node
kafka plugin for egg.js
Stars: ✭ 36 (+100%)
Mutual labels:  egg, egg-plugin

Egg-Sentry

Sentry Plugin for Eggjs

About

This module is to helper developers setup sentry with least work.

Getting Started

Install egg-sentry as an npm module and save it to your package.json file as a development dependency:

npm install --save egg-sentry

Add sentry configuration:

// config/config.default.js

exports.sentry = {
  dsn: 'https://819e74a6e948468b9740680cfa87986b:[email protected]/246025',
};

// config/plugin.js

exports.sentry = {
  enable: true,
  package: 'egg-sentry',
};

Replace the dsn with your own one, get details at Sentry.

From now on, expections are able to submit to sentry. What if we wanna more custom information, such as logined user?

To get a rich context, implemet Egg Service in app/service/sentry.js file and there are four member properties or methods are supported.

// app/service/sentry.js

'use strict';

const Service = require('egg').Service;

class SentryService extends Service {
  /**
   * filter errors need to be submitted to sentry
   *
   * @param {any} err error
   * @return {boolean} true for submit, default true
   * @memberof SentryService
   */
  judgeError(err) {
    // ignore HTTP Error
    return !(err.status && err.status > 500);
  }
  
  // user information
  get user() {
    return this.ctx.session.user;
  }

  get extra() {
    return {
      ip: this.ctx.ip,
      payload: this.ctx.request.body,
    };
  }

  get tags() {
    return {
      url: this.ctx.request.url,
    };
  }
}

module.exports = SentryService;

These infomation would be automaticlly injected into error context.

Bootstrap

Replace the dsn in test/fixtures/apps/sentry-test/config/config.unittest.js and then run npm start to see what would happend.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].