www 101

All you need to know about the internet

Have a Question?

If you have any question you can ask below or enter what you are looking for!

Error and Performance Monitoring for Web & Mobile Apps Using Raygun

Fixing a bug is a whole lot easier when you know how it occurred, but that may not always be the case. Once the software has been shipped, you are left at the mercy of customers, who may not always report the crash.

When the code crashes, you log the errors in the log file, and hence continues the journey of a developer to trace the occurrence of the bug by looking through the log files. Guessing the root cause of the crash from the log file may take a lot of your valuable time.

Is there an easier way to troubleshoot the cause of an error in your software application? Raygun offers a set of interesting solutions to keep an eye on errors when they arise in your web and mobile applications. 

From the official documentation, Raygun offers:

Complete visibility into problems your users are experiencing and workflow tools to solve them quickly as a team.

Raygun offers four tools to make it easier to deal with errors and crashes in your application:

  • The Raygun Crash Reporting tool helps you monitor and replicate each crash and error that occurred in your application.
  • The Real User Monitoring tool helps to capture each user session and other related information to gauge the user experience.
  • The User Tracking tool helps to categorise crashes and errors based on application users. 
  • The Raygun Deployment Tracking tool makes it easier to track each release and shows you how it affects the overall performance of the software application.

In this tutorial, you’ll learn how to integrate Raygun tools with your web application to monitor and trace bugs. For this tutorial, you’ll be integrating Raygun tools with an Angular web application.

Getting Started With Raygun

You can use Raygun with a number of programming languages and frameworks. For the sake of this tutorial, let’s see how to get started using Raygun with an Angular web application.

To get started, you need to create an account on Raygun. Once you have created the account, you will be presented with a screen to select the preferred language or framework.

Raygun - Select Framework To Integrate With

In this tutorial, you’ll learn how to get started with using Raygun on an Angular web application.

Using Angular With Raygun

From the list of frameworks, select the Angular framework. You will be presented with a screen to select Angular (v2+) or Angular1.x

Raygun - Angular Framework Selected

Since you are going to learn how to integrate Raygun with Angular 4, focus on the tab Angular (v2+)

Before integrating Raygun with Angular, you need to create an Angular application. Let’s get started by creating an Angular application.

First, you’ll need to install the Angular CLI globally.

Create an Angular app using the Angular CLI.

You will have the Angular application created and installed with the required dependencies.

Navigate to the project directory and start the application.

You will have the application running on http://localhost:4200/.

Angular App Default Home
Install the raygun4js library using the Node Package Manager (npm).

Inside the src/config folder, create a file called app.raygun.setup.ts.

Copy the setup code from Step 2 of the Angular (v2+) and paste it into the app.raygun.setup.ts file.

Raygun Error Handling Code

Import the RaygunErrorHandler in the app.module.ts file inside the Angular application, and add the custom error handler. Here is how the app.module.ts file looks:

Now you have added a custom error handler RaygunErrorHandler, which will handle the errors.

Let’s add some code to create an error. Import the Router in the app.component.ts file.

Modify the constructor method as shown:

The above code will throw an error when you run the application since it hasn’t been imported in the AppModule. Let’s see how Raygun captures the errors. Save the above changes and restart the application. 

Point your browser to http://localhost:4200. Check the browser console and you will have the errors logged.

Raygun Dashboard

When you run the application, you will have an error logged in the browser console.

From the Raygun application, click on the Dashboard tab on the left side, and you will have detailed information about the requests logged by Raygun.

Raygun Dashboard

As seen in the Raygun dashboard, it shows the session count, recent request, error instance counts, etc., related to the Angular application which you configured with Raygun.

Raygun Dashboard - Recent Requests

Click on the recent requests displayed on the right side of the dashboard, and you will have detailed information related to the particular request.

Raygun - Detailed Request Info

Raygun Crash Reporting 

Application crashes are a common scenario when dealing with software applications. Lots of these crashes occur in real-time scenarios and are hence difficult to track without a proper crash reporting system in place.

Raygun provides a tool called Crash Reporting which provides a deeper insight into application crashes. Let’s have a look at how Crash Reporting works.

You have a bug in your Angular app which is crashing it. Let’s see how it gets reported using Raygun Crash Reporting.

Click on the Crash Reporting tab from the menu on the left-hand side. You will have the error report listed.

Raygun Crash Reporting

In the Raygun crash reporting tab, it shows the errors that occurred in the application. In the tabs shown above, the errors have been categorized into Active, Resolved, Ignored, and Permanently ignored.

The error that you encountered while running the application has been logged under the Active tab.

On clicking the listed error, you’ll be redirected to another page with detailed information related to the error. On this page, you’ll have information such as the error summary, HTTP information, environment details in which the error occurred (such as the OS, browser, etc.), raw error information, and the error stack trace.

