npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jserrlogger

v1.0.3

Published

A javascript module that catches javascript errors and posts them back to a server to be logged and managed.

Downloads

5

Readme

jserrlogger

A javascript module that catches javascript errors and posts them back to a server to be logged and managed.

Including jserrlogger.js

Add a script tag to your page

<script src="jserrlogger.min.js"></script>

Install the handler

<script>
    jserrlogger.install("http://www.your-url.com/err_js_endpoint");
</script>

Install the handler with options

<script>
    var options = {
        upperLimit: 5,
        debug: 1,
        timeout: 3000
    };
    jserrlogger.install("http://www.your-url.com/err_js_endpoint", options);
</script>

Options available to specify:

  • upperLimit - when set, only report the first upperLimit errors in one browser session, ignore any errors after that
  • debug - when enabled, log to console any errors
  • timeout - timeout after which the jsonp script is removed from the DOM (in ms)

Implement the server side endpoint

jserrlogger will send GET requests like these:

http://www.your-url.com/err_js_enpoint/?i=1&sn=<encoded_page_url>&fl=<encoded_js_file_name>&ln=<line_number>&err=<encoded_err_message>

Handle it on the server side as you see fit (i.e. log them in a DB, email them, etc.)

You can report your own errors

Use jserrlogger.logErr call to report your own errors to the server side.

    jserrlogger.logErr("Someone stepped on the boobytrap.", "app.js", 834);

How does it work?

jserrlogger.js installs a callback on window.onerror. This is a callback that gets called whenever there's a javascript error on a page (which is not caught). These errors can come up from your code or any 3rd party js libraries you use. jserrlogger.js will then submit a JSONP request to your configured URL endpoint (the one you specify in the call to install) and send you in the query string:

  • i - an enumerator of the exception since the start of the browser session (0 - first, etc.)
  • sn - the URL of the page as shown in the browser where the exception was raised
  • fl - the js file name where the exception was raised
  • ln - the line number where the exception was raised
  • err - the actual message of the exception raised

jserrlogger.js will also call any previously installed window.onerror callback.