Skip to content

Commit 62a4832

Browse files
committed
Merge pull request #142 from getsentry/better-node-docs
Improve raven-node docs ...
2 parents 5b9aa46 + fee60bc commit 62a4832

File tree

3 files changed

+35
-44
lines changed

3 files changed

+35
-44
lines changed

docs/index.rst

+12-8
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,30 @@ Raven is distributed via ``npm``:
2727
Configuring the Client
2828
----------------------
2929

30-
Now need to configure your application:
30+
Next you need to initialize the Raven client and configure it to use your `Sentry DSN
31+
<https://docs.getsentry.com/hosted/quickstart/#configure-the-dsn>`_:
3132

3233
.. code-block:: javascript
3334
35+
var raven = require('raven');
3436
var client = new raven.Client('___DSN___');
3537
36-
At this point you'll likely need to integrate it into your application via
37-
middleware or another integration mechanism. Take a look at our documentation
38-
on :doc:`integrations/index` and :doc:`usage`.
38+
You can optionally pass an object of configuration options as the 2nd argument to `Client`. For
39+
more information, see :doc:`config`.
3940

4041
Reporting Errors
4142
----------------
4243

43-
You'll want to start by injecting a global error handler, which will catch any
44-
exceptions which would bubble up to the Node runtime:
44+
To get started passing errors to Raven, it is recommended to initialize Raven's global error handler using
45+
``patchGlobal``. This will cause any uncaught exception which would bubble up to the Node runtime to be
46+
captured and processed by Raven.
4547

4648
.. code-block:: javascript
4749
4850
client.patchGlobal();
4951
50-
Beyond that, the simplest way is to explicitly capture and report potentially
51-
problematic code with a ``try...catch`` block and ``Raven.captureException``:
52+
Additionally, you can manually capture and report potentially problematic code with ``try...catch`` and
53+
``captureException``:
5254

5355
.. code-block:: javascript
5456
@@ -58,6 +60,8 @@ problematic code with a ``try...catch`` block and ``Raven.captureException``:
5860
client.captureException(e)
5961
}
6062
63+
The ``captureException`` method optionally takes an object of configuration options as the 2nd argument. For more information, and to learn about other methods provided by the Raven API, see :docs:`usage`.
64+
6165
Adding Context
6266
--------------
6367

docs/install.rst

-23
This file was deleted.

docs/usage.rst

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
Usage
22
=====
33

4-
.. code-block:: javascript
4+
Capturing Errors
5+
----------------
56

6-
var raven = require('raven');
7-
var client = new raven.Client('___DSN___');
7+
.. code-block:: javascript
88
9-
client.captureMessage('Hello, world!');
9+
try {
10+
doSomething(a[0])
11+
} catch (err) {
12+
client.captureException(err)
13+
}
1014
1115
Capturing Messages
1216
------------------
@@ -15,15 +19,6 @@ Capturing Messages
1519
1620
client.captureMessage('Broken!')
1721
18-
Configuring the HTTP Transport
19-
------------------------------
20-
21-
.. code-block:: javascript
22-
23-
var client = new raven.Client('___DSN___', {
24-
transport: new raven.transports.HTTPSTransport({rejectUnauthorized: false})
25-
});
26-
2722
.. _raven-node-additional-context:
2823

2924
Optional Attributes
@@ -165,6 +160,13 @@ so an optional callback is provided to allow you to hook in something like:
165160
166161
The callback is called **after** the event has been sent to the Sentry server.
167162

163+
164+
Middleware and Integrations
165+
---------------------------
166+
167+
If you're using Node.js with a web server framework/library like Connect, Express, or Koa, it is recommended
168+
to configure one of Raven's server middleware integrations. See doc:`integrations/index`.
169+
168170
Events
169171
------
170172

@@ -187,6 +189,14 @@ If you really care if the event was logged or errored out, Client emits two even
187189
188190
client.captureMessage('Boom');
189191
192+
Configuring the HTTP Transport
193+
------------------------------
194+
195+
.. code-block:: javascript
196+
197+
var client = new raven.Client('___DSN___', {
198+
transport: new raven.transports.HTTPSTransport({rejectUnauthorized: false})
199+
});
190200
191201
Disable Raven
192202
-------------

0 commit comments

Comments
 (0)