@@ -6,12 +6,9 @@ On its own, Raven.js will report any uncaught exceptions triggered from your app
66Additionally, Raven.js can be configured to catch any Angular 2-specific exceptions reported through the `angular2/core/ExceptionHandler
77<https://angular.io/docs/js/latest/api/core/index/ExceptionHandler-class.html> `_ component.
88
9- **Note **: This document assumes you are writing your Angular 2 project in TypeScript, and using `SystemJS
10- <https://github.com/systemjs/systemjs> `_ as your module bundler.
11-
129
1310TypeScript Support
14- ~~~~~~~~~~~~~~~~~~
11+ ------------------
1512
1613Raven.js ships with a `TypeScript declaration file
1714<https://github.com/getsentry/raven-js/blob/master/typescript/raven.d.ts> `_, which helps static checking correctness of
@@ -31,6 +28,15 @@ Raven.js should be installed via npm.
3128 Configuration
3229-------------
3330
31+ Configuration depends on which module loader/packager you are using to build your Angular 2 application.
32+
33+ Below are instructions for `SystemJS
34+ <https://github.com/systemjs/systemjs> `__, followed by instructions for `Webpack
35+ <https://webpack.github.io/> `__, Angular CLI, and other module loaders/packagers.
36+
37+ SystemJS
38+ ~~~~~~~~
39+
3440First, configure SystemJS to locate the Raven.js package:
3541
3642.. code-block :: js
@@ -73,13 +79,30 @@ Then, in your main application file (where ``bootstrap`` is called, e.g. main.ts
7379
7480 Once you've completed these two steps, you are done.
7581
76- Webpack and Other Module Loaders
77- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82+ Webpack, Angular CLI, and Other Module Loaders
83+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7884
79- In Webpack and other module loaders, you may need to use the require keyword to load Raven:
85+ In Webpack, Angular CLI, and other module loaders/packagers, you may need to use the **require ** keyword as
86+ part of your `import ` statement:
8087
8188.. code-block :: js
8289
83- import Raven = require(' raven-js' );
90+ import Raven = require (' raven-js' ); // NOTE: "require" not "from"
91+ import { bootstrap } from ' angular2/platform/browser' ;
92+ import { MainApp } from ' ./app.component' ;
93+ import { provide , ExceptionHandler } from ' angular2/core' ;
94+
95+ Raven
8496 .config (' ___PUBLIC_DSN___' )
8597 .install ();
98+
99+ class RavenExceptionHandler {
100+ call (err : any ) {
101+ Raven .captureException (err .originalException );
102+ }
103+ }
104+
105+ bootstrap (MainApp, [
106+ provide (ExceptionHandler, {useClass: RavenExceptionHandler})
107+ ]);
108+
0 commit comments