Skip to content

Instantly share code, notes, and snippets.

@eanakashima
Created December 10, 2013 19:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eanakashima/7896696 to your computer and use it in GitHub Desktop.
Save eanakashima/7896696 to your computer and use it in GitHub Desktop.
client-side error beacon code in coffeescript
class YourNamespace.Errors
window.onerror = (e) => @report(e)
@report: (e) ->
img = new Image(1,1)
img.src = '//' + your_config.errors_host + '/images/error_pixel.gif'
img.style.display='none'
document.getElementsByTagName('body')[0].appendChild(img);
@eanakashima
Copy link
Author

Just a sketch. You may also want to check if window.onerror has already been set, since other code or third-party tools may already have set a handler there, and call that function as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment