Skip to content

Commit 66f1006

Browse files
committed
Improve docs on passing extra values
1 parent d02b693 commit 66f1006

File tree

1 file changed

+51
-14
lines changed

1 file changed

+51
-14
lines changed

docs/usage.rst

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,66 @@ Capturing Messages
9999
Passing Additional Data
100100
-----------------------
101101

102-
``captureException``, ``context``, ``wrap``, and ``captureMessage``
103-
functions all allow passing additional data to be tagged onto the error,
104-
such as ``tags`` or ``extra`` for additional context.
102+
The ``captureMessage``, ``captureException``, ``context``, and ``wrap``
103+
functions all allow passing additional data to be tagged onto the error.
105104

106-
.. code-block:: javascript
105+
.. describe:: level
107106

108-
Raven.captureException(e, {tags: { key: "value" }})
107+
The log level associated with this event. Default: ``error``
109108

110-
Raven.captureMessage('Broken!', {tags: { key: "value" }})
109+
.. code-block:: javascript
111110
112-
Raven.context({tags: { key: "value" }}, function(){ ... })
111+
Raven.captureMessage('Something happened', {
112+
level: 'info' // one of 'info', 'warning', or 'error'
113+
});
113114
114-
Raven.wrap({logger: "my.module"}, function(){ ... })
115+
.. describe:: logger
115116

116-
Raven.captureException(e, {extra: { foo: "bar" }})
117+
The name of the logger used to record this event. Default: ``javascript``
117118

118-
You can also set context variables globally to be merged in with future
119-
exceptions with ``setExtraContext`` and ``setTagsContext``.
119+
.. code-block:: javascript
120120
121-
.. code-block:: javascript
121+
Raven.captureException(new Error('Oops!'), {
122+
logger: 'my.module'
123+
});
124+
125+
Note that logger can also be set globally via ``Raven.config``.
126+
127+
.. describe:: tags
128+
129+
`Tags <https://www.getsentry.com/docs/tags/>`__ to assign to the event.
130+
131+
.. code-block:: javascript
132+
133+
Raven.wrap({
134+
tags: {git_commit: 'c0deb10c4'}
135+
}, function () { /* ... */ });
136+
137+
// NOTE: Raven.wrap and Raven.context accept options as first argument
138+
139+
You can also set tags globally to be merged in with future exceptions events via ``Raven.config``, or ``Raven.setTagsContext``:
140+
141+
.. code-block:: javascript
142+
143+
Raven.setTagsContext({ key: "value" });
144+
145+
.. describe:: extra
146+
147+
Arbitrary data to associate with the event.
148+
149+
.. code-block:: javascript
150+
151+
Raven.context({
152+
extra: {planet: {name: 'Earth'}}}
153+
}, function () { /* ... */ });
154+
155+
// NOTE: Raven.wrap and Raven.context accept options as first argument
156+
157+
You can also set extra data globally to be merged in with future events with ``setExtraContext``:
158+
159+
.. code-block:: javascript
122160
123-
Raven.setExtraContext({ foo: "bar" })
124-
Raven.setTagsContext({ key: "value" })
161+
Raven.setExtraContext({ foo: "bar" })
125162
126163
127164
Getting Back an Event ID

0 commit comments

Comments
 (0)