Skip to content
Draft
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
16 changes: 16 additions & 0 deletions .github/dependency-review-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Configuration for the org-level dependency-review workflow.
#
# electron is a devDependency only (used to build and test the SDK, it is never
# shipped to consumers) so these Electron advisories do not affect downstream
# apps, which pin their own Electron version. They are flagged against the floor
# of our supported range (35.7.5); newer Electron versions we test against are
# patched.
fail-on-severity: 'high'
allow-ghsas:
- GHSA-v3j7-r9gq-3gjw # Electron: custom protocol supportFetchAPI cross-origin reads
- GHSA-9wfr-w7mm-pc7f # Electron: renderer command-line switch injection
- GHSA-jjp3-mq3x-295m # Electron: use-after-free in PowerMonitor
- GHSA-8337-3p73-46f4 # Electron: use-after-free in WebContents permission callbacks
- GHSA-h7rp-cf8h-j98x # Electron: context isolation bypass via Function.prototype.bind
- GHSA-532v-xpq5-8h95 # Electron: use-after-free in offscreen paint callback
- GHSA-9f4c-93c8-jc8g # Electron: sandboxed iframe allow-popups bypass
8 changes: 8 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
This document details the changes between major versions of the Sentry Electron
SDK.

- [Upgrading from 7.x to 8.x](#upgrading-from-7x-to-8x)
- [Upgrading from 6.x to 7.x](#upgrading-from-6x-to-7x)
- [Upgrading from 5.x to 6.x](#upgrading-from-5x-to-6x)
- [Upgrading from 4.x to 5.x](#upgrading-from-4x-to-5x)

# Upgrading from 7.x to 8.x

## Supported Electron Versions

The Sentry Node SDK now requires Node >= 20.19.0 which means the Sentry Electron
SDK now supports Electron >= 35.0.0.

# Upgrading from 6.x to 7.x

Most users won't notice many breaking API changes in v7 but it's worth checking
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Test](https://github.com/getsentry/sentry-electron/actions/workflows/build.yml/b
[`@sentry/browser`](https://github.com/getsentry/sentry-javascript/tree/master/packages/browser))
- Captures **native crashes** (Minidump crash reports) from renderers and the main process
- Collects **breadcrumbs and context** information along with events across renderers and the main process
- Supports `electron >= v23`
- Supports `electron >= v35`

## Usage

Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@
"e2e": "xvfb-maybe vitest run --root=./test/e2e --silent=false --disable-console-intercept"
},
"dependencies": {
"@sentry/browser": "10.73.0",
"@sentry/conventions": "^0.16.0",
"@sentry/core": "10.73.0",
"@sentry/node": "10.73.0"
"@sentry/browser": "11.0.0-rc.0",
"@sentry/conventions": "^0.23.0",
"@sentry/core": "11.0.0-rc.0",
"@sentry/node": "11.0.0-rc.0",
"@sentry/server-utils": "11.0.0-rc.0"
},
"peerDependencies": {
"@sentry/node-native": "10.73.0"
"@sentry/node-native": "11.0.0-rc.0"
},
"peerDependenciesMeta": {
"@sentry/node-native": {
Expand All @@ -120,14 +121,14 @@
},
"devDependencies": {
"@rollup/plugin-typescript": "^12.1.3",
"@sentry/eslint-plugin-sdk": "10.73.0",
"@sentry/node-native": "10.73.0",
"@sentry/eslint-plugin-sdk": "11.0.0-rc.0",
"@sentry/node-native": "11.0.0-rc.0",
"@types/busboy": "^1.5.4",
"@types/koa": "^2.0.52",
"@types/koa-bodyparser": "^4.3.0",
"@types/tmp": "^0.2.2",
"busboy": "^1.6.0",
"electron": "^25.9.8",
"electron": "^35.7.5",
"extract-zip": "^2.0.1",
"koa": "^3.0.1",
"koa-bodyparser": "^4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-electron-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const result = spawnSync('npm', ['view', 'electron', 'dist-tags', '--json'], { e
const allTags = JSON.parse(result.stdout);

const versions = [];
let startVersion = 23;
let startVersion = 35;

while (true) {
const versionTag = `${startVersion}-x-y`;
Expand Down
30 changes: 14 additions & 16 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export {
addIntegration,
amqplibIntegration,
anthropicAIIntegration,
applyDiagnosticsChannelInjectionIntegrations,
bindScopeToEmitter,
buildLaunchDarklyFlagUsedHandler,
captureCheckIn,
Expand All @@ -33,21 +32,21 @@ export {
captureMessage,
captureSession,
close,
connectIntegration,
consoleIntegration,
consoleLoggingIntegration,
contextLinesIntegration,
continueTrace,
createConsolaReporter,
createFlueInstrumentation,
createGetModuleFromFilename,
createLangChainCallbackHandler,
createSentryWinstonTransport,
createTransport,
cron,
dataloaderIntegration,
dedupeIntegration,
diagnosticsChannelInjectionIntegrations,
endSession,
eveConversationHook,
eventFiltersIntegration,
expressErrorHandler,
expressIntegration,
Expand All @@ -58,14 +57,15 @@ export {
flush,
fsIntegration,
functionToStringIntegration,
generateInstrumentOnce,
genericPoolIntegration,
getActiveSpan,
getAutoPerformanceIntegrations,
getClient,
getCurrentScope,
getGlobalScope,
getInstrumentedModuleNames,
getIsolationScope,
getOtlpTracesEndpoint,
getRootSpan,
getSpanDescendants,
getSpanStatusFromHttpCode,
Expand All @@ -75,23 +75,19 @@ export {
growthbookIntegration,
graphqlIntegration,
hapiIntegration,
honoIntegration,
httpHeadersToSpanAttributes,
httpIntegration,
httpServerIntegration,
httpServerSpansIntegration,
// eslint-disable-next-line deprecation/deprecation
inboundFiltersIntegration,
initOpenTelemetry,
instrumentAnthropicAiClient,
instrumentGoogleGenAIClient,
instrumentLangChainEmbeddings,
instrumentLangGraph,
instrumentMistralAiClient,
instrumentOpenAiClient,
instrumentStateGraph,
instrumentStateGraphCompile,
instrumentSupabaseClient,
isDiagnosticsChannelInjectionEnabled,
isEnabled,
isInitialized,
kafkaIntegration,
Expand All @@ -105,7 +101,9 @@ export {
localVariablesIntegration,
logger,
lruMemoizerIntegration,
mastraIntegration,
metrics,
mistralAIIntegration,
modulesIntegration,
mongoIntegration,
mongooseIntegration,
Expand All @@ -119,6 +117,7 @@ export {
openAIIntegration,
OpenFeatureIntegrationHook,
openFeatureIntegration,
openTelemetryIntegration,
parameterize,
pinoIntegration,
postgresIntegration,
Expand All @@ -129,11 +128,11 @@ export {
requestDataIntegration,
rewriteFramesIntegration,
Scope,
SentryMastraExporter,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SentryContextManager,
SENTRY_SEGMENT_NAME_SOURCE,
setAttribute,
setAttributes,
setConversationId,
Expand All @@ -143,19 +142,18 @@ export {
setExtras,
setHttpStatus,
setMeasurement,
setNodeAsyncContextStrategy,
setOpenTelemetryContextAsyncContextStrategy,
setTag,
setTags,
setupConnectErrorHandler,
setupExpressErrorHandler,
setupFastifyErrorHandler,
setupHapiErrorHandler,
setupHonoErrorHandler,
setupKoaErrorHandler,
setUser,
spanStreamingIntegration,
spanToBaggageHeader,
spanToJSON,
spanToStaticSpanJSON,
spanToTraceHeader,
spotlightIntegration,
startInactiveSpan,
Expand All @@ -171,14 +169,14 @@ export {
trpcMiddleware,
unleashIntegration,
updateSpanName,
experimentalUseDiagnosticsChannelInjection,
validateOpenTelemetrySetup,
winterCGHeadersToDict,
withActiveSpan,
withIsolationScope,
withMonitor,
withScope,
withStaticSpan,
withStreamedSpan,
workerThreadsIntegration,
wrapMcpServerWithSentry,
zodErrorsIntegration,
} from '@sentry/node';
Expand Down
10 changes: 2 additions & 8 deletions src/main/integrations/renderer-anr.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import type { Client, Event, Integration, StackFrame } from '@sentry/core';
import {
callFrameToStackFrame,
captureEvent,
debug,
defineIntegration,
stripSentryFramesAndReverse,
watchdogTimer,
} from '@sentry/core';
import { captureEvent, debug, defineIntegration, stripSentryFramesAndReverse } from '@sentry/core';
import { callFrameToStackFrame, watchdogTimer } from '@sentry/core/server';
import { createGetModuleFromFilename } from '@sentry/node';
import type { WebContents } from 'electron';
import { app, powerMonitor } from 'electron';
Expand Down
22 changes: 3 additions & 19 deletions src/main/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import {
eventFiltersIntegration,
functionToStringIntegration,
getCurrentScope,
initOpenTelemetry,
linkedErrorsIntegration,
localVariablesIntegration,
nativeNodeFetchIntegration,
NodeClient,
nodeContextIntegration,
onUnhandledRejectionIntegration,
setNodeAsyncContextStrategy,
} from '@sentry/node';
import type { Session, WebContents } from 'electron';
import { session } from 'electron';
Expand Down Expand Up @@ -155,23 +153,17 @@ export type ElectronMainOptions = Pick<
Omit<ElectronMainOptionsInternal, 'getSessions' | 'ipcMode' | 'ipcNamespace'> &
NodeOptions;

function resolveUserInfo(options: ElectronMainOptions): boolean {
const base = options.dataCollection != null ? true : !!options.sendDefaultPii;
const dc = options.dataCollection ?? {};
return dc.userInfo ?? base;
}

/**
* Initialize Sentry in the Electron main process
*/
export function init(userOptions: ElectronMainOptions): void {
const [major = 0] = process.versions.electron.split('.').map(Number);

if (major < 23) {
throw new Error('Sentry Electron SDK requires Electron 23 or higher');
if (major < 35) {
throw new Error('Sentry Electron SDK requires Electron 35 or higher');
}

const inferIpAddress = resolveUserInfo(userOptions);
const inferIpAddress = userOptions.dataCollection?.userInfo ?? true;

const optionsWithDefaults = {
_metadata: { sdk: getSdkInfo(inferIpAddress) },
Expand Down Expand Up @@ -200,8 +192,6 @@ export function init(userOptions: ElectronMainOptions): void {
removeRedundantIntegrations(options);
configureUtilityProcessIPC();

setNodeAsyncContextStrategy();

const scope = getCurrentScope();
scope.update(options.initialScope);

Expand All @@ -223,12 +213,6 @@ export function init(userOptions: ElectronMainOptions): void {
client.init();

configureIPC(client, options);

// If users opt-out of this, they _have_ to set up OpenTelemetry themselves
// There is no way to use this SDK without OpenTelemetry!
if (!options.skipOpenTelemetrySetup) {
initOpenTelemetry(client);
}
}

/** A list of integrations which cause default integrations to be removed */
Expand Down
3 changes: 2 additions & 1 deletion src/main/stack-parse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { StackFrame, StackParser } from '@sentry/core';
import { createStackParser, debug, nodeStackLineParser } from '@sentry/core';
import { createStackParser, debug } from '@sentry/core';
import { nodeStackLineParser } from '@sentry/core/server';
import { createGetModuleFromFilename } from '@sentry/node';
import type { WebContents, WebFrameMain } from 'electron';
import { app } from 'electron';
Expand Down
2 changes: 1 addition & 1 deletion src/main/transports/electron-net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function getRequestOptions(url: string): Electron.ClientRequestConstructorOption
hostname,
path: `${pathname}${search}`,
port: parseInt(port, 10),
protocol,
protocol: protocol as 'http:' | 'https:',
// Use a non-persistent in-memory session to avoid triggering a macOS keychain
// prompt during Chromium's cookie-store initialization of the default session.
partition: 'sentry-electron',
Expand Down
Loading