Skip to content

Commit 7b80e82

Browse files
docs(js): Move Electron content from quick start to other pages (#15393)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR This branch contains the restructured Electron quick start guide. The goal is to make sure we don't overwhelm users with advanced topics. What changed: - Created a new navigation item "Electron Features" - Created the following pages under "Electron Features" and moved the respective content from the quick start guide: - Offline Support - Native Crash Reporting - Inter-process Communication - Fixed the steps numbering in the quick start (now we have 4 instead of 8 🎉) - added a link to "Electron Features" page from the quick start (in Next steps) - added the `transportOptions` options for Electron offline support to Configuration > Options Closes: #15329 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --------- Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io>
1 parent 5eda123 commit 7b80e82

File tree

6 files changed

+259
-220
lines changed

6 files changed

+259
-220
lines changed

docs/platforms/javascript/common/configuration/options.mdx

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ Set this option to `false` to disable sending of client reports. Client reports
171171
Set this option to `true` to add stack local variables to stack traces.
172172

173173
<PlatformSection notSupported={["javascript.bun", "javascript.cloudflare", "javascript.deno"]}>
174+
174175
For more advanced configuration options, see the documentation on the <PlatformLink to="/configuration/integrations/localvariables">Local Variables integration options</PlatformLink>.
176+
175177
</PlatformSection>
176178

177179
</SdkOption>
@@ -242,6 +244,21 @@ Options used to configure the transport. This is an object with the following po
242244

243245
</PlatformCategorySection>
244246

247+
<PlatformSection supported={["javascript.electron"]}>
248+
**Options for Electron offline support:**
249+
250+
The Electron SDK provides built-in offline support that queues events when the app is offline and automatically sends them once the connection is restored. These options let you configure the following behavior:
251+
252+
- `maxAgeDays`: The maximum number of envelopes to keep in the queue.
253+
- `maxQueueSize`: The maximum number of days to keep an envelope in the queue.
254+
- `flushAtStartup`: Whether the offline store should flush shortly after application startup. Defaults to `false`.
255+
- `shouldSend`: Called before the SDK attempts to send an envelope to Sentry. If this function returns false, `shouldStore` will be called to determine if the envelope should be stored. Defaults to `() => true`.
256+
- `shouldStore`: Called before an event is stored. Return `false` to drop the envelope rather than store it. Defaults to `() => true`.
257+
258+
Check out the [Offline Support](/platforms/javascript/guides/electron/features/offline-support/) documentation for a complete example.
259+
260+
</PlatformSection>
261+
245262
</SdkOption>
246263

247264
<SdkOption name="shutdownTimeout" type='number' defaultValue='2000' categorySupported={['server', 'serverless']}>
@@ -450,27 +467,31 @@ If a root span matches any of the specified patterns, the entire local trace wil
450467
By default, no spans are ignored.
451468

452469
Here are some predefined matches for common spans to get you started:
470+
453471
```javascript
454472
Sentry.init({
455473
ignoreSpans: [
456474
// Browser connection events
457-
{op: /^browser\.(cache|connect|DNS)$/},
475+
{ op: /^browser\.(cache|connect|DNS)$/ },
458476

459477
// Fonts
460-
{op: 'resource.other', name: /.+\.(woff2|woff|ttf|eot)$/},
478+
{ op: "resource.other", name: /.+\.(woff2|woff|ttf|eot)$/ },
461479

462480
// CSS files
463-
{op: 'resource.link', name: /.+\.css.*$/},
481+
{ op: "resource.link", name: /.+\.css.*$/ },
464482

465483
// JS files
466-
{op: /resource\.(link|script)/, name: /.+\.js.*$/},
484+
{ op: /resource\.(link|script)/, name: /.+\.js.*$/ },
467485

468486
// Images
469-
{op: /resource\.(other|img)/, name: /.+\.(png|svg|jpe?g|gif|bmp|tiff?|webp|avif|heic?|ico).*$/},
487+
{
488+
op: /resource\.(other|img)/,
489+
name: /.+\.(png|svg|jpe?g|gif|bmp|tiff?|webp|avif|heic?|ico).*$/,
490+
},
470491

471492
// Measure spans
472-
{op: 'measure'},
473-
]
493+
{ op: "measure" },
494+
],
474495
});
475496
```
476497

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Electron Features
3+
description: "Learn how Sentry's Electron SDK exposes features for first class integration with Electron."
4+
excerpt: ""
5+
---
6+
7+
The Sentry Electron SDK offers Electron-specific features for first class integration with the framework.
8+
9+
<PageGrid />
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: Inter-Process Communication
3+
description: "Learn how the Sentry Electron SDK communicates across processes to capture detailed error data."
4+
---
5+
6+
To provide the most detailed context for all events, including native crashes, the SDK merges context, scope, and breadcrumbs from all processes into the Electron `main` process.
7+
8+
By default, the SDK attempts to establish communication from `renderer` to `main` using Electron's IPC APIs. If that fails, it falls back to a custom HTTP protocol. You can change this behavior using the <PlatformLink to="/configuration/options/#ipcMode">`ipcMode`</PlatformLink> option:
9+
10+
```javascript
11+
const { init, IPCMode } = require("@sentry/electron/main");
12+
13+
init({
14+
dsn: "___PUBLIC_DSN___",
15+
debug: true,
16+
ipcMode: IPCMode.Protocol, // Options: IPCMode.Classic, IPCMode.Protocol, or IPCMode.Both
17+
});
18+
```
19+
20+
## Custom IPC Namespace
21+
22+
If your application uses multiple IPC channels, you can specify a custom namespace to prevent conflicts with Sentry's IPC channels.
23+
24+
Configure the same namespace across all three contexts:
25+
26+
**Main process**
27+
28+
```javascript
29+
import * as Sentry from "@sentry/electron/main";
30+
31+
Sentry.init({
32+
dsn: "___PUBLIC_DSN___",
33+
ipcNamespace: "some-app",
34+
});
35+
```
36+
37+
**Renderer process**
38+
39+
```javascript
40+
import * as Sentry from "@sentry/electron/renderer";
41+
42+
Sentry.init({
43+
ipcNamespace: "some-app",
44+
});
45+
```
46+
47+
**Preload process**
48+
49+
```javascript
50+
import { hookupIpc } from "@sentry/electron/preload-namespaced";
51+
52+
hookupIpc("some-app");
53+
```
54+
55+
The SDK will prefix all IPC channels with your specified namespace (for example, `some-app`), helping to avoid conflicts with other channels in your application.
56+
57+
For more configuration options, see the <PlatformLink to="/configuration/options/#ipcNamespace">configuration options documentation</PlatformLink>.
58+
59+
## Preload Injection
60+
61+
The SDK automatically injects a preload script using [`session.setPreloads(preloads)`](https://www.electronjs.org/docs/latest/api/session#sessetpreloadspreloads). By default, this only applies to the `defaultSession`.
62+
63+
If your app uses other sessions, pass them via the `getSessions` option in the `main` process:
64+
65+
```javascript
66+
import { session } from "electron";
67+
import * as Sentry from "@sentry/electron/main";
68+
69+
Sentry.init({
70+
dsn: "___PUBLIC_DSN___",
71+
getSessions: () => [
72+
session.defaultSession,
73+
session.fromPartition("persist:my-session"),
74+
],
75+
});
76+
```
77+
78+
<Alert>
79+
If your app bundles the `main` process JavaScript, the SDK can't automatically
80+
inject preload scripts because they won't be included in the packaged app. In
81+
this case, the SDK will send events and scope updates via a custom HTTP
82+
protocol and `window.fetch`.
83+
</Alert>
84+
85+
## Manual Preload
86+
87+
If you prefer to bundle and configure the preload script manually, import the SDK preload code into your own preload script:
88+
89+
```javascript
90+
import "@sentry/electron/preload";
91+
```
92+
93+
This exposes IPC to the isolated renderer via Electron's `contextBridge` API.
94+
95+
Check out our [example apps](https://github.com/getsentry/sentry-electron/tree/master/examples) for implementation details.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: Native Crash Reporting
3+
description: "Learn how Sentry captures and processes native crashes from Electron processes."
4+
---
5+
6+
Sentry can process Minidumps created when any Electron process crashes. The SDK uploads these files when the application restarts (or immediately after a renderer crash). All event metadata, including user information and breadcrumbs, is included in these uploads.
7+
8+
Due to [macOS App Store sandbox restrictions](https://electronjs.org/docs/tutorial/mac-app-store-submission-guide#limitations-of-mas-build), native crashes can't be collected in Mac App Store builds. Native crash handling is automatically disabled in these environments.
9+
10+
<Expandable level="success" title="A word on data privacy">
11+
Minidumps are memory snapshots of a process at the moment it crashes. They may
12+
contain sensitive information, such as environment variables, local path
13+
names, or even in-memory data from input fields, including passwords. **Sentry
14+
does not store these memory dumps**. Once processed, Sentry immediately
15+
deletes them and strips all sensitive information from the resulting Issues.
16+
</Expandable>
17+
18+
<Alert level="warning" title="Known issue">
19+
It's currently not possible to send events from native code (such as a C++
20+
extension). However, crashes will still be reported to Sentry if they happen
21+
in a process where the SDK has been configured. Additionally, crash reports
22+
from sub-processes may not be reported automatically on all platforms. This
23+
feature will be added in a future SDK update.
24+
</Alert>
25+
26+
## Symbolication
27+
28+
To allow Sentry to process native crashes and fully provide symbolicated stack traces, you need to upload _Debug Information Files_ (sometimes also referred to as _Debug Symbols_ or just _Symbols_). Without these symbols, crash reports will show memory addresses instead of function names and file locations.
29+
30+
For standard Electron apps, enable the built-in Electron Symbol Server in Sentry:
31+
32+
1. Go **Project Settings > Debug Files**
33+
2. Select `Electron` from the **Built-in Repositories**
34+
3. Add symbol servers for the platforms you're deploying to (if needed)
35+
36+
### Custom Code and Extensions
37+
38+
If your application contains custom native extensions or you wish to symbolicate crashes from a spawned child process, upload their debug information manually during your build or release process.
39+
40+
For detailed instructions on uploading and managing debug symbols, see the [Debug Information Files](/platforms/javascript/guides/electron/data-management/debug-files/) documentation.
41+
42+
## Child Processes
43+
44+
The SDK relies on the [Electron crashReporter](https://electronjs.org/docs/api/crash-reporter) to capture crash dumps. To receive crash reports for child processes, make sure the crash reporter is activated by either the SDK or manually (see [Manual Crash Reporting below](#manual-crash-reporting)).
45+
46+
Once active, the SDK automatically captures native crashes for the following processes:
47+
48+
| | `event.process` tag | macOS | Windows | Linux |
49+
| --------------------------- | ------------------- | ----- | ------- | -------------- |
50+
| Electron `main` process | `browser` ||||
51+
| Electron `renderer` process | `renderer` ||||
52+
| Electron `utilityProcess` | `utility` ||| ✓ <sup>1</sup> |
53+
| `child_process.fork` | `node` ||| |
54+
| `child_process.exec/spawn` | `unknown` || | |
55+
56+
<sup>1</sup> Not supported in Electron v29.4.6.
57+
58+
## Manual Crash Reporting
59+
60+
You can also capture native crashes by manually starting the [Electron `crashReporter`](https://electronjs.org/docs/api/crash-reporter). This approach provides symbolicated stack traces and system information, but doesn't include Electron-specific metadata, breadcrumbs, or context information.
61+
62+
This is useful when you can't use the full Electron SDK:
63+
64+
```javascript
65+
const { crashReporter } = require("electron");
66+
crashReporter.start({
67+
companyName: "YourCompany",
68+
productName: "YourApp",
69+
ignoreSystemCrashHandler: true,
70+
submitURL: "___MINIDUMP_URL___",
71+
});
72+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Offline Support
3+
description: "Learn how to customize the automatic caching of Sentry events while being offline."
4+
---
5+
6+
Sentry automatically handles offline event caching across the main and renderer processes to make sure you don't miss important information.
7+
8+
You can customize the queueing behavior with these optional [`transportOptions`](/platforms/javascript/guides/electron/configuration/options/#transportOptions) properties:
9+
10+
```javascript
11+
import * as Sentry from "@sentry/electron/main";
12+
13+
Sentry.init({
14+
dsn: "___PUBLIC_DSN___",
15+
transportOptions: {
16+
/* The maximum number of days to keep an envelope in the queue. */
17+
maxAgeDays: 30,
18+
/* The maximum number of envelopes to keep in the queue. */
19+
maxQueueSize: 30,
20+
/**
21+
* Called before we attempt to send an envelope to Sentry.
22+
*
23+
* If this function returns false, `shouldStore` will be called to determine if the envelope should be stored.
24+
*
25+
* Default: () => true
26+
*
27+
* @param envelope The envelope that will be sent.
28+
* @returns Whether we should attempt to send the envelope
29+
*/
30+
shouldSend: (envelope: Envelope) => boolean | Promise<boolean>;
31+
/**
32+
* Called before an event is stored.
33+
*
34+
* Return false to drop the envelope rather than store it.
35+
*
36+
* Default: () => true
37+
*
38+
* @param envelope The envelope that failed to send.
39+
* @param error The error that occurred.
40+
* @param retryDelay The current retry delay in milliseconds.
41+
* @returns Whether we should store the envelope in the queue
42+
*/
43+
shouldStore: (envelope: Envelope, error: Error, retryDelay: number) => boolean | Promise<boolean>;
44+
/**
45+
* Should the offline store flush shortly after startup.
46+
*
47+
* Defaults: false
48+
*/
49+
flushAtStartup: false;
50+
},
51+
});
52+
```

0 commit comments

Comments
 (0)