Coder Social home page Coder Social logo

ember-cli-bugsnag's Introduction

Ember-cli-bugsnag

Build Status Ember Observer Score

Installation

Install the addon:

ember install ember-cli-bugsnag

💥 ember-cli-bugsnag 3.0.0 includes some breaking changes. Learn more.

Configuration

There are two ways to configure ember-cli-bugsnag:

  1. Add POJO to config/environment:
{
  bugsnag: {
    apiKey: '',
    enabledReleaseStages: ['development', 'production']
  }
}

The releaseStage defaults to the current application environment, if you need to set a different releaseStage that diverges from the environment, you can pass and additional attribute to the bugsnag configuration called releaseStage. It would look like this:

{
  bugsnag: {
    apiKey: '',
    enabledReleaseStages: ['development', 'production', 'staging'],
    releaseStage: 'staging'
  }
}
  1. Specify environment variables:
export BUGSNAG_API_KEY=''
export BUGSNAG_ENABLED_RELEASE='development,production'

Configuration options:

  • config.bugsnag.apiKey / BUGSNAG_API_KEY -- required
  • config.bugsnag.enabledReleaseStages / BUGSNAG_ENABLED_RELEASE -- optional, defaults to [] (never notify).
  • config.bugsnag.releaseStage / BUGSNAG_RELEASE_STAGE -- optional, defaults to config.environment.
  • config.bugsnag.endpoints / BUGSNAG_ENDPOINTS -- optional, defaults to what the libraryUrl uses.
  • config.currentRevision -- any string representing the current version of the app, e.g. "1b8ef2c7" or "v1.2.4", optional.
    • Defaults to the version specified in package.json, e.g. 0.1.0.
    • This can be set automatically at build time with ember-git-version.

Customization

In order to send additional data along with errors reported to Bugsnag, generate a utility named bugsnag:

ember g util bugsnag

Custom Diagnostics (docs)

To send custom metadata, define a helper method getMetadata in the app/utils/bugsnag.js you created. getMetadata takes the error and the container as arguments, e.g.:

export function getMetadata(error, container) {
  return {
    // …some metadata
  };
}

ember-cli-bugsnag calls this method for every error and reports any data returned by it to Bugsnag as metadata for the respective error. The returned metadata should be formatted to correspond with tabs in your interface. E.g. for an Account tab:

return {
  account: {
    name: "Bugsnag",
    plan: "premium",
    beta_access: true
  }
};

Identifying Users (docs)

To correlate a specific user to an error and have the information appear in the User tab in the Bugsnag UI, send user data with each error data. Define a helper method getUser in the app/utils/bugsnag.js you created. getUser takes the container as an argument. For example, if you have a currentUser service that references a user model in your app:

import Ember from 'ember';

const {
  getProperties
} = Ember;

export function getUser(owner) {
  const currentUser = owner.lookup('service:current-user').get('user');
  const {
    email,
    id,
    fullName: name
  } = getProperties(currentUser, 'email', 'id', 'fullName');

  return {
    email,
    id,
    name
  };
}

Uploading Sourcemaps (docs)

Uploading sourcemaps to Bugsnag makes it easier to track down errors in your code because the stacktrace for each error in the Bugsnag UI highlights the exact line in your unminified source code. To send sourcemaps to Bugsnag, you can use the Ember CLI Deploy addon ember-cli-deploy-bugsnag.

Upgrading to 3.0

ember-cli-bugsnag 3.0 includes some changes to bring this addon in line with the latest from the bugsnag-js library and accompanying documentation.

  1. Rename config.bugsnag.notifyReleaseStages/BUGSNAG_NOTIFY_RELEASE to config.bugsnag.enabledReleaseStages/BUGSNAG_ENABLED_RELEASE

  2. config.bugsnag.endpoint/ BUGSNAG_ENDPOINT => config.bugsnag.endpoints/BUGSNAG_ENDPOINTS

  3. Rename getMetaData => getMetadata in app/utils/bugsnag.js

ember-cli-bugsnag's People

Contributors

alonski avatar cibernox avatar cigoe avatar ember-tomster avatar evanlouden avatar jderr-mx avatar josemarluedke avatar josex2r avatar kategengler avatar kcincode avatar marcoow avatar michaeldeitcher avatar mmun avatar odoe avatar patrickberkeley avatar pdud avatar pezmc avatar rlivsey avatar seawatts avatar tempo22 avatar twokul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ember-cli-bugsnag's Issues

Install instructions

