Skip to content

Commit cb8286f

Browse files
jesslabenvinegar
authored andcommitted
Rename Angular 1 to AngularJS and Angular 2 to Angular (#928)
1 parent 45ae332 commit cb8286f

File tree

3 files changed

+193
-193
lines changed

3 files changed

+193
-193
lines changed

docs/integrations/angular.rst

Lines changed: 81 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,116 @@
1-
Angular 1
1+
Angular
22
=========
33

4-
To use Sentry with your Angular 1.x application, you will need to use both Raven.js (Sentry's browser JavaScript SDK) and the Raven.js Angular plugin.
4+
This document uses Angular to refer to Angular 2+. On its own, Raven.js will report any uncaught exceptions triggered from your application. For advanced usage examples of Raven.js, please read :doc:`Raven.js usage <../usage>`.
55

6-
On its own, Raven.js will report any uncaught exceptions triggered from your application. For advanced usage examples of Raven.js, please read :doc:`Raven.js usage <../usage>`.
6+
Additionally, Raven.js can be configured to catch any Angular-specific (2.x) exceptions reported through the `@angular/core/ErrorHandler
7+
<https://angular.io/docs/js/latest/api/core/index/ErrorHandler-class.html>`_ component.
78

8-
Additionally, the Raven.js Angular plugin will catch any Angular-specific exceptions reported through Angular's ``$exceptionHandler`` interface.
99

10-
**Note**: This documentation is for Angular 1.x. See also: :doc:`Angular 2.x <angular2>`
10+
TypeScript Support
11+
------------------
1112

12-
Installation
13-
------------
14-
15-
Raven.js and the Raven.js Angular plugin are distributed using a few different methods.
13+
Raven.js ships with a `TypeScript declaration file
14+
<https://github.com/getsentry/raven-js/blob/master/typescript/raven.d.ts>`_, which helps static checking correctness of
15+
Raven.js API calls, and facilitates auto-complete in TypeScript-aware IDEs like Visual Studio Code.
1616

17-
Using our CDN
18-
~~~~~~~~~~~~~
1917

20-
For convenience, our CDN serves a single, minified JavaScript file containing both Raven.js and the Raven.js Angular plugin. It should be included **after** Angular, but **before** your application code.
18+
Installation
19+
------------
2120

22-
Example:
21+
Raven.js should be installed via npm.
2322

24-
.. sourcecode:: html
23+
.. code-block:: sh
2524
26-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
27-
<script src="https://cdn.ravenjs.com/###RAVEN_VERSION###/angular/raven.min.js" crossorigin="anonymous"></script>
28-
<script>Raven.config('___PUBLIC_DSN___').install();</script>
25+
$ npm install raven-js --save
2926
30-
Note that this CDN build auto-initializes the Angular plugin.
3127
32-
Using package managers
33-
~~~~~~~~~~~~~~~~~~~~~~
28+
Configuration
29+
-------------
3430

35-
Pre-built distributions of Raven.js and the Raven.js Angular plugin are available via both Bower and npm.
31+
Configuration depends on which module loader/packager you are using to build your Angular application.
3632

37-
Bower
38-
`````
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.
3936

40-
.. code
37+
SystemJS
38+
~~~~~~~~
4139

42-
.. code-block:: sh
40+
First, configure SystemJS to locate the Raven.js package:
4341

44-
$ bower install raven-js --save
42+
.. code-block:: js
4543
46-
.. code-block:: html
44+
System.config({
45+
packages: {
46+
/* ... existing packages above ... */
47+
'raven-js': {
48+
main: 'dist/raven.js'
49+
}
50+
},
51+
paths: {
52+
/* ... existing paths above ... */
53+
'raven-js': 'node_modules/raven-js'
54+
}
55+
});
4756
48-
<script src="/bower_components/angular/angular.js"></script>
49-
<script src="/bower_components/raven-js/dist/raven.js"></script>
50-
<script src="/bower_components/raven-js/dist/plugins/angular.js"></script>
51-
<script>
52-
Raven
53-
.config('___PUBLIC_DSN___')
54-
.addPlugin(Raven.Plugins.Angular)
55-
.install();
56-
</script>
57+
Then, in your main module file (where ``@NgModule`` is called, e.g. app.module.ts):
5758

58-
npm
59-
````
59+
.. code-block:: js
6060
61-
.. code-block:: sh
61+
import Raven = require('raven-js');
62+
import { BrowserModule } from '@angular/platform-browser';
63+
import { NgModule, ErrorHandler } from '@angular/core';
64+
import { AppComponent } from './app.component';
6265
63-
$ npm install raven-js --save
64-
65-
.. code-block:: html
66-
67-
<script src="/node_modules/angular/angular.js"></script>
68-
<script src="/node_modules/raven-js/dist/raven.js"></script>
69-
<script src="/node_modules/raven-js/dist/plugins/angular.js"></script>
70-
<script>
71-
Raven
72-
.config('___PUBLIC_DSN___')
73-
.addPlugin(Raven.Plugins.Angular)
74-
.install();
75-
</script>
66+
Raven
67+
.config('___PUBLIC_DSN___')
68+
.install();
7669
77-
These examples assume that Angular is exported globally as `window.angular`. You can alternatively pass a reference to the `angular` object directly as the second argument to `addPlugin`:
70+
export class RavenErrorHandler implements ErrorHandler {
71+
handleError(err:any) : void {
72+
Raven.captureException(err.originalError || err);
73+
}
74+
}
7875
79-
.. code-block:: javascript
76+
@NgModule({
77+
imports: [ BrowserModule ],
78+
declarations: [ AppComponent ],
79+
bootstrap: [ AppComponent ],
80+
providers: [ { provide: ErrorHandler, useClass: RavenErrorHandler } ]
81+
})
82+
export class AppModule { }
8083
81-
Raven.addPlugin(Raven.Plugins.Angular, angular);
84+
Once you've completed these two steps, you are done.
8285

83-
Module loaders (CommonJS)
84-
~~~~~~~~~~~~~~~~~~~~~~~~~
86+
Angular CLI
87+
~~~~~~~~~~~
8588

86-
Raven and the Raven Angular plugin can be loaded using a module loader like Browserify or Webpack.
89+
Angular CLI now uses Webpack to build instead of SystemJS. All you need to do is modify your main module file (where ``@NgModule`` is called, e.g. app.module.ts):
8790

88-
.. code-block:: javascript
91+
.. code-block:: js
8992
90-
var angular = require('angular');
91-
var Raven = require('raven-js');
93+
import * as Raven from 'raven-js';
94+
import { BrowserModule } from '@angular/platform-browser';
95+
import { NgModule, ErrorHandler } from '@angular/core';
96+
import { AppComponent } from './app.component';
9297
9398
Raven
9499
.config('___PUBLIC_DSN___')
95-
.addPlugin(require('raven-js/plugins/angular'), angular)
96100
.install();
97101
98-
Note that when using CommonJS-style imports, you must pass a reference to `angular` as the second argument to `addPlugin`.
99-
100-
Angular Configuration
101-
---------------------
102-
103-
Inside your main Angular application module, you need to declare `ngRaven` as a module dependency:
104-
105-
.. code-block:: javascript
106-
107-
var myApp = angular.module('myApp', [
108-
'ngRaven',
109-
'ngRoute',
110-
'myAppControllers',
111-
'myAppFilters'
112-
]);
102+
export class RavenErrorHandler implements ErrorHandler {
103+
handleError(err:any) : void {
104+
Raven.captureException(err.originalError);
105+
}
106+
}
107+
108+
@NgModule({
109+
imports: [ BrowserModule ],
110+
declarations: [ AppComponent ],
111+
bootstrap: [ AppComponent ],
112+
providers: [ { provide: ErrorHandler, useClass: RavenErrorHandler } ]
113+
})
114+
export class AppModule { }
115+
116+
Once you've completed that step, you are done.

docs/integrations/angular2.rst

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)