Skip to content

Commit 9c176d6

Browse files
committed
move advanced info from quick start to other pages
1 parent 3814d0e commit 9c176d6

File tree

6 files changed

+265
-222
lines changed

6 files changed

+265
-222
lines changed

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

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,14 @@ Set this option to `false` to disable sending of client reports. Client reports
170170

171171
Set this option to `true` to add stack local variables to stack traces.
172172

173-
<PlatformSection notSupported={["javascript.bun", "javascript.cloudflare", "javascript.deno"]}>
174-
For more advanced configuration options, see the documentation on the <PlatformLink to="/configuration/integrations/localvariables">Local Variables integration options</PlatformLink>.
173+
<PlatformSection
174+
notSupported={["javascript.bun", "javascript.cloudflare", "javascript.deno"]}
175+
>
176+
For more advanced configuration options, see the documentation on the{" "}
177+
<PlatformLink to="/configuration/integrations/localvariables">
178+
Local Variables integration options
179+
</PlatformLink>
180+
.
175181
</PlatformSection>
176182

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

243249
</PlatformCategorySection>
244250

251+
<PlatformSection supported={["javascript.electron"]}>
252+
**Options for Electron offline support:**
253+
254+
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 that behavior:
255+
256+
- `maxQueueSize`: The maximum number of days to keep an envelope in the queue.
257+
- `maxAgeDays`: The maximum number of envelopes to keep in the queue.
258+
- `flushAtStartup`: Whether the offline store should flush shortly after application startup. Defaults to `false`.
259+
- `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`.
260+
- `shouldStore`: Called before an event is stored. Return `false` to drop the envelope rather than store it. Defaults to `() => true`.
261+
262+
Check out the [Offline Support](/platforms/javascript/guides/electron/features/offline-support/) documentation for a complete example.
263+
264+
</PlatformSection>
265+
245266
</SdkOption>
246267

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

452473
Here are some predefined matches for common spans to get you started:
474+
453475
```javascript
454476
Sentry.init({
455477
ignoreSpans: [
456478
// Browser connection events
457-
{op: /^browser\.(cache|connect|DNS)$/},
479+
{ op: /^browser\.(cache|connect|DNS)$/ },
458480

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

462484
// CSS files
463-
{op: 'resource.link', name: /.+\.css.*$/},
485+
{ op: "resource.link", name: /.+\.css.*$/ },
464486

465487
// JS files
466-
{op: /resource\.(link|script)/, name: /.+\.js.*$/},
488+
{ op: /resource\.(link|script)/, name: /.+\.js.*$/ },
467489

468490
// Images
469-
{op: /resource\.(other|img)/, name: /.+\.(png|svg|jpe?g|gif|bmp|tiff?|webp|avif|heic?|ico).*$/},
491+
{
492+
op: /resource\.(other|img)/,
493+
name: /.+\.(png|svg|jpe?g|gif|bmp|tiff?|webp|avif|heic?|ico).*$/,
494+
},
470495

471496
// Measure spans
472-
{op: 'measure'},
473-
]
497+
{ op: "measure" },
498+
],
474499
});
475500
```
476501

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)