@@ -6,12 +6,9 @@ On its own, Raven.js will report any uncaught exceptions triggered from your app
6
6
Additionally, Raven.js can be configured to catch any Angular 2-specific exceptions reported through the `angular2/core/ExceptionHandler
7
7
<https://angular.io/docs/js/latest/api/core/index/ExceptionHandler-class.html> `_ component.
8
8
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
-
12
9
13
10
TypeScript Support
14
- ~~~~~~~~~~~~~~~~~~
11
+ ------------------
15
12
16
13
Raven.js ships with a `TypeScript declaration file
17
14
<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.
31
28
Configuration
32
29
-------------
33
30
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
+
34
40
First, configure SystemJS to locate the Raven.js package:
35
41
36
42
.. code-block :: js
@@ -73,13 +79,30 @@ Then, in your main application file (where ``bootstrap`` is called, e.g. main.ts
73
79
74
80
Once you've completed these two steps, you are done.
75
81
76
- Webpack and Other Module Loaders
77
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82
+ Webpack, Angular CLI, and Other Module Loaders
83
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78
84
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:
80
87
81
88
.. code-block :: js
82
89
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
84
96
.config (' ___PUBLIC_DSN___' )
85
97
.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