Coder Social home page Coder Social logo

tinysentry's Introduction

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

tinysentry's People

Contributors

morrisjohns avatar

Stargazers

Ryan McQuen avatar

Watchers

 avatar

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.