{ "html": "
Raven.js should be installed via npm.
\n$ npm install raven-js --save\n
Configuration depends on which module loader/packager you are using to build your Angular 2 application.
\nBelow are instructions for SystemJS, followed by instructions for Webpack, Angular CLI, and other module loaders/packagers.
\nFirst, configure SystemJS to locate the Raven.js package:
\nSystem.config({\n packages: {\n /* ... existing packages above ... */\n 'raven-js': {\n main: 'dist/raven.js'\n }\n },\n paths: {\n /* ... existing paths above ... */\n 'raven-js': 'node_modules/raven-js'\n }\n});\n
Then, in your main application file (where bootstrap
is called, e.g. main.ts):
import Raven from 'raven-js';\nimport { bootstrap } from 'angular2/platform/browser';\nimport { MainApp } from './app.component';\nimport { provide, ExceptionHandler } from 'angular2/core';\n\nRaven\n .config('___PUBLIC_DSN___')\n .install();\n\nclass RavenExceptionHandler {\n call(err:any) {\n Raven.captureException(err.originalException);\n }\n}\n\nbootstrap(MainApp, [\n provide(ExceptionHandler, {useClass: RavenExceptionHandler})\n]);\n
Once you’ve completed these two steps, you are done.
\nIn Webpack, Angular CLI, and other module loaders/packagers, you may need to use the require keyword as\npart of your import statement:
\nimport Raven = require('raven-js'); // NOTE: "require" not "from"\nimport { bootstrap } from 'angular2/platform/browser';\nimport { MainApp } from './app.component';\nimport { provide, ExceptionHandler } from 'angular2/core';\n\nRaven\n .config('___PUBLIC_DSN___')\n .install();\n\nclass RavenExceptionHandler {\n call(err:any) {\n Raven.captureException(err.originalException);\n }\n}\n\nbootstrap(MainApp, [\n provide(ExceptionHandler, {useClass: RavenExceptionHandler})\n]);\n