From 0846dca050ac933c67de52010ed8bb761c275014 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 18 Sep 2025 16:18:31 +0000 Subject: [PATCH 1/2] Add ipcNamespace option to Electron SDK Co-authored-by: aprasad --- .../javascript/common/configuration/options.mdx | 17 +++++++++++++++++ .../javascript/guides/electron/index.mdx | 15 +++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/docs/platforms/javascript/common/configuration/options.mdx b/docs/platforms/javascript/common/configuration/options.mdx index 806c61d3832a1..34f85860466f1 100644 --- a/docs/platforms/javascript/common/configuration/options.mdx +++ b/docs/platforms/javascript/common/configuration/options.mdx @@ -277,6 +277,23 @@ Available options are: + + +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. + + + A function that returns an array of Electron `session` objects. These sessions are used to configure communication between the Electron main and renderer processes. diff --git a/docs/platforms/javascript/guides/electron/index.mdx b/docs/platforms/javascript/guides/electron/index.mdx index c314acb8b6687..2bb43909dd4ec 100644 --- a/docs/platforms/javascript/guides/electron/index.mdx +++ b/docs/platforms/javascript/guides/electron/index.mdx @@ -211,6 +211,21 @@ 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: + +```javascript +import * as Sentry from "@sentry/electron/main"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + ipcNamespace: "myAppSentry", +}); +``` + +When set, the IPC channels used by Sentry will be prefixed with the specified namespace, helping to avoid conflicts with other IPC channels in your application. For more configuration options, see the configuration options documentation. + ### 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: From 8b5dc1c1e1a17a16f5eb4b7ea60113a7b5c69192 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 18 Sep 2025 16:22:47 +0000 Subject: [PATCH 2/2] docs: Clarify custom IPC namespace setup for Electron Co-authored-by: aprasad --- .../common/configuration/options.mdx | 2 +- .../javascript/guides/electron/index.mdx | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/platforms/javascript/common/configuration/options.mdx b/docs/platforms/javascript/common/configuration/options.mdx index 34f85860466f1..39d18858533a4 100644 --- a/docs/platforms/javascript/common/configuration/options.mdx +++ b/docs/platforms/javascript/common/configuration/options.mdx @@ -290,7 +290,7 @@ Sentry.init({ }); ``` -When set, the IPC channels used by Sentry will be prefixed with the specified namespace. +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 Custom IPC Namespace section for complete setup instructions. diff --git a/docs/platforms/javascript/guides/electron/index.mdx b/docs/platforms/javascript/guides/electron/index.mdx index 2bb43909dd4ec..fa823d6e90af8 100644 --- a/docs/platforms/javascript/guides/electron/index.mdx +++ b/docs/platforms/javascript/guides/electron/index.mdx @@ -213,18 +213,42 @@ 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: +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: "myAppSentry", + ipcNamespace: "some-app", }); ``` -When set, the IPC channels used by Sentry will be prefixed with the specified namespace, helping to avoid conflicts with other IPC channels in your application. For more configuration options, see the configuration options documentation. +**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 configuration options documentation. ### Preload Injection