Created
July 6, 2016 16:14
-
-
Save matsimitsu/65f95166ef8b0192e889159172e993cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class @Appsignal | |
constructor: -> | |
@action = "" | |
@tags = {} | |
set_action: (action) -> | |
@action = action | |
tag_request: (tags) -> | |
for key in tags | |
@tags[key] = tags[key] | |
sendError: (error) -> | |
data = { | |
action: @action | |
message: error.message | |
name: error.name | |
backtrace: error.stack.split("\n") | |
path: window.location.pathname | |
tags: @tags | |
environment: { | |
agent: navigator.userAgent | |
platform: navigator.platform | |
vendor: navigator.vendor | |
screen_width: screen.width | |
screen_height: screen.height | |
} | |
} | |
xhr = new XMLHttpRequest() | |
xhr.open('POST', '/appsignal_error_catcher', true) | |
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8') | |
xhr.send(JSON.stringify(data)) | |
appsignal = new Appsignal | |
window.appsignal = appsignal | |
window.onerror = (message, filename, lineno, colno, error) -> | |
appsignal.sendError(error) if error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment