Migrate from 7.x to 8.x for Electron
Learn about migrating from Sentry Electron SDK 7.x to 8.x.
Version 8 of the Sentry Electron SDK updates the underlying Sentry JavaScript SDKs from version 10 to version 11. Most of the breaking changes come from those SDKs. The biggest changes are:
- Version support: Electron 35 is the new minimum.
- Span streaming: Stream mode is the new default, so the SDK no longer sends transactions.
- Data collection:
sendDefaultPiiis replaced bydataCollection, and the SDK collects more by default. - OpenTelemetry: The SDK no longer sets up OpenTelemetry by default.
This page covers the changes that affect most Electron apps. For the full list of changes, see the JavaScript SDK migration guides:
- Browser JavaScript 10.x to 11.x for the
rendererprocesses - Node.js 10.x to 11.x for the
mainand utility processes
We recommend that you upgrade to the most recent 7.x release first, because most of what version 8 removes is already deprecated there.
Version 8 of the SDK requires Sentry self-hosted 26.4.2 or higher. Lower versions may continue to work, but are not supported.
The Sentry Node SDK now requires Node.js 20.19.0 or higher. Because of this, the Electron SDK now supports Electron 35.0.0 or higher. On older Electron versions, Sentry.init() throws an error in the main process.
Tracing now uses stream mode (traceLifecycle: 'stream') by default. The SDK sends finished spans in batches. It no longer sends a transaction when the root span ends.
If you opted into span streaming in version 7, you can remove traceLifecycle: 'stream' and spanStreamingIntegration() from your configuration.
Because the SDK no longer sends transactions, the beforeSendTransaction and ignoreTransactions options have no effect. Use beforeSendSpan and ignoreSpans instead.
beforeSendSpan callbacks now receive the streamed span format. See The beforeSendSpan Payload Changed for the renamed fields.
Scope tags and extra are not applied to streamed spans. Use Sentry.setAttribute() and Sentry.setAttributes() to set data that must be searchable on spans.
Span names, operations, and attributes also changed for many automatically created spans. If your filters, dashboards, or alerts use them, see Tracing in the JavaScript migration guide.
To keep sending transactions, set traceLifecycle: 'static'. Tracing options apply to the process where they are set, so set the option in each process where you enabled tracing.
In transaction mode, wrap beforeSendSpan callbacks with Sentry.withStaticSpan() to receive the previous span format. The SDK does not call a callback that is not wrapped.
import * as Sentry from "@sentry/electron/main";
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
traceLifecycle: "static",
beforeSendSpan: Sentry.withStaticSpan((span) => {
// `span` has the previous `SpanJSON` format
return span;
}),
});
import * as Sentry from "@sentry/electron/main";
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
traceLifecycle: "static",
beforeSendSpan: Sentry.withStaticSpan((span) => {
// `span` has the previous `SpanJSON` format
return span;
}),
});
import * as Sentry from "@sentry/electron/renderer";
Sentry.init({
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1.0,
traceLifecycle: "static",
});
Transaction mode only exists for backwards compatibility and will be removed in a future major version.
Spans that the ElectronNet integration creates now use the same attributes as the http.client spans from the Node.js and browser SDKs:
- The
url,http.method, andtype: 'net.request'attributes are replaced byhttp.request.method,url.full,url.path,url.query,url.scheme,server.address, andserver.port. - The span name no longer includes the query string or the fragment. In stream mode, the span name is the method and the host, for example
GET example.com. - In stream mode, the integration creates spans even when there is no active parent span.
If your beforeSendSpan callback, dashboards, or alerts use the previous span names or attributes, update them.
The sendDefaultPii option was removed and is replaced by dataCollection, which controls each category of collected data separately.
This is a behavior change, not a rename. The SDK now infers the user's IP address by default. Apps that did not set sendDefaultPii: true in version 7 now send IP addresses.
If you set sendDefaultPii: true, remove it. The version 8 default matches that behavior.
To opt out of IP address inference, set dataCollection: { userInfo: false } in the main process. This setting controls IP address inference for events from all processes:
import * as Sentry from "@sentry/electron/main";
Sentry.init({
dsn: "___PUBLIC_DSN___",
dataCollection: {
userInfo: false,
},
});
import * as Sentry from "@sentry/electron/main";
Sentry.init({
dsn: "___PUBLIC_DSN___",
dataCollection: {
userInfo: false,
},
});
Other categories, such as HTTP bodies and cookies, are also collected by default now. See Data Collection in the JavaScript migration guide for the previous and the new defaults, and the dataCollection option for the full list of categories.
The SDK no longer sets up OpenTelemetry by default. If you only use the Sentry SDK, tracing works as before and you do not need to change anything.
The skipOpenTelemetrySetup option is replaced by enableOpenTelemetrySetup, which defaults to false. Set enableOpenTelemetrySetup: true in the main or utility process to register the Sentry OpenTelemetry tracer provider. The SDK then sends spans created with the OpenTelemetry API to Sentry:
import * as Sentry from "@sentry/electron/main";
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
enableOpenTelemetrySetup: true,
});
import * as Sentry from "@sentry/electron/main";
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
enableOpenTelemetrySetup: true,
});
If you use your own OpenTelemetry setup, do not set enableOpenTelemetrySetup. Instead, add openTelemetryIntegration() to link Sentry events to your OpenTelemetry spans, and use getOtlpTracesEndpoint() to export spans to Sentry. See OpenTelemetry in the Node.js migration guide for an example.
The following exports were removed from @sentry/electron/main and @sentry/electron/utility:
inboundFiltersIntegration. UseeventFiltersIntegrationinstead. The integration name changed fromInboundFilterstoEventFilters.honoIntegrationandsetupHonoErrorHandlerconnectIntegrationandsetupConnectErrorHandlerinstrumentLangGraph. UseinstrumentStateGraphinstead.SentryContextManager,setNodeAsyncContextStrategy,generateInstrumentOnce, andvalidateOpenTelemetrySetupSEMANTIC_ATTRIBUTE_SENTRY_SOURCEexperimentalUseDiagnosticsChannelInjection,diagnosticsChannelInjectionIntegrations,applyDiagnosticsChannelInjectionIntegrations, andisDiagnosticsChannelInjectionEnabled. Diagnostics channel injection is now enabled by default. To disable it, setenableRuntimeChannelInjection: false.
The following exports were removed from @sentry/electron/renderer:
instrumentOpenAiClient,instrumentAnthropicAiClient,instrumentGoogleGenAIClient,instrumentLangGraph,instrumentStateGraph,instrumentCreateReactAgent,instrumentLangChainEmbeddings, andcreateLangChainCallbackHandler. AI integrations are no longer available in the browser SDK. They remain available in themainand utility processes.inboundFiltersIntegration. UseeventFiltersIntegrationinstead.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE
See Removed APIs in the JavaScript migration guide for more removed APIs and their replacements.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").