Skip to content

Commit f9ac32a

Browse files
authored
docs: Electron integration docs (#1142)
* docs: Electron integration docs * docs: Add platform tags to Electron integration * ref: Minor wording changes
1 parent f9b49e4 commit f9ac32a

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

docs/integrations/electron.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Electron
2+
========
3+
4+
To use Sentry with your Electron application, you will need to use both Raven.js SDKs, one for Browser and one for Node.js.
5+
Browser SDK is used to report all errors from Electron's ``renderer process``, while Node.js is used to report ``main process`` errors.
6+
7+
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>`.
8+
9+
Installation
10+
------------
11+
12+
Both packages are available via npm.
13+
14+
.. code-block:: sh
15+
16+
$ npm install raven raven-js --save
17+
18+
First, let's configure ``main process``, which uses the Node.js SDK:
19+
20+
.. code-block:: javascript
21+
22+
var Raven = require('raven');
23+
24+
Raven.config('___PUBLIC_DSN___', {
25+
captureUnhandledRejections: true
26+
}).install();
27+
28+
And now ``renderer process``, which uses the Browser SDK:
29+
30+
.. code-block:: javascript
31+
32+
var Raven = require('raven-js');
33+
Raven.config('___PUBLIC_DSN___').install();
34+
35+
window.addEventListener('unhandledrejection', function (event) {
36+
Raven.captureException(event.reason);
37+
});
38+
39+
This configuration will also take care of unhandled Promise rejections, which can be handled in various ways. By default, Electron uses standard JS API.
40+
To learn more about handling promises, refer to :doc:`Promises <../usage#promises>` documentation.
41+
42+
Sending environment information
43+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44+
45+
It's often a good idea to send platform information along with a caught error.
46+
Some things that we can easily add, but are not limited to, are:
47+
48+
- Environment type (browser/renderer)
49+
- Electron version
50+
- Chrome version
51+
- Operation System type
52+
- Operation System release
53+
54+
You can configure both processes in the same way. To do this, require the standard Node.js module `os` and add a `tags` attribute to your `config` call:
55+
56+
.. code-block:: javascript
57+
58+
var os = require('os');
59+
var Raven = require('raven');
60+
61+
Raven.config('___PUBLIC_DSN___', {
62+
captureUnhandledRejections: true,
63+
tags: {
64+
process: process.type,
65+
electron: process.versions.electron,
66+
chrome: process.versions.chrome,
67+
platform: os.platform(),
68+
platform_release: os.release()
69+
}
70+
}).install();

docs/sentry-doc-config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@
3838
"integrations/backbone#configuring-the-client"
3939
]
4040
},
41+
"javascript.electron": {
42+
"name": "Electron",
43+
"type": "framework",
44+
"doc_link": "integrations/electron/",
45+
"wizard": [
46+
"integrations/electron#installation",
47+
"integrations/electron#configuring-the-client"
48+
]
49+
},
4150
"javascript.ember": {
4251
"name": "Ember",
4352
"type": "framework",

0 commit comments

Comments
 (0)