Skip to content

Update Ember plugin docs #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 72 additions & 8 deletions docs/integrations/ember.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,88 @@
Ember
=====

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.

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>`.

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
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.

Installation
------------

Start by adding the ``raven.js`` script tag to our page. You'll want to position it
after you load all other external libraries (like jQuery), but before your code.
Raven.js and the Raven.js Ember plugin are distributed using a few different methods.

Using our CDN
~~~~~~~~~~~~~

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.

Example:

.. sourcecode:: html

<script src="http://builds.emberjs.com/tags/v2.3.1/ember.prod.js"></script>
<script src="https://cdn.ravenjs.com/2.1.0/ember/raven.min.js"></script>
<script>Raven.config('___PUBLIC_DSN___').install();</script>

Note that this CDN build auto-initializes the Ember plugin.

Using package managers
~~~~~~~~~~~~~~~~~~~~~~

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to assume that everybody just uses ember-cli with Ember today?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure. I wouldn't be able to document a custom build tool here very well anyway.


Bower
`````

.. code

.. code-block:: sh

Configuring the Client
----------------------
$ bower install raven-js --save

Now need to set up Raven.js to use your Sentry DSN:
.. code-block:: javascript

app.import('bower_components/raven-js/dist/raven.js');
app.import('bower_components/raven-js/dist/plugins/ember.js');

.. code-block:: html

<script src="assets/vendor.js"></script>
<script>
Raven
.config('___PUBLIC_DSN___')
.addPlugin(Raven.Plugins.Ember)
.install();
</script>
<script src="assets/your-app.js"></script>

npm
````

.. code-block:: sh

$ npm install raven-js --save

.. code-block:: javascript

Raven.config('___PUBLIC_DSN___').install()
app.import('bower_components/raven-js/dist/raven.js');
app.import('bower_components/raven-js/dist/plugins/ember.js');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be node_modules

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ember CLI actually uses Bower. Fixed in 1bece62.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I squashed this fix btw and rebased the PR onto latest master.


.. code-block:: html

<script src="assets/vendor.js"></script>
<script>
Raven
.config('___PUBLIC_DSN___')
.addPlugin(Raven.Plugins.Ember)
.install();
</script>
<script src="assets/your-app.js"></script>

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``:

.. code-block:: javascript

At this point, Raven is ready to capture any uncaught exception via standard hooks
in addition to Ember's ``onError`` handlers.
Raven.addPlugin(Raven.Plugins.Ember, Ember);