post errors to hoptoad from actionscript
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
protected function sendToHoptoad (msg:String):void { | |
var yamlData:String = 'notice: \n' | |
+ ' api_key: YOUR_API_KEY\n' | |
+ ' error_message: "' + msg + '"\n' | |
+ ' backtrace: \n' | |
+ ' request: {}\n' | |
+ ' session: {}\n' | |
+ ' environment: \n' | |
+ ' RAILS_ENV: [YOUR_ENV_HERE]\n'; | |
var req:URLRequest = new URLRequest("http://hoptoadapp.com/notices"); | |
req.method = URLRequestMethod.POST; | |
req.data = yamlData; | |
req.contentType = "application/x-yaml"; | |
var loader:URLLoader = new URLLoader(req); | |
loader.addEventListener(Event.COMPLETE, function (e:Event):void { | |
trace("Error tracker response: " + (URLLoader(e.target).data)); | |
}); | |
loader.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void { | |
trace("Failed to send error report. Failure message: " + e); | |
}); | |
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, function (e:HTTPStatusEvent):void { | |
trace("HTTP Status: " + e); | |
}); | |
loader.load(req); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment