|
1 | 1 | Ember
|
2 | 2 | =====
|
3 | 3 |
|
| 4 | +To use Sentry with your Ember application, you will need to use both Raven.js (Sentry's browser JavaScript SDK) and the Raven.js Ember plugin. |
| 5 | + |
| 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>`. |
| 7 | + |
| 8 | +Additionally, the Raven.js Ember plugin will catch any Ember-specific exceptions reported through Ember's `onerror <https://guides.emberjs.com/v2.3.0/configuring-ember/debugging/#toc_implement-an-ember-onerror-hook-to-log-all-errors-in-production>`_. hook |
| 9 | +and any `RSVP promises <https://guides.emberjs.com/v2.3.0/configuring-ember/debugging/#toc_errors-within-an-code-rsvp-promise-code>`_ that would otherwise be swallowed. |
| 10 | + |
4 | 11 | Installation
|
5 | 12 | ------------
|
6 | 13 |
|
7 |
| -Start by adding the ``raven.js`` script tag to our page. You'll want to position it |
8 |
| -after you load all other external libraries (like jQuery), but before your code. |
| 14 | +Raven.js and the Raven.js Ember plugin are distributed using a few different methods. |
| 15 | + |
| 16 | +Using our CDN |
| 17 | +~~~~~~~~~~~~~ |
| 18 | + |
| 19 | +For convenience, our CDN serves a single, minified JavaScript file containing both Raven.js and the Raven.js Ember plugin. It should be included **after** Ember, but **before** your application code. |
| 20 | + |
| 21 | +Example: |
9 | 22 |
|
10 | 23 | .. sourcecode:: html
|
11 | 24 |
|
| 25 | + <script src="http://builds.emberjs.com/tags/v2.3.1/ember.prod.js"></script> |
12 | 26 | <script src="https://cdn.ravenjs.com/2.1.0/ember/raven.min.js"></script>
|
| 27 | + <script>Raven.config('___PUBLIC_DSN___').install();</script> |
| 28 | + |
| 29 | +Note that this CDN build auto-initializes the Ember plugin. |
| 30 | + |
| 31 | +Using package managers |
| 32 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 33 | + |
| 34 | +Pre-built distributions of Raven.js and the Raven.js Ember plugin are available via both Bower and npm for importing in your ``ember-cli-build.js`` file. |
| 35 | + |
| 36 | +Bower |
| 37 | +````` |
| 38 | + |
| 39 | +.. code |
| 40 | +
|
| 41 | +.. code-block:: sh |
13 | 42 |
|
14 |
| -Configuring the Client |
15 |
| ----------------------- |
| 43 | + $ bower install raven-js --save |
16 | 44 |
|
17 |
| -Now need to set up Raven.js to use your Sentry DSN: |
| 45 | +.. code-block:: javascript |
| 46 | +
|
| 47 | + app.import('bower_components/raven-js/dist/raven.js'); |
| 48 | + app.import('bower_components/raven-js/dist/plugins/ember.js'); |
| 49 | +
|
| 50 | +.. code-block:: html |
| 51 | + |
| 52 | + <script src="assets/vendor.js"></script> |
| 53 | + <script> |
| 54 | + Raven |
| 55 | + .config('___PUBLIC_DSN___') |
| 56 | + .addPlugin(Raven.Plugins.Ember) |
| 57 | + .install(); |
| 58 | + </script> |
| 59 | + <script src="assets/your-app.js"></script> |
| 60 | + |
| 61 | +npm |
| 62 | +```` |
| 63 | + |
| 64 | +.. code-block:: sh |
| 65 | +
|
| 66 | + $ npm install raven-js --save |
18 | 67 |
|
19 | 68 | .. code-block:: javascript
|
20 | 69 |
|
21 |
| - Raven.config('___PUBLIC_DSN___').install() |
| 70 | + app.import('node_modules/raven-js/dist/raven.js'); |
| 71 | + app.import('bower_components/raven-js/dist/plugins/ember.js'); |
| 72 | +
|
| 73 | +.. code-block:: html |
| 74 | + |
| 75 | + <script src="assets/vendor.js"></script> |
| 76 | + <script> |
| 77 | + Raven |
| 78 | + .config('___PUBLIC_DSN___') |
| 79 | + .addPlugin(Raven.Plugins.Ember) |
| 80 | + .install(); |
| 81 | + </script> |
| 82 | + <script src="assets/your-app.js"></script> |
| 83 | + |
| 84 | +These examples assume that Ember is exported globally as ``window.Ember``. You can alternatively pass a reference to the ``Ember`` object directly as the second argument to ``addPlugin``: |
| 85 | + |
| 86 | +.. code-block:: javascript |
22 | 87 |
|
23 |
| -At this point, Raven is ready to capture any uncaught exception via standard hooks |
24 |
| -in addition to Ember's ``onError`` handlers. |
| 88 | + Raven.addPlugin(Raven.Plugins.Ember, Ember); |
0 commit comments