-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Update electron docs #1241
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,69 @@ | ||
Electron | ||
======== | ||
|
||
To use Sentry with your Electron application, you will need to use both Raven.js SDKs, one for Browser and one for Node.js. | ||
Browser SDK is used to report all errors from Electron's ``renderer process``, while Node.js is used to report ``main process`` errors. | ||
This is the documentation for our new Electron SDK. | ||
`Sentry Wizard <https://github.com/getsentry/sentry-wizard>`_ helps you with the correct | ||
setup. Under the hood we use `raven-node <https://github.com/getsentry/raven-node>`_ | ||
and `raven-js <https://github.com/getsentry/raven-js>`_. | ||
|
||
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>`. | ||
We also do support native crashes via minidumps. | ||
|
||
Installation | ||
------------ | ||
|
||
Both packages are available via npm. | ||
All packages are available via npm. | ||
|
||
.. code-block:: sh | ||
|
||
$ npm install raven raven-js --save | ||
$ npm install @sentry/electron --save | ||
|
||
Configuring the Client | ||
---------------------- | ||
This will also install `@sentry/wizard`. Run the wizard the help you finish your setup: | ||
With ``yarn`` you can just call: | ||
|
||
First, let's configure ``main process``, which uses the Node.js SDK: | ||
.. code-block:: sh | ||
|
||
.. code-block:: javascript | ||
$ yarn sentry-wizard --integration=electron | ||
|
||
var Raven = require('raven'); | ||
If you only have ``npm`` call: | ||
|
||
Raven.config('___PUBLIC_DSN___', { | ||
captureUnhandledRejections: true | ||
}).install(); | ||
.. code-block:: sh | ||
|
||
And now ``renderer process``, which uses the Browser SDK: | ||
$ node node_modules/.bin/sentry-wizard --integration=electron | ||
|
||
.. code-block:: javascript | ||
``sentry-wizard`` will display recommended packages like `electron-download` which we need | ||
in order to symbolicate native crashes. | ||
The wizard will also create a file called ``sentry.properties`` (which does contain | ||
you account information) and ``sentry-symbols.js`` which helps you with the symbols | ||
upload. | ||
|
||
var Raven = require('raven-js'); | ||
Raven.config('___PUBLIC_DSN___').install(); | ||
|
||
window.addEventListener('unhandledrejection', function (event) { | ||
Raven.captureException(event.reason); | ||
}); | ||
Configuring the Client | ||
---------------------- | ||
|
||
This configuration will also take care of unhandled Promise rejections, which can be handled in various ways. By default, Electron uses standard JS API. | ||
To learn more about handling promises, refer to :ref:`raven-js-promises` documentation. | ||
The following code should reside in the ``main process`` and ``renderer process``: | ||
|
||
Sending environment information | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
.. code-block:: javascript | ||
|
||
It's often a good idea to send platform information along with a caught error. | ||
Some things that we can easily add, but are not limited to, are: | ||
const Sentry = require('@sentry/core'); | ||
const SentryElectron = require('@sentry/electron'); | ||
|
||
- Environment type (browser/renderer) | ||
- Electron version | ||
- Chrome version | ||
- Operation System type | ||
- Operation System release | ||
Sentry.create('___PRIVATE_DSN___') | ||
.use(SentryElectron) | ||
.install(); | ||
|
||
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: | ||
This configuration will also take care of unhandled Promise rejections, which can be | ||
handled in various ways. By default, Electron uses standard JS API. | ||
To learn more about handling promises, refer to :ref:`raven-js-promises` documentation. | ||
|
||
.. code-block:: javascript | ||
Uploading symbols | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
The wizard should create a file called ``sentry-symbols.js`` which takes care of uploading | ||
debug symbols to Sentry. Note that this is only necessary only whenever you update your | ||
version of electron. It usually takes quiet a while because it downloads debug symbols | ||
of electron and uploads the to Sentry so we can symbolicate your native crashes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
You can always execute the script by calling: | ||
|
||
.. code-block:: sh | ||
|
||
var os = require('os'); | ||
var Raven = require('raven'); | ||
|
||
Raven.config('___PUBLIC_DSN___', { | ||
captureUnhandledRejections: true, | ||
tags: { | ||
process: process.type, | ||
electron: process.versions.electron, | ||
chrome: process.versions.chrome, | ||
platform: os.platform(), | ||
platform_release: os.release() | ||
} | ||
}).install(); | ||
$ node sentry-symbols.js |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double
only