Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions docs/platforms/javascript/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ Set this option to `false` to disable sending of client reports. Client reports
Set this option to `true` to add stack local variables to stack traces.

<PlatformSection notSupported={["javascript.bun", "javascript.cloudflare", "javascript.deno"]}>

For more advanced configuration options, see the documentation on the <PlatformLink to="/configuration/integrations/localvariables">Local Variables integration options</PlatformLink>.

</PlatformSection>

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

</PlatformCategorySection>

<PlatformSection supported={["javascript.electron"]}>
**Options for Electron offline support:**

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:

- `maxAgeDays`: The maximum number of envelopes to keep in the queue.
- `maxQueueSize`: The maximum number of days to keep an envelope in the queue.
- `flushAtStartup`: Whether the offline store should flush shortly after application startup. Defaults to `false`.
- `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`.
- `shouldStore`: Called before an event is stored. Return `false` to drop the envelope rather than store it. Defaults to `() => true`.

Check out the [Offline Support](/platforms/javascript/guides/electron/features/offline-support/) documentation for a complete example.

</PlatformSection>

</SdkOption>

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

Here are some predefined matches for common spans to get you started:

```javascript
Sentry.init({
ignoreSpans: [
// Browser connection events
{op: /^browser\.(cache|connect|DNS)$/},
{ op: /^browser\.(cache|connect|DNS)$/ },

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

// CSS files
{op: 'resource.link', name: /.+\.css.*$/},
{ op: "resource.link", name: /.+\.css.*$/ },

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

// Images
{op: /resource\.(other|img)/, name: /.+\.(png|svg|jpe?g|gif|bmp|tiff?|webp|avif|heic?|ico).*$/},
{
op: /resource\.(other|img)/,
name: /.+\.(png|svg|jpe?g|gif|bmp|tiff?|webp|avif|heic?|ico).*$/,
},

// Measure spans
{op: 'measure'},
]
{ op: "measure" },
],
});
```

Expand Down
9 changes: 9 additions & 0 deletions docs/platforms/javascript/guides/electron/features/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Electron Features
description: "Learn how Sentry's Electron SDK exposes features for first class integration with Electron."
excerpt: ""
---

The Sentry Electron SDK offers Electron-specific features for first class integration with the framework.

<PageGrid />
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: Inter-Process Communication
description: "Learn how the Sentry Electron SDK communicates across processes to capture detailed error data."
---

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.

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:

```javascript
const { init, IPCMode } = require("@sentry/electron/main");

init({
dsn: "___PUBLIC_DSN___",
debug: true,
ipcMode: IPCMode.Protocol, // Options: IPCMode.Classic, IPCMode.Protocol, or IPCMode.Both
});
```

## Custom IPC Namespace

If your application uses multiple IPC channels, you can specify a custom namespace to prevent conflicts with Sentry's IPC channels.

Configure the same namespace across all three contexts:

**Main process**

```javascript
import * as Sentry from "@sentry/electron/main";

Sentry.init({
dsn: "___PUBLIC_DSN___",
ipcNamespace: "some-app",
});
```

**Renderer process**

```javascript
import * as Sentry from "@sentry/electron/renderer";

Sentry.init({
ipcNamespace: "some-app",
});
```

**Preload process**

```javascript
import { hookupIpc } from "@sentry/electron/preload-namespaced";

hookupIpc("some-app");
```

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.

For more configuration options, see the <PlatformLink to="/configuration/options/#ipcNamespace">configuration options documentation</PlatformLink>.

## Preload Injection

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`.

If your app uses other sessions, pass them via the `getSessions` option in the `main` process:

```javascript
import { session } from "electron";
import * as Sentry from "@sentry/electron/main";

