Skip to content

Commit 104594a

Browse files
committed
Updated raven-js docs to have more on the index page.
1 parent effc282 commit 104594a

File tree

4 files changed

+96
-7
lines changed

4 files changed

+96
-7
lines changed

docs/config.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Configuration
22
=============
33

4-
We must first configure Sentry to allow certain hosts to report errors.
5-
This prevents abuse so somebody else couldn't start sending errors to your
6-
account from their site.
4+
We must first configure the client to allow certain hosts to report
5+
errors. This prevents abuse so somebody else couldn't start sending
6+
errors to your account from their site.
77

88
**Note**: Without setting this, all messages will be rejected!
99

docs/index.rst

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,88 @@ used to report errors from browser and node environments. The quality
1515
of reporting will heavily depend on the environment the data is submitted
1616
from.
1717

18+
Installation
19+
------------
20+
21+
Raven.js is distributed in a few different methods, and should get
22+
included after any other libraries are included, but before your own
23+
scripts. For all details see :doc:`install`. For just getting started,
24+
you can use our CDN:
25+
26+
.. sourcecode:: html
27+
28+
<script src="//cdn.ravenjs.com/1.1.19/raven.min.js"></script>
29+
30+
Configuring the Client
31+
----------------------
32+
33+
We must first configure Sentry to allow certain hosts to report errors.
34+
This prevents abuse so somebody else couldn't start sending errors to your
35+
account from their site. This can be found under the *Project Details*
36+
page in Sentry.
37+
38+
Now need to set up Raven.js to use your Sentry DSN:
39+
40+
.. code-block:: javascript
41+
42+
Raven.config('___PUBLIC_DSN___').install()
43+
44+
At this point, Raven is ready to capture any uncaught exception.
45+
46+
Although, this technically works, this is not going to yield the greatest
47+
results. It's highly recommended to next check out :doc:`config` and
48+
:doc:`usage` after you have it up and running to improve your results.
49+
50+
Reporting Errors
51+
----------------
52+
53+
The simplest way, is to try and explicitly capture and report potentially
54+
problematic code with a ``try...catch`` block and
55+
``Raven.captureException``.
56+
57+
.. code-block:: javascript
58+
59+
try {
60+
doSomething(a[0])
61+
} catch(e) {
62+
Raven.captureException(e)
63+
}
64+
65+
There are more ways to report errors. For a complete guide on this see
66+
:ref:`raven-js-reporting-errors`.
67+
68+
Tracking Users
69+
--------------
70+
71+
While a user is logged in, you can tell Sentry to associate errors with
72+
user data. This data is then submitted with each error which allows you
73+
to figure out which users are affected.
74+
75+
.. code-block:: javascript
76+
77+
Raven.setUserContext({
78+
79+
id: '123'
80+
})
81+
82+
If at any point, the user becomes unauthenticated, you can call
83+
``Raven.setUserContext()`` with no arguments to remove their data.
84+
85+
Dealing with Minified Source Code
86+
---------------------------------
87+
88+
Raven and Sentry support `Source Maps
89+
<http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/>`_. If
90+
you provide source maps in addition to your minified files that data
91+
becomes available in Sentry. For more information see
92+
:ref:`raven-js-sourcemaps`.
93+
94+
Deep Dive
95+
---------
96+
97+
For more detailed information about how to get most out of Raven.js there
98+
is additional documentation available that covers all the rest:
99+
18100
.. toctree::
19101
:maxdepth: 2
20102
:titlesonly:

docs/install.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ So for example:
99
.. sourcecode:: html
1010

1111
<script src="jquery.js"></script>
12-
<script src="//cdn.ravenjs.com/1.1.18/jquery,native/raven.min.js"></script>
12+
<script src="//cdn.ravenjs.com/1.1.19/jquery,native/raven.min.js"></script>
1313
<script>Raven.config('___PUBLIC_DSN___').install();</script>
1414
<script src="app.js"></script>
1515

@@ -28,7 +28,7 @@ Our CDN distributes builds with and without :doc:`plugins <plugins>`.
2828

2929
.. sourcecode:: html
3030

31-
<script src="//cdn.ravenjs.com/1.1.18/raven.min.js"></script>
31+
<script src="//cdn.ravenjs.com/1.1.19/raven.min.js"></script>
3232

3333
**We highly recommend trying out a plugin or two since it'll greatly
3434
improve the chances that we can collect good information.**

docs/usage.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ meaningful stack traces, but browsers make it pretty difficult.
77
The easiest solution is to prevent an error from bubbling all of the way
88
up the stack to ``window``.
99

10+
.. _raven-js-reporting-errors:
11+
1012
Reporting Errors Correctly
1113
--------------------------
1214

@@ -82,6 +84,9 @@ If at any point, the user becomes unauthenticated, you can call
8284
would only really be useful in a large web app where the user logs in/out
8385
without a page reload.*
8486

87+
This data is generally submitted with each error or message and allows you
88+
to figure out which errors are affected by problems.
89+
8590
Capturing Messages
8691
------------------
8792

@@ -151,10 +156,12 @@ is already initialized:
151156
Raven.isSetup()
152157
153158
154-
Dealing with minified source code
159+
.. _raven-js-source-maps:
160+
161+
Dealing with Minified Source Code
155162
---------------------------------
156163

157-
Raven and Sentry now support `Source Maps
164+
Raven and Sentry support `Source Maps
158165
<http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/>`_.
159166

160167
We have provided some instructions to creating Source Maps over at

0 commit comments

Comments
 (0)