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:
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.
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.
In this tutorial, you'll learn how to get started with using Raygun on an Angular web application.
From the list of frameworks, select the Angular framework. You will be presented with a screen to select Angular (v2+) or Angular1.x.
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.
npm install -g @angular/cli
Create an Angular app using the Angular CLI.
ng new AngularRaygun
You will have the Angular application created and installed with the required dependencies.
Navigate to the project directory and start the application.
cd AngularRaygun npm start
You will have the application running on http://localhost:4200/.
npm install raygun4js --save
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.
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:
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { ErrorHandler } from '@angular/core'; import { RaygunErrorHandler } from '../config/app.raygun.setup'; import { AppComponent } from './app.component'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule ], providers: [{ provide: ErrorHandler, useClass: RaygunErrorHandler }], bootstrap: [AppComponent] }) export class AppModule { }
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.
import { Router } from '@angular/router';
Modify the constructor method as shown:
constructor(private router: Router) {}
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.
When you run the application, you will have an error logged in the browser console.
NullInjectorError: No provider for Router!
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.
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.
Click on the recent requests displayed on the right side of the dashboard, and you will have detailed information related to the particular request.
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.
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.
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'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.
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 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 127.0.0.0.1 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 127.0.0.0.1
to the filter list.
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.
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.
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.
rg4js('setUser', { identifier: 'roy_agasthyan_unique_id', isAnonymous: false, email: 'royagasthyan@gmail.com', firstName: 'Roy', fullName: 'Roy Agasthyan' });
Here is how the config/app.raygun.setup.ts
file looks:
import * as rg4js from 'raygun4js'; import { ErrorHandler } from '@angular/core'; const VERSION_NUMBER = '1.0.0.0'; rg4js('apiKey', 'FehB7YwfCf/F+KrFCZdJSg=='); rg4js('setVersion', VERSION_NUMBER); rg4js('enableCrashReporting', true); rg4js('enablePulse', true); rg4js('setUser', { identifier: 'roy_agasthyan_unique_id', isAnonymous: false, email: 'royagasthyan@gmail.com', firstName: 'Roy', fullName: 'Roy Agasthyan' }); export class RaygunErrorHandler implements ErrorHandler { handleError(e: any) { rg4js('send', { error: e, }); } }
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.
Click on the user name to view the details associated with the particular user.
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.
By clicking on the different tabs, you can monitor the performance of the requested pages.
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.
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.
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.
The Best Small Business Web Designs by DesignRush
/Create Modern Vue Apps Using Create-Vue and Vite
/Pros and Cons of Using WordPress
/How to Fix the “There Has Been a Critical Error in Your Website” Error in WordPress
/How To Fix The “There Has Been A Critical Error in Your Website” Error in WordPress
/How to Create a Privacy Policy Page in WordPress
/How Long Does It Take to Learn JavaScript?
/The Best Way to Deep Copy an Object in JavaScript
/Adding and Removing Elements From Arrays in JavaScript
/Create a JavaScript AJAX Post Request: With and Without jQuery
/5 Real-Life Uses for the JavaScript reduce() Method
/How to Enable or Disable a Button With JavaScript: jQuery vs. Vanilla
/How to Enable or Disable a Button With JavaScript: jQuery vs Vanilla
/Confirm Yes or No With JavaScript
/How to Change the URL in JavaScript: Redirecting
/15+ Best WordPress Twitter Widgets
/27 Best Tab and Accordion Widget Plugins for WordPress (Free & Premium)
/21 Best Tab and Accordion Widget Plugins for WordPress (Free & Premium)
/30 HTML Best Practices for Beginners
/31 Best WordPress Calendar Plugins and Widgets (With 5 Free Plugins)
/25 Ridiculously Impressive HTML5 Canvas Experiments
/How to Implement Email Verification for New Members
/How to Create a Simple Web-Based Chat Application
/30 Popular WordPress User Interface Elements
/Top 18 Best Practices for Writing Super Readable Code
/Best Affiliate WooCommerce Plugins Compared
/18 Best WordPress Star Rating Plugins
/10+ Best WordPress Twitter Widgets
/20+ Best WordPress Booking and Reservation Plugins
/Working With Tables in React: Part Two
/Best CSS Animations and Effects on CodeCanyon
/30 CSS Best Practices for Beginners
/How to Create a Custom WordPress Plugin From Scratch
/10 Best Responsive HTML5 Sliders for Images and Text… and 3 Free Options
/16 Best Tab and Accordion Widget Plugins for WordPress
/18 Best WordPress Membership Plugins and 5 Free Plugins
/25 Best WooCommerce Plugins for Products, Pricing, Payments and More
10 Best WordPress Twitter Widgets
1 /20 Popular WordPress User Interface Elements
/10 Best WordPress Star Rating Plugins
/12 Best CSS Animations on CodeCanyon
/12 Best WordPress Booking and Reservation Plugins
/20 Best WordPress Calendar Plugins and Widgets
/12 Elegant CSS Pricing Tables for Your Latest Web Project
/24 Best WordPress Form Plugins for 2020
/14 Best PHP Event Calendar and Booking Scripts
/Create a Blog for Each Category or Department in Your WooCommerce Store
/8 Best WordPress Booking and Reservation Plugins
/Best Exit Popups for WordPress Compared
/Best Exit Popups for WordPress Compared
/11 Best Tab & Accordion WordPress Widgets & Plugins
/12 Best Tab & Accordion WordPress Widgets & Plugins
1 /New Course: Practical React Fundamentals
/Short Course: Better Angular App Architecture With Modules
/Preview Our New Course on Angular Material
/Build Your Own CAPTCHA and Contact Form in PHP
/Object-Oriented PHP With Classes and Objects
/Best Practices for ARIA Implementation
/Accessible Apps: Barriers to Access and Getting Started With Accessibility
/Dramatically Speed Up Your React Front-End App Using Lazy Loading
/15 Best Modern JavaScript Admin Templates for React, Angular, and Vue.js
/15 Best Modern JavaScript Admin Templates for React, Angular and Vue.js
/19 Best JavaScript Admin Templates for React, Angular, and Vue.js
/10 Best WordPress Facebook Widgets
13Hands-on With ARIA: Accessibility for eCommerce
/New eBooks Available for Subscribers
/Hands-on With ARIA: Homepage Elements and Standard Navigation
/Site Accessibility: Getting Started With ARIA
/How Secure Are Your JavaScript Open-Source Dependencies?
/New Course: Secure Your WordPress Site With SSL
/Testing Components in React Using Jest and Enzyme
/Testing Components in React Using Jest: The Basics
/15 Best PHP Event Calendar and Booking Scripts
/Create Interactive Gradient Animations Using Granim.js
/How to Build Complex, Large-Scale Vue.js Apps With Vuex
1 /Examples of Dependency Injection in PHP With Symfony Components
/Set Up Routing in PHP Applications Using the Symfony Routing Component
1 /A Beginner’s Guide to Regular Expressions in JavaScript
/Introduction to Popmotion: Custom Animation Scrubber
/Introduction to Popmotion: Pointers and Physics
/New Course: Connect to a Database With Laravel’s Eloquent ORM
/How to Create a Custom Settings Panel in WooCommerce
/Building the DOM faster: speculative parsing, async, defer and preload
1 /20 Useful PHP Scripts Available on CodeCanyon
3 /How to Find and Fix Poor Page Load Times With Raygun
/Introduction to the Stimulus Framework
/Single-Page React Applications With the React-Router and React-Transition-Group Modules
/12 Best Contact Form PHP Scripts
1 /Getting Started With the Mojs Animation Library: The ShapeSwirl and Stagger Modules
/Getting Started With the Mojs Animation Library: The Shape Module
/Getting Started With the Mojs Animation Library: The HTML Module
/Project Management Considerations for Your WordPress Project
/8 Things That Make Jest the Best React Testing Framework
/Creating an Image Editor Using CamanJS: Layers, Blend Modes, and Events
/New Short Course: Code a Front-End App With GraphQL and React
/Creating an Image Editor Using CamanJS: Applying Basic Filters
/Creating an Image Editor Using CamanJS: Creating Custom Filters and Blend Modes
/Modern Web Scraping With BeautifulSoup and Selenium
/Challenge: Create a To-Do List in React
1 /Deploy PHP Web Applications Using Laravel Forge
/Getting Started With the Mojs Animation Library: The Burst Module
/10 Things Men Can Do to Support Women in Tech
/A Gentle Introduction to Higher-Order Components in React: Best Practices
/Challenge: Build a React Component
/A Gentle Introduction to Higher-Order Components in React
/Creating Pretty Popup Messages Using SweetAlert2
/Creating Stylish and Responsive Progress Bars Using ProgressBar.js
/18 Best Contact Form PHP Scripts for 2022
/How to Make a Real-Time Sports Application Using Node.js
/Creating a Blogging App Using Angular & MongoDB: Delete Post
/Set Up an OAuth2 Server Using Passport in Laravel
/Creating a Blogging App Using Angular & MongoDB: Edit Post
/Creating a Blogging App Using Angular & MongoDB: Add Post
/Creating a Blogging App Using Angular & MongoDB: Show Post
/Creating a Blogging App Using Angular & MongoDB: Home
/Creating a Blogging App Using Angular & MongoDB: Login
/Creating Your First Angular App: Implement Routing
/Persisted WordPress Admin Notices: Part 4
/Creating Your First Angular App: Components, Part 2
/How Laravel Broadcasting Works
/Persisted WordPress Admin Notices: Part 2
/Create Your First Angular App: Storing and Accessing Data
/Persisted WordPress Admin Notices: Part 1
/Error and Performance Monitoring for Web & Mobile Apps Using Raygun
/Using Luxon for Date and Time in JavaScript
7 /How to Create an Audio Oscillator With the Web Audio API
/How to Cache Using Redis in Django Applications
/20 Essential WordPress Utilities to Manage Your Site
/Introduction to API Calls With React and Axios
/Beginner’s Guide to Angular 4: HTTP
/Rapid Web Deployment for Laravel With GitHub, Linode, and RunCloud.io
/Beginners Guide to Angular 4: Routing
/Beginner’s Guide to Angular 4: Services
/Beginner’s Guide to Angular 4: Components
/Creating a Drop-Down Menu for Mobile Pages
/Introduction to Forms in Angular 4: Writing Custom Form Validators
/10 Best WordPress Booking & Reservation Plugins
/Getting Started With Redux: Connecting Redux With React
/Getting Started With Redux: Learn by Example
/Getting Started With Redux: Why Redux?
/Understanding Recursion With JavaScript
/How to Auto Update WordPress Salts
/How to Download Files in Python
/Eloquent Mutators and Accessors in Laravel
1 /10 Best HTML5 Sliders for Images and Text
/Site Authentication in Node.js: User Signup
/Creating a Task Manager App Using Ionic: Part 1
/Introduction to Forms in Angular 4: Template-Driven Forms
/24 Essential WordPress Utilities to Manage Your Site
/25 Essential WordPress Utilities to Manage Your Site
/Get Rid of Bugs Quickly Using BugReplay
1 /Manipulating HTML5 Canvas Using Konva: Part 1, Getting Started
/10 Must-See Easy Digital Downloads Extensions for Your WordPress Site
/22 Best WordPress Booking and Reservation Plugins
/Understanding ExpressJS Routing
/15 Best WordPress Star Rating Plugins
/Creating Your First Angular App: Basics
/Inheritance and Extending Objects With JavaScript
/Introduction to the CSS Grid Layout With Examples
1Performant Animations Using KUTE.js: Part 5, Easing Functions and Attributes
/Performant Animations Using KUTE.js: Part 4, Animating Text
/Performant Animations Using KUTE.js: Part 3, Animating SVG
/New Course: Code a Quiz App With Vue.js
/Performant Animations Using KUTE.js: Part 2, Animating CSS Properties
/Performant Animations Using KUTE.js: Part 1, Getting Started
/10 Best Responsive HTML5 Sliders for Images and Text (Plus 3 Free Options)
/Single-Page Applications With ngRoute and ngAnimate in AngularJS
/Deferring Tasks in Laravel Using Queues
/Site Authentication in Node.js: User Signup and Login
/Working With Tables in React, Part Two
/Working With Tables in React, Part One
/How to Set Up a Scalable, E-Commerce-Ready WordPress Site Using ClusterCS
/New Course on WordPress Conditional Tags
/Building With Vue.js 2 and Firebase
6 /Best Unique Bootstrap JavaScript Plugins
/Essential JavaScript Libraries and Frameworks You Should Know About
/Vue.js Crash Course: Create a Simple Blog Using Vue.js
/Build a React App With a Laravel RESTful Back End: Part 1, Laravel 5.5 API
/API Authentication With Node.js
/Beginner’s Guide to Angular: Routing
/Beginners Guide to Angular: Routing
/Beginner’s Guide to Angular: Services
/Beginner’s Guide to Angular: Components
/How to Create a Custom Authentication Guard in Laravel
/Learn Computer Science With JavaScript: Part 3, Loops
/Build Web Applications Using Node.js
/Learn Computer Science With JavaScript: Part 4, Functions
/Learn Computer Science With JavaScript: Part 2, Conditionals
/Learn Computer Science With JavaScript: Part 1, The Basics
/Create Interactive Charts Using Plotly.js, Part 5: Pie and Gauge Charts
/Create Interactive Charts Using Plotly.js, Part 4: Bubble and Dot Charts
/Create Interactive Charts Using Plotly.js, Part 3: Bar Charts
/Awesome JavaScript Libraries and Frameworks You Should Know About
/Create Interactive Charts Using Plotly.js, Part 2: Line Charts
/Bulk Import a CSV File Into MongoDB Using Mongoose With Node.js
/Build a To-Do API With Node, Express, and MongoDB
/Getting Started With End-to-End Testing in Angular Using Protractor
/TypeScript for Beginners, Part 4: Classes
/Object-Oriented Programming With JavaScript
/10 Best Affiliate WooCommerce Plugins Compared
/Stateful vs. Stateless Functional Components in React
/Make Your JavaScript Code Robust With Flow
/Build a To-Do API With Node and Restify
/Testing Components in Angular Using Jasmine: Part 2, Services
/Testing Components in Angular Using Jasmine: Part 1
/Creating a Blogging App Using React, Part 6: Tags
/React Crash Course for Beginners, Part 3
/React Crash Course for Beginners, Part 2
/React Crash Course for Beginners, Part 1
/Set Up a React Environment, Part 4
1 /Set Up a React Environment, Part 3
/New Course: Get Started With Phoenix
/Set Up a React Environment, Part 2
/Set Up a React Environment, Part 1
/Command Line Basics and Useful Tricks With the Terminal
/Build a React App With a Laravel Back End: Part 2, React
/Build a React App With a Laravel RESTful Back End: Part 1, Laravel 9 API
/Creating a Blogging App Using React, Part 5: Profile Page
/Pagination in CodeIgniter: The Complete Guide
/JavaScript-Based Animations Using Anime.js, Part 4: Callbacks, Easings, and SVG
JavaScript-Based Animations Using Anime.js, Part 3: Values, Timeline, and Playback
10 Elegant CSS Pricing Tables for Your Latest Web Project
/Getting Started With the Flux Architecture in React
/Getting Started With Matter.js: The Composites and Composite Modules
/Getting Started With Matter.js: The Engine and World Modules
/10 More Popular HTML5 Projects for You to Use and Study
/Understand the Basics of Laravel Middleware
/Iterating Fast With Django & Heroku
/Creating a Blogging App Using React, Part 4: Update & Delete Posts
/Creating a jQuery Plugin for Long Shadow Design
/How to Register & Use Laravel Service Providers
2 /Unit Testing in React: Shallow vs. Static Testing
/Creating a Blogging App Using React, Part 3: Add & Display Post
/Creating a Blogging App Using React, Part 2: User Sign-Up
20 /Creating a Blogging App Using React, Part 1: User Sign-In
/9 More Popular HTML5 Projects for You to Use and Study
/Creating a Grocery List Manager Using Angular, Part 2: Managing Items
/9 Elegant CSS Pricing Tables for Your Latest Web Project
/Dynamic Page Templates in WordPress, Part 3
/Angular vs. React: 7 Key Features Compared
/Creating a Grocery List Manager Using Angular, Part 1: Add & Display Items
New eBooks Available for Subscribers in June 2017
/Create Interactive Charts Using Plotly.js, Part 1: Getting Started
/The 5 Best IDEs for WordPress Development (And Why)
/33 Popular WordPress User Interface Elements
/New Course: How to Hack Your Own App
/How to Install Yii on Windows or a Mac
/How to Register and Use Laravel Service Providers
/
waly Good blog post. I absolutely love this…