---
title: "Log Angular 2 Errors with Sentry"
description: "Sentry now supports Angular 2 with full TypeScript support"
url: "https://blog.sentry.io/sentry-and-angular2/"
canonical_url: "https://blog.sentry.io/sentry-and-angular2/"
authors: ["Ben Vinegar"]
published: "2016-06-27"
category: "Product Updates"
---

# Log Angular 2 Errors with Sentry

Angular 2 is almost here, and so it’s with great pleasure that Sentry now officially provides support for [Angular 2 error](https://sentry.io/for/angular/) tracking through our [browser JavaScript SDK](https://docs.sentry.io/hosted/clients/javascript/) – including full support for use with TypeScript.

## Getting Started

Install the `sentry/raven-js` package:

```plaintext
$ npm install raven-js --save
```

Configure SystemJS (the new default package manager for Angular 2) to locate the raven-js package:

```plaintext
System.config({
  packages: {'raven-js': { main: 'dist/raven.js' }},
  paths: {'raven-js': 'node_modules/raven-js'}
});
```

Declare a custom ErrorHandler that calls `Raven.captureException`, and initiate it as part of your `NgModule` call:

```plaintext
import Raven from 'raven-js';
import { ErrorHandler } from '@angular/core';
...

Raven.config('your dsn').install();

class RavenErrorHandler {
  handleError(err:any) {
    Raven.captureException(err.originalError);
  }
}


@NgModule({
  imports: [ BrowserModule ],
  declarations: [ AppComponent ],
  bootstrap: [ AppComponent ],
  providers: [ { provide: ErrorHandler, useClass: RavenErrorHandler } ]
})
```

**_Edit_**_: These instructions have been edited to reflect API changes in Angular 2 RC7._

Once you’re done, Sentry will now start capturing both native JavaScript errors and errors occurring deep inside your Angular 2 application. For more in-depth instructions, take a look at our [dedicated Angular 2 documentation](https://docs.sentry.io/hosted/clients/javascript/integrations/angular2/).

## TypeScript + Source Maps

The Raven.js project now provides a TypeScript [language declaration file](https://github.com/getsentry/raven-js/blob/master/typescript/raven-tests.ts) for static analysis of Raven.js API calls inside of your Angular 2 projects.

Additionally, Sentry supports [Source Maps](https://docs.sentry.io/platforms/javascript/legacy-sdk/sourcemaps/), which means that you can see your original TypeScript code in error stack traces.

![TypeScript stack trace](https://blog.sentry.io/_vercel/image?url=_astro%2Finline-0.DHB1yc6j.png&w=828&q=100)

Check out [our documentation](https://docs.sentry.io/platforms/javascript/legacy-sdk/sourcemaps/) to see how to produce source maps as part of your build process and pass them to Sentry. And, whether you need to [debug JavaScript](https://sentry.io/for/javascript/) or do [Angular error](https://sentry.io/for/angular/) tracking, you can get started fast with Sentry.
