Skip to content

Pushes exception or logging info into GetSentry.com from the browser similar to raven.js

License

Notifications You must be signed in to change notification settings

MorrisJohns/TinySentry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TinySentry

This pushes exception or logging info into GetSentry.com from the browser.

Similar to the combination of https://github.com/getsentry/raven-js with https://github.com/csnover/TraceKit, but shorter code and hopefully a little more readable.

Please don't report bugs, features, or ask me anything. This is a simplification of other code, provided only because it might be useful to others.

Beware GetSentry sometimes overzealously consolidates/aggregates errors even though they are different. This code repeats the message in a string tag, so that at least you can tell if an error has been consolidated.

To use TinySentry, you will need to change the sentry_project and sentry_key. Go to Settings | Client Keys in getsentry.com dashboard and get the project and key from out of the client key e.g. https://ab1234ab1234ab1234ab1234ab1234:[email protected]/99999 where the number at the end is the sentry_project and the uid at the start is the sentry_key.

Ground up rewrite (instead of raven.js) because:

  • I found raven.js hard to use
  • raven.js plus tracekit.js is 16000 bytes, versus tinysentry.js is 3000 bytes (approx compressed but not gzipped byte counts).
  • raven.js/tracekit.js loses stack information because they drop stack frames if they can't parse them (eval, internal functions, anonymous functions etc).
  • however tracekit.js supports stack frames on non-modern browsers better (at the cost of codesize, and an awful setTimeout() call for window.onerror).

Take extra care if editing this code because if this code has exceptions, you won't know about it!

Fiddler will prevent logging for some browsers. e.g. Firefox won't allow https interception, so nothing gets logged if Fiddler running.

You can capture onerror by calling TinySentry.onerrorRegister(). Exceptions caught this way are logged as level:'info' because it is presumed that you use try/catch around your JavaScript entry points, in which case most errors caught by onerror are in third party code that you can't care about or fix.

Stack frames are supported by modern browsers (IE10+, most FF, Android AOSP, Chrome, iOS8+). Older browsers won't get the stack.

If you are self hosting GetSentry code, the maybe look at https://github.com/Banno/getsentry-javascript-lite

About

Pushes exception or logging info into GetSentry.com from the browser similar to raven.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published