Skip to content
Merged
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
17 changes: 17 additions & 0 deletions docs/platforms/javascript/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,23 @@ Available options are:

</SdkOption>

<SdkOption name="ipcNamespace" type='string'>

Custom namespace for the inter-process communication (IPC) channels used by the Sentry Electron SDK. This is useful when your Electron application uses multiple IPC channels and you want to prevent potential conflicts between them.

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

Sentry.init({
dsn: "___PUBLIC_DSN___",
ipcNamespace: "myCustomNamespace",
});
```

When set, the IPC channels used by Sentry will be prefixed with the specified namespace. Note that you need to configure the same namespace in your main process, renderer processes, and preload scripts for proper communication. See the <PlatformLink to="/platforms/javascript/guides/electron/#custom-ipc-namespace">Custom IPC Namespace section</PlatformLink> for complete setup instructions.

</SdkOption>

<SdkOption name="getSessions" type='() => Electron.Session[]' defaultValue='() => [session.defaultSession]'>

A function that returns an array of Electron `session` objects. These sessions are used to configure communication between the Electron main and renderer processes.
Expand Down
39 changes: 39 additions & 0 deletions docs/platforms/javascript/guides/electron/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,45 @@ init({
});
```

### Custom IPC Namespace

If your Electron application uses multiple IPC channels and you want to prevent potential conflicts between them, you can specify a custom namespace for the IPC channels used by Sentry with the `ipcNamespace` option.

To use a custom namespace, you need to configure it in all three contexts: main process, renderer processes, and preload scripts.

**In the main process:**

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

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

**In renderer processes:**

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

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

**In preload scripts:**

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

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

When set, the IPC channels used by Sentry will be prefixed with the specified namespace (e.g., `some-app`), helping to avoid conflicts with other IPC channels in your application. Make sure to use the same namespace value across all processes for proper communication.

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

### Preload Injection

The SDK attempts to inject a preload script via [`session.setPreloads(preloads)`](https://www.electronjs.org/docs/latest/api/session#sessetpreloadspreloads) and by default only does this for the `defaultSession`. If you are using other sessions, you can pass custom sessions via the `getSessions` option in the `main` process:
Expand Down
Loading