Giter Site home page Giter Site logo

getsentry / sentry-javascript Goto Github PK

View Code? Open in Web Editor NEW
7.6K 121.0 1.5K 109 MB

Official Sentry SDKs for JavaScript

Home Page: https://sentry.io

License: MIT License

JavaScript 7.65% HTML 0.93% TypeScript 90.15% Shell 0.33% CSS 0.13% Handlebars 0.04% Svelte 0.09% Astro 0.10% Python 0.01% C++ 0.55% Vue 0.03%
crash-reporting raven sentry javascript javascript-client error-monitoring sentry-client node typescript hacktoberfest

sentry-javascript's Introduction

Sentry

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us Check out our open positions

Build & Test codecov npm version Discord

Official Sentry SDKs for JavaScript

This is the next line of Sentry JavaScript SDKs, comprised in the @sentry/ namespace. It will provide a more convenient interface and improved consistency between various JavaScript environments.

Links

  • Documentation
  • Forum
  • Discord
  • Stack Overflow
  • Twitter Follow

Contents

Supported Platforms

For each major JavaScript platform, there is a specific high-level SDK that provides all the tools you need in a single package. Please refer to the README and instructions of those SDKs for more detailed information:

Installation and Usage

To install a SDK, simply add the high-level package, for example:

npm install --save @sentry/browser
yarn add @sentry/browser

Setup and usage of these SDKs always follows the same principle.

import { init, captureMessage } from '@sentry/browser';

init({
  dsn: '__DSN__',
  // ...
});

captureMessage('Hello, world!');

Other Packages

Besides the high-level SDKs, this repository contains shared packages, helpers and configuration used for SDK development. If you're thinking about contributing to or creating a JavaScript-based SDK, have a look at the resources below:

Bug Bounty Program

Our bug bounty program aims to improve the security of our open source projects by encouraging the community to identify and report potential security vulnerabilities. Your reward will depend on the severity of the identified vulnerability.

Our program is currently running on an invitation basis. If you're interested in participating, please send us an email to [email protected] and tell us, that you are interested in auditing this repository.

For more details, please have a look at https://sentry.io/security/#vulnerability-disclosure.

sentry-javascript's People

Contributors

abhiprasad avatar ahmedetefy avatar anonrig avatar benvinegar avatar billyvg avatar bkonkle avatar byk avatar c298lee avatar dcramer avatar dependabot[bot] avatar dominikb2014 avatar getsentry-bot avatar github-actions[bot] avatar hazat avatar iker-barriocanal avatar ipmb avatar jonasba avatar k-fish avatar kamilogorek avatar lewisjellis avatar lforst avatar lms24 avatar lobsterkatie avatar mattrobenolt avatar maxbittker avatar mitsuhiko avatar mydea avatar onurtemizkan avatar rhcarvalho avatar timfish 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  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

sentry-javascript's Issues

exceptions raised when running on non-standard ports like 8000

When using raven-js on a site running on a non port 80/443 server, doing this fails:

// capture an exception
try {
    errorThrowingCode();
} catch(err) {
    Raven.captureException(err);
}

i.e. running locally for testing on http://localhost:8000 (with that set as allowed origin for CORRS), you'll get raven exceptions as it strips the from the ":" on wards.

Script Error. How to see full message instead.

