Giter VIP home page Giter VIP logo

bugsnag / bugsnag-js Goto Github PK

View Code? Open in Web Editor NEW
845.0 49.0 252.0 71.1 MB

JavaScript error handling tool for BugSnag. Monitor and report JavaScript bugs & errors.

Home Page: https://docs.bugsnag.com/platforms/javascript

License: MIT License

HTML 3.25% JavaScript 19.56% Shell 1.24% TypeScript 39.22% Ruby 2.66% Gherkin 12.30% CSS 0.01% Dockerfile 0.14% Java 5.06% Kotlin 1.78% Objective-C 3.94% Starlark 0.23% Swift 0.11% C 7.93% Python 0.06% Makefile 0.22% C++ 0.99% Objective-C++ 1.32%
bugsnag javascript error-reporting debug error-handling exceptions bug crash-reporting error-monitoring bugs

bugsnag-js's Introduction

Bugsnag error monitoring & reporting for JavaScript

Automatically detect JavaScript errors in the browser, Node.js and React Native, with plugins for React, Vue, Angular, Express, Restify and Koa. Get cross-platform error detection for handled and unhandled errors with real-time error alerts and detailed diagnostic reports.

Learn more about JavaScript error reporting and React Native error reporting from Bugsnag.


This is a monorepo (managed with Lerna containing our universal error reporting client @bugsnag/js, and our React Native client @bugsnag/react-native, along with:

Etc. See packages for a full list of contents.

Getting started

  1. Create a Bugsnag account
  2. Complete the instructions in the integration guide
  3. Report handled exceptions using Bugsnag.notify()
  4. Customize your integration using the configuration options

Integrating with frameworks

Use the following plugins and guides to integrate Bugsnag with various frameworks.

Browser

Framework Bugsnag plugin Documentation
Vue @bugsnag/plugin-vue Vue docs
React @bugsnag/plugin-react React docs
Angular @bugsnag/plugin-angular Angular docs

Desktop

Framework Bugsnag notifier Documentation
Electron @bugsnag/electron Electron docs

Server

Framework Bugsnag plugin Documentation
Koa @bugsnag/plugin-koa Koa docs
Express @bugsnag/plugin-express Express docs
Restify @bugsnag/plugin-restify Restify docs

Mobile

Framework Bugsnag notifier Documentation
React Native @bugsnag/react-native React Native docs

Support

Contributing

Most updates to this repo will be made by Bugsnag employees. We are unable to accommodate significant external PRs such as features additions or any large refactoring, however minor fixes are welcome. See contributing for more information.

Development quick start

# Clone the repository
git clone [email protected]:bugsnag/bugsnag-js.git --recursive
cd bugsnag-js

# Install top-level dependencies
npm i

# Bootstrap all of the packages
npm run bootstrap

# Build the standalone notifiers and plugins
npm run build

# Run the unit tests
npm run test:unit

# Run tests for a specific package
npm run test:unit -- --testPathPattern="packages/react-native"

# Generate a code coverage report
npm run test:unit -- --coverage

# Run the linter
npm run test:lint

# Run the typescript compatibility tests
npm run test:types

See contributing for more information.

License

All packages in this repository are released under the MIT License. See LICENSE.txt for details.

bugsnag-js's People

Contributors

anastasiiasvietlova avatar andvla avatar bengourley avatar cawllec avatar dependabot[bot] avatar djskinner avatar fractalwrench avatar gingerbenw avatar imjoehaines avatar johnkiely1 avatar joshedney avatar kattrali avatar kstenerud avatar lemnik avatar linusu avatar loopj avatar mattdyoung avatar mclack avatar nickdowell avatar nvojnovic avatar robert-smartbear avatar sharc7 avatar skirsten avatar snmaynard avatar steve-nester-uk avatar tomlongridge avatar twometresteve avatar wadetandy avatar yousif-bugsnag avatar yychen01988 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bugsnag-js's Issues

Async Safety

Some people (despite the instructions) load bugsnag asyncronously. This actually can break removeEventListener in the following case:

  1. addEventListener is called with unwrapped event handlers.
  2. bugsnag loads
  3. removeEventListener is called with wrapped event handlers.

We can fix this by making removeEventListener remove both wrapped and unwrapped versions of the function.

npm publish?

I know this package is published on bower but why isn't it published on npm too? Under bugsnag-js? I believe it would make a lot of sense; managing updates on published package is lot more simpler than through a git URL e.g: "bugsnag-js": "git+ssh://[email protected]:bugsnag/bugsnag-js.git#v2.4.6". And bower doesn't have anything that come close to npm shrinkwrap.

When using commonJS and for the above reasons npm is much more useful than bower.

Safari 5.1 type error

In Safari 5.1 on windows and os x the bugsnag lib throws a type error at line

318 curr = curr.caller;

when iterating through the call stack. Any ideas why and possible fixes for this problem. I'm sorry I can't be more specific.

Tag V1.0.8

Please could you tag version 1.0.8

Thank you

bugsnag.notify fails in IE 9

There's no lineNumber, so we throw it away as useless on the server side. We should either fix the server to not discard or the client to send lineNumber.

Object Expected Error

Happens in at least IE 9.

/src/bugsnag.js:128

var ret = _super.apply(this, arguments);

Include full current page URL (with hashtag)

Many JS systems use a hashtag to determine where it is; if you sent the full contents of document.location.href to bugsnag it would make it much easier to track down the cause of issues for things like this.

Possibility of an afterNotify callback?

Similar to being able to define a beforeNotify method, afterNotify would tell my application something had gone wrong and application state was unknown.

From this I could start checking my javascript objects or perhaps reload the page without interrupting the notification from being sent.

Invalid Argument thrown by wrapped event handler in IE9

In Internet Explorer 9, wrapped event handlers (in particular, tap) throw an error message of Invalid Argument. This is occurring at line 128 of bugsnag.js:

 } else {
            var ret = _super.apply(this, arguments); // problem is here
            // in case of error, this is set to null in window.onerror
            lastScript = null;
            return ret;

I have not been able to reproduce this unfortunately, but the error is caught and a notification gets sent correctly.

I'll update if I am able to reproduce.

Makes selenium::webdriver unhappy

This seems to happen frequently, but not consistently. I hope to provide more details shortly. The browser being used is Firefox, testing stack is ruby/capybara/cucumber/gherkin + selenium::webdriver.

The issue is a known issue within selenium (js access denied), but in this case bugsnagjs is triggering it.

Would wrapping the entirety of bugsnagjs in a try/catch help protect against this?

When this occurs, screenshots of the failure page seem to be showing all JS on the page grinding to a halt also.

Permission denied to access property 'bugsnag' (Selenium::WebDriver::Error::UnknownError)
[remote server] https://d2wy8f7a9ursnm.cloudfront.net/bugsnag-1.1.0.min.js:1:in y.wrap' [remote server] https://d2wy8f7a9ursnm.cloudfront.net/bugsnag-1.1.0.min.js:1:inM/<'

`lastEvent` is not reset at the end of event handler wrapper

Unless I am mistaken, the intent of logging the last event is when it was likely the trigger for the error. I was reading the notifier code (https://github.com/bugsnag/bugsnag-js/blob/master/src/bugsnag.js)
and realized lastEvent is never reset anywhere which suggests to me that if an event handler fires lastEvent is set with that event and then sent back with the next error on the page which may be completely unrelated to the event. I would have expected lastEvent to be cleared at the end of any event handler wrapper, because if the error didn't happen in the handler, it is no longer relevant.

Allow settings to be functions?

I was wondering if you guys had thought about allowing settings to be functions. For instance:

Bugsnag.user = function() {
  return getCurrentUser() || {
    id: 7,
    name: "Conrad Irwin",
    email: "[email protected]"
  };
};

This would let us keep our Bugsnag code all in one place, rather than putting it in various places (here, when the user logs in, logs out, etc.).

I'd be happy to whip up a PR for this if it's something you guys agree with.

I'm also brand new to Bugsnag so let me know if there's an alternative approach I missed!

`millisecondsAgo` incorrect

Screenshot

Pretty self explanatory, date is set to 1970 (44 years ago).
Haven't had a look at where this is happening yet, but I can, when I get a chance.

Happens on Firefox 30, so it's not a legacy problem.

Chrome extension

Hello,

I'm using bugsnag-js for monitoring a chrome extension. Errors are sent, but never displayed in Bugsnag It seems that there is a problem because of 'chrome-extension" into stacks error.

Exemple :

Error
    at generateStacktrace (chrome-extension://nkleeghhjabalfolcphldebmfabofbia/lib/bugsnag.js:489:13)
    at Object.self.notify (chrome-extension://nkleeghhjabalfolcphldebmfabofbia/lib/bugsnag.js:100:19)
    at _init (chrome-extension://nkleeghhjabalfolcphldebmfabofbia/js/content-script/smartbar.js:442:17)
    at Object.callback (chrome-extension://nkleeghhjabalfolcphldebmfabofbia/js/content-script/smartbar.js:322:13)
    at safeCallbackApply (extensions::sendRequest:21:15)
    at handleResponse (extensions::sendRequest:73:7)

As workaround, I do this in bugsnag.js :

function stacktraceFromException(exception) {
    return (exception.stack || exception.backtrace || exception.stacktrace).replace(/chrome-extension:/g, "chromeextension:");
  }

Bugsnag breaks setTimeout/setInterval when used with more than two arguments

Most people only use setTimeout/setInterval's first two arguments (a callback function and a delay in milliseconds), but you can actually pass extra arguments which then get passed to the callback function.

This syntax doesn't work when using Bugsnag because your setTimeout/setInterval wrapper explicitly passes through only the first two arguments, and thus everything after that is dropped. It should work with an arbitrary number of arguments.

I'd submit a pull request, but it's past my bedtime and it looks like this should be an easy fix for you guys.

Error when loading bugsnag through commonjs as a bundled file.

After finding that uBlock outright blocks bugsnag, we've decided to wrap bugsnag up in our external-libraries file in our browserify setup. Being so, means we don't have a script tag where bugsnag is bound to, and that leads to the following error.

bugsnag.js:318
      var attrs = node.attributes;
                      ^
TypeError: Cannot read property 'attributes' of undefined
  at getData (/Users/alex/Development/reactor/client/scripts/vendor/bugsnag.js:318:23)
  at getSetting (/Users/alex/Development/reactor/client/scripts/vendor/bugsnag.js:334:22)

Consider adding an ignore list or other way to ignore 3rd party JavaScript

Hi guys

We've just started using the JavaScript bug tracker and it works great, but at the moment the only exceptions seem to be appearing from 3rd party services, an example of this is:

B1D671CF-E532-4481-99AA-19F420D90332/netdefender/hui/ndhui.js

That file isn't actually present in our application at all, it's obviously being loaded by the netdefender firewall the user has installed. Is there a way to ignore these 3rd party errors, or possibly an ignore list we could add to?

Cannot call method 'split' of undefined

When submitting errors I keep getting this error on bugsnag's end:

Cannot call method 'split' of undefined

Here is a simple test I am using:

try {
  length("test");
} catch (error) {
  Bugsnag.notify("ErrorType", error);
}

Which generates this url: (token and app changed)

https://notify.bugsnag.com/js?notifierVersion=1.0.2&apiKey=changedtoprotectinocent&projectRoot=https%3A%2F%2Fsite.app&context=%2F&releaseStage=Testing&name=ErrorType&&stacktrace=Error%3A+stackgen%0A++++at+generateStacktrace+(https%3A%2F%2Fd2wy8f7a9ursnm.cloudfront.net%2Fbugsnag-1.0.2.js%3A132%3A13)%0A++++at+Object.window.Bugsnag.self.notify+(https%3A%2F%2Fd2wy8f7a9ursnm.cloudfront.net%2Fbugsnag-1.0.2.js%3A173%3A19)%0A++++at+filterList+(https%3A%2F%2Fsite.app%2Fcdn1360353379%2Fjs%2Fapp.js%3A629%3A15)%0A++++at+showFilter+(https%3A%2F%2Fsite.app%2Fcdn1360353379%2Fjs%2Fapp.js%3A611%3A19)%0A++++at+_.extend.route+(https%3A%2F%2Fsite.app%2Fcdn1360353379%2Fjs%2Fstructure.js%3A2246%3A30)%0A++++at+https%3A%2F%2Fsite.app%2Fcdn1360353379%2Fjs%2Fstructure.js%3A2443%3A19%0A++++at+Array.some+(native)%0A++++at+Function._.some._.any+(https%3A%2F%2Fsite.app%2Fcdn1360353379%2Fjs%2Fstructure.js%3A413%3A59)%0A++++at+_.extend.loadUrl+(https%3A%2F%2Fsite.app%2Fcdn1360353379%2Fjs%2Fstructure.js%3A2441%3A23)%0A++++at+_.extend.start+(https%3A%2F%2Fsite.app%2Fcdn1360353379%2Fjs%2Fstructure.js%3A2407%3A45)&ct=img

Async loading

With buffering for notify/notifyException Google Apps style.

JavaScript object expected thrown from inside Bugsnag notifier?

We’re seeing a consistent low-volume stream of errors come in from IE 10 and 11, and from the stack, it appears to be coming from Bugsnag itself (but it’s hard to tell for sure, since there’s so little information provided — only one frame in the trace).

Here’s the raw trace:

Error JavaScript object expected
    https://[redacted].harvestapp.com/assets/web_timesheet2-80a7d003a062a3d24384e0c0e4ebc022.js:1:244 t.bugsnag

Our source is minified, but the line given in Bugsnag is this block of code:

if (options && options.eventHandler) {
  lastEvent = event;
}
lastScript = currentScript;

// We set shouldCatch to false on IE < 10 because catching the error ruins the file/line as reported in window.onerror,
// We set shouldCatch to false on Chrome/Safari because it interferes with "break on unhandled exception"
// All other browsers need shouldCatch to be true, as they don't pass the exception object to window.onerror
if (shouldCatch) {
  try {
    return _super.apply(this, arguments);
  } catch (e) {
    // We do this rather than stashing treating the error like lastEvent
    // because in FF 26 onerror is not called for synthesized event handlers.
    if (getSetting("autoNotify", true)) {
      self.notifyException(e, null, null, "error"); 

Here‘s the error in our Bugsnag account. We’re sort of ¯_(ツ)_/¯ with ideas.

Seen anything like this before? I assume that if it’s indeed an issue in the notifier, that it’d be present on other accounts for IE 10 and 11.

Find other candidates for wrapping automatically

I found probably a way to find them all point 3 in your blog.

https://bugsnag.com/blog/js-stacktraces/

  1. Other async entry points. We've hooked into setTimeout, setInterval and requestAnimationFrame. I think there are a few other candidates for wrapping automatically, but I can't think of a reliable way to find them all.

I tried in reading the global available objects on window by looking at the source of firebug. They have autocomplete also for all available objects.

https://github.com/firebug/firebug/blob/master/extension/content/firebug/console/autoCompleter.js#L1873

Sourcemap links and github integration

Hi,

We're now using the JS reporter in production, and it's been really helpful already - thanks very much. The only issue we have is with the links from the error view to our application repo.

Our sourcemaps point to unminified locations available via our site, so for example the sourcemap for /assets/js/main.min.js points to locations in /javascripts/app/main.js - this needs to be the case so browser dev tools can fetch the original source.

In bugsnag's error view, these links point to our github repo. There, though, the files referred to are all contained in a public/ directory, so the github links don't work.

Would it be possible for the JS reporter to include an option for specifying the location of static assets within our repo?

Regards,
Simon

Add support for lazy metadata

eg.

Bugsnag.metaData = {
  config: {
    foo: 'bar',
    timeSincePageLoad: () => Math.round(window.performance.now()/1000)
}

Export as module for AMD and NodeJS-style bundling

Hi guys, I'm keen to start using Bugsnag in the client side as well as the server side (I'm already using the NodeJS wrapper).

To give you a bit of context, I develop a lot of JavaScript that runs on thousands of client sites, so it's not an option to add the Bugsnag script as per the documentation:

<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-2.min.js" data-apikey="YOUR-API-KEY-HERE"></script>

I use Browserify for development, although a lot of the community use RequireJS. So ideally I'd be able to do something like:

var bugsnag = require("bugsnag");

Have you looked into adding support for exporting Bugsnag as a module? The top of the Backbone annotate source code provides a pretty good example on how it could/should be done.

Support for refreshing rate-limit

At the moment we limit to 10 errors per-page-load. Some people worry this is too low for long-running single-page-apps. We should provide an API call (Bugsnag.newPage()) or something that resets this, and which can be called from inside the js router.

Missing Sourcemap Example

Your docs mention that bugsnag.js contains an example of the special comment at the bottom of the file to enable SourceMap support, but it does not.

Can you please create a SourceMap example?

Allow set app version

I tried but can't set the app version that show proportion of errors by version like I can do in nodejs version.

Accessing the error object in `beforeNotify`?

Hi, I've just started using bugsnag javascript with batman.js. We've always used it with Ruby and now that we're using it with JS too, we're very happy! Thanks for your work on such a great product.

I'm curious: is it possible to access the actual error that was thrown in a beforeNotify hook? I ask because some errors in batman.js have valuable information attached to them. Specifically, errors during XHR operations have request details -- and I want those!

thanks!

No stacktrace

Hey,
If I open an existing example than I see an stacktrace in bugsnag,
But if I modify it so:

function crashyFunction () {
    // Anonymous function
    (function () {
      throw new Error("Something broke");
    })();
  }

Than it stop showing me the stacktrace.

Currently in production I don't see any stacktrace because of that.

Even though Console shows it
screen shot 2013-05-17 at 12 00 24 pm

Investigate Ember grouping

Ember seems to wrap errors changing the stack trace which can cause grouping issues - lets try and find a nice solution to this.

400 RangeError: Maximum Call Stack size exceeded

I get this when uploading A file using POST request.

I use Express.js (latest)


var express = require('express')
    , routes = require('./routes')
    , http = require('http')
    , path = require('path')
    , mongoose = require('mongoose')
    , MongoStore = require('connect-mongo')(express)
    , mailer = require('nodemailer')

var bugsnag = require("bugsnag");
bugsnag.register("My API Code")

var app = exports.app = express();

// all environments
app.enable('trust proxy');
app.set('port', process.env.PORT || 3000); // Port
app.set('views', __dirname + '/views');
app.set('view engine', 'jade'); // Templating engine
app.set('view cache', true); // Cache views
app.set('app version', '0.0.2'); // App version
app.locals.pretty = process.env.NODE_ENV != 'production' // Pretty HTML outside production mode

app.use(bugsnag.requestHandler); // UnCommenting this line causes RangeError
app.use(express.logger('dev')); // Pretty log
app.use(express.limit('25mb')); // File upload limit
app.use("/", express.static(path.join(__dirname, 'public'))); // serve static files
app.use(express.bodyParser()); // Parse the request body
app.use(express.cookieParser()); // Parse cookies from header
app.use(express.methodOverride());
app.use(express.session({ // Session store
    secret: "mysecret",
    store: sessionStore,
    cookie: {
        maxAge: 604800000 // 7 days in s * 10^3
    }
}));
app.use(express.csrf()); // csrf protection

// development only
if ('development' == app.get('env')) {
    app.use(express.errorHandler()); // Let xpress handle errors
    app.set('view cache', false); // Tell Jade not to cache views
}

var server = http.createServer(app)
server.listen(app.get('port'), function(){
    console.log('Express server listening on port ' + app.get('port'));
});

// routes
//routes.router(app);

app.use(bugsnag.errorHandler);

Removing Bugsnag from global scope

Is there a documented method to remove Bugsnag from the global scope?

Right now I can just open up the browser console and start sending error messages!

Issue with the AMD Module Pattern and AlmondJS

The standard build includes the AMD Pattern:

!function(a) {
    if ("function" == typeof define && define.amd)
        define(function() {
            return a(window)
        });
    else if ("object" == typeof module && "object" == typeof module.exports)
        module.exports = a(global);
    else {
        var b = window.Bugsnag;
        window.Bugsnag = a(window, b)
    }
}

This doesn't play well with AlmondJS which is expecting a name to be the first param. The error causes Bugsnag not to be added to the window at all.

Could we get different options to build with, as opposed to AMD by default?

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.