So what is RayGun? RayGun plugs into your apps and sends errors to the server. You as the developer receive an email stating that a new error has been found.
What’s great here is that you can resolve the error here with one click, the second link will open the error details on the site and immediately change its status to Resolved.
If you view the error you get all the information that you expect from a service like Raygun. Information about the device that the error occurred on, the used resolution (always 800x480 for Windows Phone as that is the base resolution, all apps are upscaled from there but it still reports as 800x480) and of course the complete stacktrace.
You can even view RAW data in JSON format.
<p>You can add comments to errors, assign people to them, all in all RayGun feels very complete. The mail arrived immediately after the error was thrown, shows up nicely on the dashboard, both the Windows Phone emulator and my Lumia 920 over 3G reported the error perfectly.</p> <h2>Implementing RayGun</h2> <p>Implementing RayGun in your app is very straigthforward, go to <a href="http://www.raygun.io">http://www.raygun.io</a> and register for a trial account (pricing can be found here <a title="http://raygun.io/pricing" href="http://raygun.io/pricing">http://raygun.io/pricing</a>). Once your account is registered you arrive at a page that tells you the steps to integrate RayGun with your app.</p> <p>Nifty feature here is that your api key is integrated in the sample code that they give you, so it’s just copy/paste. It may sound stupid but I really liked that sense of detail.</p> <p>First thing we need to do is add RayGun through NuGet.</p> <p><a href="http://i39.tinypic.com/2w2g3dh.jpg" target="_blank"><img src="http://i39.tinypic.com/2w2g3dh.jpg" width="307" height="205" /></a></p> <p>Bit weird here is that a readme file pops open stating that for Windows Phone I need to Reference the "Mindscape.Raygun4Net.WindowsPhone.dll but NuGet is smart enough to reference the correct DLL depending on the platform that you’re developing for.</p> <p>Second step is adding a property of the RayGunClient to App.xaml.cs and instantiating it with the api key.</p> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:133a595d-1f94-4d29-a3c0-3faed8ee899c" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div> <div style="background: #ddd; max-height: 300px; overflow: auto"> <ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"> <li><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">RaygunClient</span><span style="background:#ffffff;color:#000000"> RaygunClient { </span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000">; </span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000">; }</span></li> <li style="background: #f3f3f3"> </li> <li><span style="background:#ffffff;color:#808080">///</span><span style="background:#ffffff;color:#008000"> </span><span style="background:#ffffff;color:#808080"><summary></span></li> <li style="background: #f3f3f3"><span style="background:#ffffff;color:#808080">///</span><span style="background:#ffffff;color:#008000"> Constructor for the Application object.</span></li> <li><span style="background:#ffffff;color:#808080">///</span><span style="background:#ffffff;color:#008000"> </span><span style="background:#ffffff;color:#808080"></summary></span></li> <li style="background: #f3f3f3"><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> App()</span></li> <li><span style="background:#ffffff;color:#000000">{</span></li> <li style="background: #f3f3f3"> <span style="background:#ffffff;color:#000000">RaygunClient = </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">RaygunClient</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#a31515">"<your key here>"</span><span style="background:#ffffff;color:#000000">);</span></li> </ol> </div> </div> </div> <p>And for the initial setup there’s one step left. In the Application_UnhandledException method add the actual call to the RayGun servers (line 4).</p> <p> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4407ec41-2816-45cd-b3f8-df09270b156d" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div> <div style="background: #ddd; max-height: 300px; overflow: auto"> <ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"> <li><span style="background:#ffffff;color:#008000">// Code to execute on Unhandled Exceptions</span></li> <li style="background: #f3f3f3"><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> Application_UnhandledException(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">ApplicationUnhandledExceptionEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span></li> <li><span style="background:#ffffff;color:#000000">{</span></li> <li style="background: #f3f3f3"> <span style="background:#ffffff;color:#000000">RaygunClient.Send(e);</span></li> <li> </li> <li style="background: #f3f3f3"> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">Debugger</span><span style="background:#ffffff;color:#000000">.IsAttached)</span></li> <li> <span style="background:#ffffff;color:#000000">{</span></li> <li style="background: #f3f3f3"> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">// An unhandled exception has occurred; break into the debugger</span></li> <li> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">Debugger</span><span style="background:#ffffff;color:#000000">.Break();</span></li> <li style="background: #f3f3f3"> <span style="background:#ffffff;color:#000000">}</span></li> <li><span style="background:#ffffff;color:#000000">}</span></li> </ol> </div> </div> </div> <br />And from now on, any unhandled exception is logged in RayGun and you’re notified immediately when they occur. Try it out by adding a button on your mainpage and set this as click event.</p> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:39ed3185-dc27-475f-bfbd-aaf5166d7c28" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div> <div style="background: #ddd; max-height: 300px; overflow: auto"> <ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"> <li><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> ButtonBase_OnClick(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span></li> <li style="background: #f3f3f3"><span style="background:#ffffff;color:#000000">{</span></li> <li> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">throw</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">Exception</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#a31515">"raygun test"</span><span style="background:#ffffff;color:#000000">);</span></li> <li style="background: #f3f3f3"><span style="background:#ffffff;color:#000000">}</span></li> </ol> </div> </div> </div> <p>Since the RayGunClient in this example is a static property in App.xaml.cs you can reuse it anywhere in your project. You can even start creating completely custom errorlogs by passing in a RayGunMessage instance in the Send method.</p> <h2>Conclusion</h2> <p>RayGun works as advertised, no problem there at all. The dashboard looks great, is easy to navigate and shows all the necessary information. Crash reports arrive really fast and have nice little details like a one-click link to resolve an error. Small mistake in the readme file that opens when adding the NuGet package can be forgiven (who reads readme files anyway?)</p> <p>Will it be a great success? I don’t know. There’s quite a lot of competition out there, services that offer the same stuff as Mindscape does with RayGun but often times they are either free or provide a limited free service for hobby developers. Personally, I feel that MindScape should include a free price plan as well, limited in such a way that it’s only suitable for hobby projects of course since everyone needs to make a living. But those hobby developers can create buzz around the product so that professionals will pick up on it as well.</p> <p>By the way, this post only talks about the Windows Phone part of RayGun but it supports a wide array of platforms like ASP.net, JavaScript, PHP, Ruby on rails, Java and ColdFusion.</p> <p>So all in all, great product, works as advertised! If you want a t-shirt come to the next MADN user group event after the summer break and hopefully we’ll have some to hand out!</p> <p><a href="http://www.mindscapehq.com/blog/index.php/2013/03/05/get-an-awesome-raygun-t-shirt/" target="_blank"><img src="http://www.mindscapehq.com/blog/wp-content/uploads/2013/02/Double-T-shirts1.jpg" width="299" height="228" /></a></p>
This is an imported post. It was imported from my old blog using an automated tool and may contain formatting errors and/or broken images.
Leave a Comment