Since Ember-CLI 0.2.3, ember addons should not be installed using ember install ember-cli-bugsnag - the readme should be upated.

When I ran the above install the package installed correctly. However, it threw an error after install:

version: 0.2.3 # Ember CLI version
Installed packages for tooling via npm.
installing
installing
The `ember generate` command requires an entity name to be specified. For more details, use `ember help`. # error

1.0.0+ always thinks I am in production

1.0.0+ always thinks I am in production so is always logging when in development. I made sure it was properly in development still checking right before an error occurred.

I went through code and couldn't find out why, mine and yours. But it works fine on 0.2.0 so just sticking with that as I haven't got time to find the actual issue or diff what changed between versions.

Better urls

Route names instead of urls. Open questions: what happens if error is thrown mid transition?

Potential regressions in 2.0.0

I published 2.0.1 today which had a fix for Ember 3.13+
I also made some changes to the version of node which required bumping ember-cli to 3.1.3+
In testing it on my work app I am seeing some regressions in our test suite that seem unrelated. Like floats being 1.250 instead of 1.25 all of a sudden.
Working on reproducing those errors, I am a little confused as it feels like if should be a simple dependency upgrade.

Upgrade bugsnag-js to new major version 4

Bugsnag has put out a new major version. Currently 4.3.3

This is a complete rewrite that changes how bugsnag is used and thus just upgrading the package doesn't work.
I played around for an hour or so trying to get this to work but couldn't get it working again.

I can help if I get some direction but I don't have a lot of experience with Ember Addons and am running into a few walls.

Here is what I tried so far: https://github.com/Alonski/ember-cli-bugsnag/tree/upgradeBugsnag

Library URL config option

Thanks for putting this add-on together, it was really easy to setup.

I was wondering if the config.bugsnag.libraryUrl property is still relevant. From what I can tell the add-on was updated to pull the Bugsnag library from Bower and then, more recently, to use inline node assets to use the node module.

Thanks!

User id is always IP address

I'm assuming this is an upstream issue, and I've reported it as bugsnag/bugsnag-js#171.

Nonetheless, I wanted to note it here.

I'm hitting an annoyance, when adding user metadata to my exception - my user ID is being ignored, and the default IP address is always being used instead.

Fix breaking changes in FastBoot 1.0

The current ember-cli-fastboot releases (1.0.0-rc.1 and above) introduce breaking changes. These will most likely break your current FastBoot implementation.

See ember-fastboot/ember-cli-fastboot#387 for more information and a guide on how to fix your addon. Also you may want to visit the -fastboot Slack channel to get help from other users.

Note: this issue has been created automatically, by searching for certain patterns in your code. If you think this has been falsely created, feel free to close!

instance.container is not a function

I'm trying to upgrade to Ember 2.5 from 2.0 and getting this: TypeError: instance.container is not a function

Sample initializer:
App.initializer({
name: 'appInitializers',
initialize: function(app) {
app.inject('controller', 'test', 'test:main');
app.inject('component', 'test', 'test:main');
app.inject('route', 'test', 'test:main');
app.inject('adapter', 'test', 'test:main');
app.inject('serializer', 'test', 'test:main');
},
});

wondering what I'm doing wrong. Thanks for any help.

Should not catch TransitionAborted error

It seems that a TransitionAborted error doesn't have a stack trace.

image

This is causing us problems for now but having looked through the Ember code base this appears to be something that might not be an error situation. I think we abort some transitions manually in our apps.

emberjs/ember.js@322fc0e

Fastboot support

Any plans on getting fastboot support out of the box for this addon?

The ideal would be that this addon uses the node version of bugsnag when running in fastboot, and then when running in the browser it uses the JS version.

First step, at least, is to get this to not include the browser version of JS in fastboot land.

No tests

There's no tests. I'm working on it!

CSP inline-script error

Chrome gives the following CSP error when using the addon:

[Report Only] Refused to execute inline script because it violates the following 
Content Security Policy directive: "script-src ... ". Either the 'unsafe-inline' keyword, 
a hash ('sha256-Li1kX2hSsXxBIvK1YWeekOV49Asr5QAOvrIrILWqql0='), or a 
nonce ('nonce-...') is required to enable inline execution.

It would be reasonably straightforward to generate a hash of the contents and inject that into the CSP rules in development, but I'm not sure how this would work in production. Obviously the addon doesn't integrate with the web-server in any way so there'd be no way of injecting this.

Adding a nonce to the config and using that in the script tag would also work, we'd just need to use the same nonce in the web-server config for it to work on live.

