Angular

BugSplat supports the collection of errors in Angular 5+ applications. The bugsplat-ng npm package implements Angular’s ErrorHandler interface in order to post errors to BugSplat where they can be tracked and managed.


Adding BugSplat to your Angular application is extremely easy. Before getting started please complete the following tasks:

  • Sign up for BugSplat
  • Create a new database for your application
  • Check out the live demo of BugSplat’s Angular error reporting
  • View the my-angular-crasher sample application to see an example BugSplat integration

Simple Configuration

To collect errors and crashes in your Angular application, run the following command in terminal or cmd at the root of your project to install bugsplat-ng:

npm install bugsplat-ng --save

Import BugSplatErrorHandler and BugSplatConfiguration into your app module from bugsplat-ng:

app.module.ts

import { BugSplatErrorHandler, BugSplatConfig } from 'bugsplat-ng';

Add a provider for ErrorHandler with the useClass property set to BugSplatErrorHandler:

app.module.ts

In your app module, add a provider for BugSplatConfiguration with the useValue property set to an instance of your BugSplat configuration:

app.module.ts

Import the HttpClient module from @angular/common/http and add it to your module’s imports:

app.module.ts

Throw a new error in your application to test the bugsplat-ng integration:

app.component.ts

throw new Error("BugSplat!");

Navigate to the Crashes page in BugSplat and you should see a new crash report for the application you just configured. Click the link in the Id column to see details about your crash on the Individual Crash page:


Extended Configuration

You can post additional information to BugSplat by creating a wrapper around the BugSplat object. To do so, create a new class that implements Angular’s ErrorHandler interface. In the handlerError method make a call to BugSplat.post passing it the error object:

my-angular-error-handler.ts

BugSplat provides the following properties and methods that allow you to customize its functionality:

bugsplat-error-handler.ts

In your app module, update the useClass property in your ErrorHandler provider to the name of the class you just created:

app.module.ts


Contributing

BugSplat loves open source software! If you have suggestions on how we can improve this integration, please reach out to support@bugsplat.com, create an issue in our GitHub repo or send us a pull request.