I see you have added feature with "Script Error" for some javascript error reports ( #14 ). We have a lot of this bugs on our servers. Is possible to see real error description?
I can found this config-option.

Better non-signing implementation

We need to implement some behavior in Sentry (so this ticket applies to both raven-js and Sentry) that removes the need for Raven to send a signed request. The signed request in JS doesn't actually provide any benefit, as it exposes the signing key (secret key).

Two things we should do:

  1. Implement ProjectDomain (model exists in Sentry, but its not implemented yet) to check for whitelisted trusted domains.
  2. Fully support non-signed requests officially. This should probably just be public key to allow it, and should not be enabled in Sentry by default. Possibly make it a per-project option that says "allow public errors" which dont require the secret key or a signed request.

Add setUser

// Set the user data
Raven.setUser({
  email: '[email protected]'
});

// Clear the user data
Raven.setUser();

This would fill in sentry.interfaces.User

Keep Built Script in Repository

As discussed on the IRC channel, the usage instructions for Bower aren't exactly right since you'll end up running a version of the script that hasn't yet been compiled with the template files (which contain the closure and module definition).

In order to use JS package managers like Bower or Volo with raven-js, the built version needs to be available on GitHub (either in this repo or another).

Cross-domain support in IE9

Hi there,

Configuration

I tried to use Raven-js in order to perform cross-domain logging, with JQuery.
Everything works in Chrome, but it fails in IE9.

Problem

The error returned by the ajax call was at first

No Transport

After reviewing this thread, I forced the CORS of jQuery :

$.support.cors = true;

The error message changes to

Access Forbidden

I guess this is because "custom headers arent supported in IE9" as said in the code.

Alternatives

Before trying to switch to Raven, I managed to achieve similar cross-domain reporting on IE9 by switching to JSONP when IE9 and Cross-domain are detected.

I would be happy to push that trick to this repository, but I am not sure yet that this is the issue.
What do you think ?

Cheers,

Antoine

Swap out AJAX with basic XDR

We should change the AJAX call to create an iframe + form and POST to the endpoint, this will allow it to work on non-same-domain installs.

Uncaught TypeError: Cannot call method 'slice' of undefined

We're seeing this occasionally in our error logs: Uncaught TypeError: Cannot call method 'slice' of undefined. This appears to be the offending line:

args=fn[1].slice(0,-1).split(',');

The UA is 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11'

Get rid of ignoreErrors

This is a remnant of pre 1.0 days with the "Script error." issue, but this has since been hardcoded into raven. It doesn't really help with anythign else.

Configurable in_app filters for ignoring frames

Start by a default filter for raven\.(min\.)js$ to filter out our own builds.

This will overall be better than checking function name since that's usually horrible inaccurate, especially with minification/obfuscation.

Document non CDN install

Realistically we don't want to encourage everyone to install from the CDN, and even more importantly we need to point them at an actual release they can download (e.g. that includes the compressed/uncompressed/sourcemap).

Probably worthwhile to document bower or whatever is supported as well.

Add pre-reporting callback to be able to add per-report tags to a particular event.

So, before a request is going to get fired off to sentry, handing that event to a callback so that I could return a set of tags or options to be appended to the requrest.

An example use (for me in paricular) is adding tags that specify requireJS: true/false to events that get caught by require's onError such as script loading or other stuff hapenning in a require load.

This is useful if the same event gets fired in both place for filtering.

Raven-JS ignores exceptions re-raised by TraceKit

There's this code in Raven:

    // TraceKit.report will re-raise any exception passed to it,
    // which means you have to wrap it in try/catch. Instead, we
    // can wrap it here and only re-raise if TraceKit.report
    // raises an exception different from the one we asked to
    // report on.
    try {
        TK.report(ex, options);
    } catch(ex1) {
        if(ex !== ex1) {
            throw ex1;
        }
    }

which seems to go against the point of reraising the exception in TraceKit:

/*
 * Tries to catch all unhandled exceptions and report them to the
 * subscribed handlers. Please note that TraceKit.report will rethrow the
 * exception. This is REQUIRED in order to get a useful stack trace in IE.
 * If the exception does not reach the top of the browser, you will only
 * get a stack trace from the point where TraceKit.report was called.
 */

By ignoring the exception here, TraceKit doesn't get the opportunity to create a stack trace for some versions of IE, which means you'll only get the top stack frame, if you're lucky.

Is there any reason the exception is caught here? If you want to ignore the exception, you can install a default window.onerror handler that returns true, or patch TraceKit so that exceptions are only reraised (and then ignored) if the stack trace is incomplete.

don't strip url hashes

Currently our application relies on hashes, I don't know on which page the error is happened.
Probably you might want to send the full url location.href too.

Bad Request: Request Line is too large (5465 > 4094)

I tried the current master (1.0-beta11) to be able to use setUser(). However, events can not be logged anymore because the request line is too long (my sentry installation is deployed behind Apache, which limits requestline lengh to 4096).

The makerequest function has been changed from a POST to a GET:

function makeRequest(data) {
    new Image().src = globalServer + getAuthQueryString() + '&sentry_data=' + encodeURIComponent(JSON.stringify(data));
}

With GET requests the data will always be limited (IE8 and IE9 limit it up to 2083 chars), and I think POST should always be used (or at least be an option).

Automatically log all thrown errors?

Is there a way to get Raven to log all thrown errors? For some reason, it logs some throw calls but not others. I found that it tends to not log behavior that is nested further down the call stack.

raven-js 5.2/5.3 incompatible with sentry 4.9.8/5-dev

Information:

20:57 < joar> so, since raven-js is incompatible with sentry 5.0.0-dev, is 4.9.8 the way to go?
20:58 < joar> 4.9.8 is also incompatible with raven-js 5.3
21:00 < joar> oh, perhaps I should use raven-js 5.2 instead.
21:03 < joar> nope, CORS pre-flight request still fails.
21:05 -!- dz0ny [[email protected]] has quit [Ping timeout: 276 seconds]
21:08 < joar> all right, using jQuery instead of zepto solves the CORS pre-flight request issue.
21:09 < joar> no wait, it doesn't.
21:09 < joar> but it at least tries to POST even though.
21:10 < joar> .. but when it posts, I receive an HTTP 400 reply, and the same issue as with sentry 5-dev and raven-js 5.3 comes into effect: https://gist.github.com/4603075e14a15fb1db77
21:20 < joar> same issue with raven-js 5.2 against app.getsentry.com.
21:22 < joar> oh wait, forgot to reload my config.
21:26 < joar> app.getsentry replies with an HTTP 400 and "Invalid data: Unable to validate interface, 'sentry.interfaces.Stacktrace':"
-- https://gist.github.com/258a66f77781c143792b

Add hook/callback/event to be fired when raven has reported an error to sentry

I've been trying to add custom error handling to sometimes reload a page when a particular type of error occurs, but I'd also like to report that through raven to sentry.

My current way of accomplishing this is by exposing the private TraceKit used by Raven through a Raven.TK variable.

This is sort of sub optimal, though, since TraceKit does all sorts of weird stuff if you're on IE, etc, and I'm not always guaranteed that my tracekit handler will be called before Raven's TK handler.

It also requires me to know that Raven uses TK and how TK works.

In reality, all I need to know is that Raven has caught an error, and successfully reported it Sentry, and also ideally the error it reported.

Then I could let Raven handle errors, report them, and when it's done, look at the error and try reloading.

Thanks.

[Proposal] Blacklist "Script Error."

We did this at DISQUS because we were getting it way too often and the message itself was not useful.

Could be an option thats just enabled by default as well.

Explicit dataType

If you change jQuery defaults you can break the ajax request.

e.g. change defaults to jsonp type (instead of json) and it will no longer work

bower install is unusable without resolve tracekit dependency by hand

Hi!

I've just pump to v1.0.0 and notice it's no longer tracekit inside your repo, because bower don't follow cloning the submodule.

For now installing tracekit as component bower install tracekit gets the job done, but maybe creating a folder build/ with the minified version with the tracekit could be a way to go. I'll prefer not to download by hand your handy version in the CDN, and keep bower handle my project dependencies.

Probably it's more an bower issue, than yours, but's just to let you know.

fast track to this issue:

cd /tmp && mkdir tracekit-bug && cd tracekit-bug #just to use a clean folder
bower install raven-js
ls components/raven-js/vendor/TraceKit/ #nothing here :(

impressive project BTW!

Cheers,
iknite

Raven-js doesn't work

With the latest update, I am no longer able to use raven-js. All errors result to:

OPTIONS https://app.getsentry.com/api/3302/store/ 200 (OK) jquery.min.js:4
POST https://app.getsentry.com/api/3302/store/ 403 (FORBIDDEN) 

captureException errors when a string is passed

It doesn't get past the interface validator in Sentry.

Might be a fix I can make in the server to discard invalid frames, but we should probably do something in raven-js as well (probably just call captureMessage instead, or throw an error).

Use Raven-js coupled to sentry in phoneGap app

Hi,

I'm trying to use sentry with raven-js on a phoneGap project.
I've a little problem...it's about URL security.

In sentry for raven-js i need to define some URL to protect my server.
But, in phoneGap i've no URL on my app. So, sentry doesn't listen to my app.

How can i solve it?
Any modification is possible to allow all URL for a define project?

Thank's!

getsentry org maintainership

I've been (officially) taking over maintainership of a bunch of the primary repos on the getsentry org. Wondering if you guys still have time to maintain this, or if you'd be interested in moving that over as well.

Send tags with captureException

I haven't been able to send tags with captureException, but it is possible with captureMessage. Example:

Raven.captureException(exc, {tags: {'host': host}}); // Doesn't send "host" tag to sentry

Raven.captureMessage(exc, {tags: {'host': host}}); // Sends "host" tag to sentry

Create a plugin architecture for patching libraries

To prevent bloat in the core lib, come up with a strategy for plugins. These plugins would be small, but would easily hook in and wrap the offerings.

For example, a requirejs plugin would wrap the define/require blocks and anythign else it can fine.

jQuery would wrap it's common callbacks, etc.

This will allow us to be as flexible as possible by keeping an archive of plugins and let users pick and choose what they want.

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.