Skip to content

Commit c2ab389

Browse files
Document ipcNamespace option for Sentry Electron (#14978)
Documents getsentry/sentry-electron#1234 ## DESCRIBE YOUR PR This PR documents the `ipcNamespace` option for the Sentry Electron SDK. This option allows users to specify a custom namespace for Sentry's IPC channels, preventing potential conflicts in applications that use multiple IPC channels. The documentation has been added to: * The main Electron guide (`docs/platforms/javascript/guides/electron/index.mdx`) with a new "Custom IPC Namespace" subsection. * The common configuration options page (`docs/platforms/javascript/common/configuration/options.mdx`) with a detailed `SdkOption` entry. ## IS YOUR CHANGE URGENT? - [ ] 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) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --- [Slack Thread](https://sentry.slack.com/archives/D0913PZP35W/p1758212038049479?thread_ts=1758212038.049479&cid=D0913PZP35W) <a href="https://cursor.com/background-agent?bcId=bc-1e45b0f6-7e47-45dd-80df-7c8f432ef00a"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-1e45b0f6-7e47-45dd-80df-7c8f432ef00a"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> --------- Co-authored-by: Cursor Agent <[email protected]>
1 parent beafd53 commit c2ab389

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,23 @@ Available options are:
277277

278278
</SdkOption>
279279

280+
<SdkOption name="ipcNamespace" type='string'>
281+
282+
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.
283+
284+
```javascript
285+
import * as Sentry from "@sentry/electron/main";
286+
287+
Sentry.init({
288+
dsn: "___PUBLIC_DSN___",
289+
ipcNamespace: "myCustomNamespace",
290+
});
291+
```
292+
293+
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.
294+
295+
</SdkOption>
296+
280297
<SdkOption name="getSessions" type='() => Electron.Session[]' defaultValue='() => [session.defaultSession]'>
281298

282299
A function that returns an array of Electron `session` objects. These sessions are used to configure communication between the Electron main and renderer processes.

docs/platforms/javascript/guides/electron/index.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,45 @@ init({
211211
});
212212
```
213213

214+
### Custom IPC Namespace
215+
216+
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.
217+
218+
To use a custom namespace, you need to configure it in all three contexts: main process, renderer processes, and preload scripts.
219+
220+
**In the main process:**
221+
222+
```javascript
223+
import * as Sentry from "@sentry/electron/main";
224+
225+
Sentry.init({
226+
dsn: "___PUBLIC_DSN___",
227+
ipcNamespace: "some-app",
228+
});
229+
```
230+
231+
**In renderer processes:**
232+
233+
```javascript
234+
import * as Sentry from '@sentry/electron/renderer';
235+
236+
Sentry.init({
237+
ipcNamespace: 'some-app',
238+
});
239+
```
240+
241+
**In preload scripts:**
242+
243+
```javascript
244+
import { hookupIpc } from '@sentry/electron/preload-namespaced';
245+
246+
hookupIpc('some-app');
247+
```
248+
249+
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.
250+
251+
For more configuration options, see the <PlatformLink to="/configuration/options/#ipcNamespace">configuration options documentation</PlatformLink>.
252+
214253
### Preload Injection
215254

216255
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:

0 commit comments

Comments
 (0)