Sentry.init({
dsn: "___PUBLIC_DSN___",
getSessions: () => [
session.defaultSession,
session.fromPartition("persist:my-session"),
],
});
```

<Alert>
If your app bundles the `main` process JavaScript, the SDK can't automatically
inject preload scripts because they won't be included in the packaged app. In
this case, the SDK will send events and scope updates via a custom HTTP
protocol and `window.fetch`.
</Alert>

## Manual Preload

If you prefer to bundle and configure the preload script manually, import the SDK preload code into your own preload script:

```javascript
import "@sentry/electron/preload";
```

This exposes IPC to the isolated renderer via Electron's `contextBridge` API.

Check out our [example apps](https://github.com/getsentry/sentry-electron/tree/master/examples) for implementation details.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Native Crash Reporting
description: "Learn how Sentry captures and processes native crashes from Electron processes."
---

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.

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.

<Expandable level="success" title="A word on data privacy">
Minidumps are memory snapshots of a process at the moment it crashes. They may
contain sensitive information, such as environment variables, local path
names, or even in-memory data from input fields, including passwords. **Sentry
does not store these memory dumps**. Once processed, Sentry immediately
deletes them and strips all sensitive information from the resulting Issues.
</Expandable>

<Alert level="warning" title="Known issue">
It's currently not possible to send events from native code (such as a C++
extension). However, crashes will still be reported to Sentry if they happen
in a process where the SDK has been configured. Additionally, crash reports
from sub-processes may not be reported automatically on all platforms. This
feature will be added in a future SDK update.
</Alert>

## Symbolication

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.

For standard Electron apps, enable the built-in Electron Symbol Server in Sentry:

1. Go **Project Settings > Debug Files**
2. Select `Electron` from the **Built-in Repositories**
3. Add symbol servers for the platforms you're deploying to (if needed)

### Custom Code and Extensions

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.

For detailed instructions on uploading and managing debug symbols, see the [Debug Information Files](/platforms/javascript/guides/electron/data-management/debug-files/) documentation.

## Child Processes

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)).

Once active, the SDK automatically captures native crashes for the following processes:

| | `event.process` tag | macOS | Windows | Linux |
| --------------------------- | ------------------- | ----- | ------- | -------------- |
| Electron `main` process | `browser` | ✓ | ✓ | ✓ |
| Electron `renderer` process | `renderer` | ✓ | ✓ | ✓ |
| Electron `utilityProcess` | `utility` | ✓ | ✓ | ✓ <sup>1</sup> |
| `child_process.fork` | `node` | ✓ | ✓ | |
| `child_process.exec/spawn` | `unknown` | ✓ | | |

<sup>1</sup> Not supported in Electron v29.4.6.

## Manual Crash Reporting

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.

This is useful when you can't use the full Electron SDK:

```javascript
const { crashReporter } = require("electron");
crashReporter.start({
companyName: "YourCompany",
productName: "YourApp",
ignoreSystemCrashHandler: true,
submitURL: "___MINIDUMP_URL___",
});
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: Offline Support
description: "Learn how to customize the automatic caching of Sentry events while being offline."
---

Sentry automatically handles offline event caching across the main and renderer processes to make sure you don't miss important information.

You can customize the queueing behavior with these optional [`transportOptions`](/platforms/javascript/guides/electron/configuration/options/#transportOptions) properties:

```javascript
import * as Sentry from "@sentry/electron/main";

Sentry.init({
dsn: "___PUBLIC_DSN___",
transportOptions: {
/* The maximum number of days to keep an envelope in the queue. */
maxAgeDays: 30,
/* The maximum number of envelopes to keep in the queue. */
maxQueueSize: 30,
/**
* Called before we attempt to send an envelope to Sentry.
*
* If this function returns false, `shouldStore` will be called to determine if the envelope should be stored.
*
* Default: () => true
*
* @param envelope The envelope that will be sent.
* @returns Whether we should attempt to send the envelope
*/
shouldSend: (envelope: Envelope) => boolean | Promise<boolean>;
/**
* Called before an event is stored.
*
* Return false to drop the envelope rather than store it.
*
* Default: () => true
*
* @param envelope The envelope that failed to send.
* @param error The error that occurred.
* @param retryDelay The current retry delay in milliseconds.
* @returns Whether we should store the envelope in the queue
*/
shouldStore: (envelope: Envelope, error: Error, retryDelay: number) => boolean | Promise<boolean>;
/**
* Should the offline store flush shortly after startup.
*
* Defaults: false
*/
flushAtStartup: false;
},
});
```
Loading
Loading