You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Integration example docs
* working on context stuff
* WIP
* Added config stuff on breadcrumbs, cleaned up index overview
* Update usage docs with all the things
* Address Ben's feedback
@@ -32,55 +32,91 @@ Next you need to initialize the Raven client and configure it to use your `Sentr
32
32
33
33
.. code-block:: javascript
34
34
35
-
varraven=require('raven');
36
-
var client =newraven.Client('___DSN___');
35
+
varRaven=require('raven');
36
+
Raven.config('___DSN___').install();
37
37
38
-
You can optionally pass an object of configuration options as the 2nd argument to `Client`. For
38
+
At this point, Raven is set up to capture and report any uncaught exceptions.
39
+
40
+
You can optionally pass an object of configuration options as the 2nd argument to `Raven.config`. For
39
41
more information, see :doc:`config`.
40
42
41
43
Reporting Errors
42
44
----------------
43
45
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.
46
+
Raven's ``install`` method sets up a global handler to automatically capture any uncaught exceptions. You can also report errors manually with ``try...catch`` and
47
+
a call to ``captureException``:
47
48
48
49
.. code-block:: javascript
49
50
50
-
client.patchGlobal();
51
+
try {
52
+
doSomething(a[0]);
53
+
} catch (e) {
54
+
Raven.captureException(e);
55
+
}
51
56
52
-
Additionally, you can manually capture and report potentially problematic code with ``try...catch`` and
53
-
``captureException``:
57
+
You can also use ``wrap`` and ``context`` to have Raven wrap a function and automatically capture any exceptions it throws:
54
58
55
59
.. code-block:: javascript
56
60
57
-
try {
58
-
doSomething(a[0])
59
-
} catch(e) {
60
-
client.captureException(e)
61
-
}
61
+
Raven.context(function () {
62
+
doSomething(a[0]);
63
+
});
62
64
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 :doc:`usage`.
65
+
For more information on reporting errors, see :doc:`usage`.
64
66
65
67
Adding Context
66
68
--------------
67
69
68
-
While a user is logged in, you can tell Sentry to associate errors with
69
-
user data. This data is then submitted with each error which allows you
70
-
to figure out which users are affected.
70
+
Code run via ``wrap`` or ``context`` has an associated set of context data, and Raven provides methods for managing that data.
71
+
72
+
You'll most commonly use this to associate the current user with an exception:
// errors thrown here will be associated with matt
84
+
});
85
+
// errors thrown here will not be associated with matt
86
+
87
+
This can also be used to set ``tags`` and ``extra`` keys for associated tags and extra data.
88
+
89
+
You can update the context data with ``mergeContext`` or retrieve it with ``getContext``. When an exception is captured by a wrapper, the current context state will be passed as options to ``captureException``.
90
+
91
+
See :ref:`raven-node-additional-context` for more.
92
+
93
+
Breadcrumbs
94
+
-----------
95
+
96
+
Breadcrumbs are records of server and application lifecycle events that can be helpful in understanding the state of the application leading up to a crash.
97
+
98
+
We can capture breadcrumbs and associate them with a context, and then send them along with any errors captured from that context:
99
+
100
+
.. code-block:: javascript
101
+
102
+
Raven.context(function () {
103
+
Raven.captureBreadcrumb({
104
+
message:'Received payment confirmation',
105
+
category:'payment',
106
+
data: {
107
+
amount:312,
108
+
}
109
+
});
110
+
// errors thrown here will have breadcrumb attached
111
+
});
112
+
113
+
Raven can be configured to automatically capture breadcrubs for certain events including:
78
114
79
-
If at any point, the user becomes unauthenticated, you can call
80
-
``client.setUserContext()`` with no arguments to remove their data.
115
+
* http/https requests
116
+
* console log statements
117
+
* postgres queries
81
118
82
-
Other similar methods are ``client.setExtraContext`` and
83
-
``client.setTagsContext``. See :ref:`raven-node-additional-context` for more info.
119
+
For more information, see :ref:`raven-recording-breadcrumbs`.
84
120
85
121
Middleware and Integrations
86
122
---------------------------
@@ -91,7 +127,7 @@ to configure one of Raven's server middleware integrations. See doc:`integration
91
127
Deep Dive
92
128
---------
93
129
94
-
For more detailed information about how to get most out of Raven.js there
130
+
For more detailed information about how to get most out of Raven there
95
131
is additional documentation available that covers all the rest:
0 commit comments