Another approach would be to not inject the script tag into the HTML at build time at all and instead dynamically inject the script at run-time using something like ember-inject-script.

Can't return promise from getMetaData

In our Ember app, we have a currentUser computed property on our session service, which returns a promise.

I'm hoping to use this currentUser() method to populate the Bugsnag user metadata via this promise-based method. However, returning a promise from utils/bugsnag.js getMetadata() is not currently possible.

Do you forsee this being possible? Or will I have to develop a local workaround?

Cannot `import Bugsnag from 'bugsnag'` in test environment

I'm using the Bugsnag.notify API and therfore have to

import Bugsnag from 'bugsnag';

However, this breaks my tests:

Chrome 43.0 - Global error: Uncaught Error: Could not find module bugsnag imported from

Any suggestions here? I'm curious why index.js explicitly does not include bugsnag in test environments.

// index.js
this._includeBugsnag =
      this.isDevelopingAddon() || process.env.EMBER_ENV !== 'test';

Any chance we could import just the bugsnag/shim in test environments?

How to require bugsnag

I need to require Bugsnag in a before hook to the ember build.

I have no problem requiring it when I install it using npm: npm install bugsnag --save-dev

However, I think since it's an ember-cli add-on, I'm having issues.

Docs say to require('bugsnag'), but it doesn't seem available at this stage.

Do you have any thoughts on how I can require it in a file outside the app directory in the tasks directory, and before ember gets built ?

Error when no api key is set

This line will issue the following error if we don't set an api key:

Uncaught TypeError: Cannot read property '_config' of null
    at Object.initialize (bugsnag.js:15)

What do you think of improving the guard like this ?

  if (!Bugsnag._client || Bugsnag._client._config.apiKey === undefined) {
    return;
  }

user/metadata not always provided when using Bugsnag.notifyException

I'm reviewing some recent Bugsnags and realizing that the user and metadata tags are not always provided as part of the Bugsnag. I'm not 100% certain but I believe it's because there's some instances in our app where we recover from an error but still want to use Bugsnag.notifyException.

The problem seems to be, from my understanding of that code, that getUser() and getMetadata() don't get called except from within onerror: https://github.com/binhums/ember-cli-bugsnag/blob/master/app/instance-initializers/bugsnag.js#L50

The result of this seems to be that if the first Bugsnag report issued is a manual notifyException, it won't contain pull in your user data / metadata. But if an onerror occurred, it'll set these values for all future notifyExceptions.

I'm surprised no one's noticed this; it makes me wonder if I'm misusing the API somehow? Is it ok that I'm still using Bugsnag.notifyException to report handled exceptions? Or is there a better workflow?

container.lookup is not a function [email protected]

This addon is using the Application Initializers API, which doesn't have access to app.lookup anymore. It should probably be migrated to be an instance initializer to access app.lookup as it fails in new ember versions.

It's fixed as easily as renaming app/initializers to app/instance-initializers I believe.

Promises are not being reported correctly

This might not be an issue and maybe it's something I did wrong. We installed bugsnag a couple weeks ago and our app has been reporting errors regularly, both on production and our staging server. But none of them have been due to error caused by unfulfilled promises. And I'm pretty sure we have a few of those.

This is the stacktrace generated by an error in bugsnag right after Ember triggers and exception on RSVP when our api responds with a 500. It's really hard to debug due to the assets being minified.

screen shot 2015-06-05 at 12 54 09 pm

Any clue on how to solve it?

Allow overriding releaseStage

Ember-CLI only supports development, test, and production, so we end up using config.environment = "production" for production and staging.

I'd love to be able to override that with

// config/environment.js:
bugsnag: {
  releaseStage: process.env.MY_APP_ENVIRONMENT
}

and have this addon default to config.environment if that isn't specified:

// index.js:
var releaseStage = bugsnagConfig.releaseStage || config.environment;
...
'Bugsnag.releaseStage = "' + releaseStage + '";',

Cannot read property 'apply' of undefined. Ember 1.13.x

For some reason Ember 1.13.x doesn't have treeForApp available on this._super on line 23:36

ember-cli-bugsnag/index.js:

  ...

  treeForApp: function() {
    if (this._includeBugsnag) {
      return this._super.treeForApp.apply(this, arguments); // Cannot read property 'apply' of undefined
    }
  },

  ...

Seems the ember-data team discovered this also: https://github.com/emberjs/data/blob/master/index.js#L95

Currently installed ember-cli-bugsnag v1.0.2.

Is there any way to fix this?

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.