Giter VIP home page Giter VIP logo

ember-cli-sentry's Introduction

ember-cli-sentry

An ember-cli addon adding Sentry support.

Docs are available here.

What it does (and does not)

This add-on does:

  • Enable safe use of Raven.js whether you are in development mode or not.
  • Inject a logging service to routes, components, controllers and models to access Raven object.
  • Provide a default logger generator that should work for the vast majority of people.
  • Add an opt-out bower dependency to ravenjs.
  • Provide rather complete customization.

This add-on does not:

  • Generate the logging service for you.
  • Provide a Sentry key for testing.

Important notice if you migrate from 1.x.x to 2.x

Please have a look at this wiki entry if you upgrade major version of ember-cli-sentry.

Install

From any ember-cli application, run ember install ember-cli-sentry.

Note: Since v2.1.2, Raven bower component is automatically included by this addon.
If you want to use your own packaged version or the cdn option, you'll have to opt-out by removing it from bower dependencies.

Add-on will assume there is an available service that proxies Raven, which is not the case unless you already did the install.

The easiest way of doing it is to create a service only extending ember-cli-sentry/services/raven:

// your-app/services/custom-logger.js
export { default } from 'ember-cli-sentry/services/raven';

You can also use a generator ember g logger <logger-name>, which will generate a service called <logger-name> extending ember-cli-sentry/services/raven and exposing its methods and properties.

Now that you have a dedicated service for Raven.js, let's configure it.

Configuration

TLDR

You already have a service named raven that extends ember-cli-sentry/services/raven.

// config/environment.js

module.exports = function(environment) {
  var ENV = {

    /* config */

    sentry: {
      dsn: 'https://<dummykey>@app.getsentry.com/<dummyproject>'
    }
  }
}

Complete config

// config/environment.js

module.exports = function(environment) {
  var ENV = {

    /* config */

    sentry: {

      /**
       * If Raven.js is not inlined in your code, this is
       * where you want to define it.
       *
       * I recommend **not** using a build containing ember.js plugin (https://github.com/getsentry/raven-js/blob/master/plugins/ember.js)
       * since setting `globalErrorCatching: true` will perform the same
       * operation, safely.
       *
       * @type {String}
       * @default undefined
       */
      cdn: 'https://cdn.ravenjs.com/2.2.0/raven.min.js',

      /**
       * The only mandatory parameter.
       *
       * @type {String}
       */
      dsn: 'https://<dummykey>@app.getsentry.com/<dummyproject>',

      /**
       * Sets Raven.debug property when running `Raven.config`.
       *
       * @type {Boolean}
       * @default true
       */
      debug: true,

      /**
       * If set to true, this add-on will never initialize
       * Raven object and capturing will be handled by the logging service (redirected to the console if you use default service).
       *
       * @type {Boolean}
       * @default undefined
       */
      development: false,

      /**
       * Injects the logging service as this property.
       *
       * @type {String}
       * @default 'raven'
       */
      exposedPropertyName: 'raven',

      /**
       * If set to true, add-on will try to have Ember.onerror
       * and Ember.RSVP.on('error') captured by Raven.
       *
       * @type {Boolean}
       * @default true
       */
      globalErrorCatching: true,

      /**
       * Service used to interface with Raven.
       *
       * @type {String}
       * @default 'raven'
       */
      serviceName: 'raven',

      /**
       * Raven.js option.
       *
       * @type {Array}
       * @default []
       */
      includePaths: [],

      /**
       * Raven.js option.
       *
       * @type {Array}
       * @default []
       */
      whitelistUrls: [],

      /**
       * Options to pass directly to Raven.js. Note: whitelistUrls and
       * includePaths in this will take precedence
       * over the above.
       *
       * @default {}
       */
      ravenOptions: {},
    }
  }
}

Content Security Policy

To allow Ravenjs to work properly, you need to add a couple of thing to the content security policy rules:

'script-src': "'self' 'unsafe-inline' 'unsafe-eval' cdn.ravenjs.com",
'img-src': "data: app.getsentry.com",
'connect-src': "'self' app.getsentry.com"

Example

The dummy application in tests is a working example with a couple of logging here and there, and a default logger.

Dependencies

Raven.js

Licence

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.