Raygun Detailed Error Information

When displaying information related to a particular error, Raygun provides you with the features to change the state of the errors as per your fix. You can change the status to active, resolved, ignored, etc.

Raygun Crash Reporting Error Status

Raygun’s crash reporting tool provides a feature to add comments to the errors, which is really helpful in discussing details about the bug when working in a team.

Raygun Crash Reporting Comment For Error

Crash Reporting: Settings

Crash reporting comes with a couple of settings which make it easier for the user to manage the errors that have occurred in the application.

It provides you with the option to enable live refresh, first seen date on an error group, and the user count on the dashboard.

You have the option to make bulk error status changes and the option to remove all the errors that occurred in the application. 

Raygun Crash Reporting Settings

Crash Reporting: Inbound Filters

Raygun provides an option to filter requests based on the IP address, machine name, etc. If you don’t want to track an error from a particular IP address, you can create an inbound filter, and the error from the application running on that IP address won’t be tracked further.

Let’s try to add a filter for your application running on and see if it gets tracked.

From the left side menu, under the Crash Reporting tab, click on the Inbound Filters link. Add the IP address to the filter list.

Raygun Crash Reporting FIlter

Now, if you try to run the application, on crashing it won’t get tracked in the crash reporting screen since it’s been filtered out.

You can also add filters based on machine names, HTTP, build versions, tag, and user agent.

Raygun User Tracking

Most of the issues encountered when the user is using the software go unreported. The probability of a frustrated user reporting an issue is quite low. Hence, you tend to lose the user feedback to improve the quality of your software.

Raygun provides an affected user tracking report. This report shows the list of users from your application who have encountered errors. It gives a full view of how that particular user encountered that particular error. You can view this report by clicking on the Users tab on the left side of the screen. 

In your Angular application, you haven’t yet used the affected user details feature of Raygun. Hence in the affected user tracking report you will find the user details as anonymous along with the error details.

Click on the Anon User link from the user tracking information, and you’ll see the detailed information related to that particular anonymous user. Detailed such as the active error info, user experience, sessions, devices used by the user, etc., will all be displayed in the user report.

Raygun User Tracking Detailed Report

You can add the user info details to the Raygun config file. Add the following code to the config/app.raygun.setup.ts file to send the user info details to Raygun.

Here is how the config/app.raygun.setup.ts file looks:

Save the above changes and reload the Angular web application. Go to the Raygun application console and click on the Users tab from the left side menu. You will be able to see the new users displayed in the list of affected users.

Raygun Users

Click on the user name to view the details associated with the particular user.

Raygun Real User Monitoring

Raygun’s Real User Monitoring tool gives you an insight into the live user sessions. It lets you identify the way the user interacts with your application from the user environment and how it affects your application’s performance.

Let’s run your Angular application and see how it’s monitored in the Real User Monitoring tool. Click on the Real User Monitoring tab in the menu on the left-hand side. You will be able to view the live user details and sessions.

Raygun - Real User Monitoring

By clicking on the different tabs, you can monitor the performance of the requested pages.

Raygun Real User Monitoring - Performance

It gives information on the slowest and the most requested pages. Based on a number of metrics, you can monitor the pages with high loading time and fix them to improve the application’s performance.

There are a number of other tabs in Real User Monitoring which give useful insight into user information based on different parameters like browsers, platforms, and user locations.

Raygun Deployment Tracking

When you release a new version of your software, it’s expected to be a better version with bug fixes and patches for the issues reported in earlier versions.

Raygun provides a tool to track the deployment process and to monitor the releases. Click on the Deployments tab from the left side menu and you will be presented with information on how to configure Raygun with your deployment system. Once you have it configured, you’ll be able to view the detailed report related to each release.

Setting up a deployment tracking system will enable you to get deeper insight into each of the releases. You can monitor the trend and see whether you are improving the build quality or taking it down. With each new release, you can compare the error rate and track any new errors that cropped up in the releases.

I recommend reading the official documentation to see how to integrate Raygun deployment tracking with your deployment system.

Wrapping It Up

In this tutorial, you saw how to get started using Raygun with an Angular web application. You learnt how to use the Crash Reporting tool to monitor and trace the occurrence of a crash. Using the Real User Monitoring tool, you saw how to understand the user experience details such as the page load time, average load time, etc.

The User Tracking tool lets you monitor and categorise errors and crashes based on the application users. The Deployment Tracking tool helps you track each release of your application for crashes and errors and lets you know how it’s affecting the overall health of your application.

For detailed information on integrating Raygun with other languages and frameworks, I would recommend reading the official Raygun documentation.

If you have any questions and comments on today’s tutorial, please post them below.