Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update JavaScript SDKs to v9.0.0 #1072

Merged
merged 19 commits into from
Feb 11, 2025
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
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

## Unreleased

## 6.0.0

This release updates the underlying Sentry JavaScript SDKs to v9 which includes
some breaking changes. Check out the the [migration guide](./MIGRATION.md) for
more details.

- feat: Update JavaScript SDKs to v9.0.0 (#1072)

### Supported Electron Versions

The Sentry Node SDK now requires Node >= 18.0.0 which means the Sentry Electron
SDK now supports Electron >= 23.0.0.

### The `autoSessionTracking` option has been removed

Whereas in v5, session tracking was disabled by setting `autoSessionTracking` to
`false`, in v6 session tracking can be disabled by removing the `MainProcessSession` integration

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

Sentry.init({
dsn: "__DSN__",
// autoSessionTracking: false,
integrations: (defaults) => defaults.filter((i) => i.name !== "MainProcessSession"),
});
```

## 5.11.0

- feat: Update from
Expand Down
63 changes: 63 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
This document details the changes between major versions of the Sentry Electron
SDK.

- [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 5.x to 6.x

Most users won't notice many breaking API changes in v6 but it's worth checking out the
[JavaScript v9 migration guide](https://docs.sentry.io/platforms/javascript/migration/v8-to-v9/).

## Supported Electron Versions

The Sentry Node SDK now requires Node >= 18.0.0 which means the Sentry Electron
SDK now supports Electron >= 23.0.0.

## Other notable changes

### The `autoSessionTracking` option has been removed

Whereas in v5, session tracking was disabled by setting `autoSessionTracking` to
`false`:

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

Sentry.init({
dsn: "__DSN__",
autoSessionTracking: false,
});
```

In v6, session tracking can be disabled by removing the `MainProcessSession` integration:

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

Sentry.init({
dsn: "__DSN__",
integrations: (defaults) =>
defaults.filter((i) => i.name !== "MainProcessSession"),
});
```

### `processThreadBreadcrumbIntegration` has been removed

The `processThreadBreadcrumbIntegration` has been removed and it's functionality
is now in the `childProcessIntegration`.


### Include IP Addresses

The SDK only includes the IP address of the user if `sendDefaultPii` is set to `true`:

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

Sentry.init({
dsn: "__DSN__",
sendDefaultPii: true,
});
```

# Upgrading from 4.x to 5.x

Many breaking changes in v5 are due to changes in the underlying Sentry JavaScript SDKs so be sure to check the
Expand Down
2 changes: 1 addition & 1 deletion examples/electron-forge-webpack/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { init } from '@sentry/electron/main';
init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
integrations: (integrations) => integrations.filter((i) => i.name !== 'MainProcessSession'),
onFatalError: () => {},
});

Expand Down
4 changes: 2 additions & 2 deletions examples/electron-forge/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const { init } = require('@sentry/electron/main');
init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
onFatalError: () => {},
integrations: (integrations) => integrations.filter((i) => i.name !== 'MainProcessSession'),
onFatalError: () => { },
});

if (require('electron-squirrel-startup')) {
Expand Down
2 changes: 1 addition & 1 deletion examples/electron-react-boilerplate/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as Sentry from '@sentry/electron/main';
Sentry.init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
integrations: (integrations) => integrations.filter((i) => i.name !== 'MainProcessSession'),
onFatalError: () => {},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/electron-vite/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { init } from '@sentry/electron/main';
init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
integrations: (integrations) => integrations.filter((i) => i.name !== 'MainProcessSession'),
onFatalError: () => {},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/webpack-context-isolation-preload/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { init } from '@sentry/electron/main';
init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
integrations: (integrations) => integrations.filter((i) => i.name !== 'MainProcessSession'),
onFatalError: () => {},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/webpack-context-isolation/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { init } from '@sentry/electron/main';
init({
dsn: '__DSN__',
debug: true,
autoSessionTracking: false,
integrations: (integrations) => integrations.filter((i) => i.name !== 'MainProcessSession'),
onFatalError: () => {},
});

Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@
"fix": "run-s fix:eslint fix:prettier",
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
"fix:eslint": "eslint . --format stylish --fix",
"update-electron-versions": "electron-latest-versions --start 15 --beta > ./test/e2e/versions.json",
"update-electron-versions": "electron-latest-versions --start 23 --beta > ./test/e2e/versions.json",
"update-sdk-versions": "node ./scripts/update-sdk-versions.mjs",
"pretest": "yarn build",
"test": "vitest run --root=./test/unit",
"pree2e": "rimraf --glob test/e2e/dist/**/node_modules/@sentry/** test/e2e/dist/**/yarn.lock test/e2e/dist/**/package-lock.json && node scripts/clean-cache.js && yarn build && npm pack",
"e2e": "xvfb-maybe vitest run --root=./test/e2e --silent=false --disable-console-intercept"
},
"dependencies": {
"@sentry/browser": "8.54.0",
"@sentry/core": "8.54.0",
"@sentry/node": "8.54.0",
"@sentry/browser": "9.0.0",
"@sentry/core": "9.0.0",
"@sentry/node": "9.0.0",
"deepmerge": "4.3.1"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.6",
"@sentry-internal/eslint-config-sdk": "8.54.0",
"@sentry-internal/typescript": "8.54.0",
"@sentry-internal/eslint-config-sdk": "9.0.0",
"@sentry-internal/typescript": "9.0.0",
"@types/busboy": "^1.5.4",
"@types/form-data": "^2.5.0",
"@types/koa": "^2.0.52",
Expand All @@ -90,12 +90,12 @@
"tmp": "^0.2.1",
"rollup": "^4.13.1",
"typescript": "^4.9.5",
"vitest": "^1.4.0",
"vitest": "^3.0.5",
"xvfb-maybe": "^0.2.1",
"yaml": "^2.2.1"
},
"volta": {
"node": "20.12.0",
"yarn": "1.22.19"
"yarn": "1.22.22"
}
}
}
2 changes: 2 additions & 0 deletions scripts/check-exports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const ignoredNode = [
// We don't include these by default in the Electron SDK
'getDefaultIntegrationsWithoutPerformance',
'initWithoutDefaultIntegrations',
// We can't call these from Electron
'vercelAIIntegration',
];

const ignoredUtility = [...ignoredNode, 'anrIntegration'];
Expand Down
12 changes: 0 additions & 12 deletions src/common/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { MeasurementUnit, Primitive } from '@sentry/core';

/** Ways to communicate between the renderer and main process */
export enum IPCMode {
/** Configures Electron IPC to receive messages from renderers */
Expand Down Expand Up @@ -58,22 +56,12 @@ export interface RendererStatus {
config: RendererProcessAnrOptions;
}

export interface MetricIPCMessage {
metricType: 'c' | 'g' | 's' | 'd';
name: string;
value: number | string;
unit?: MeasurementUnit;
tags?: Record<string, Primitive>;
timestamp?: number;
}

export interface IPCInterface {
sendRendererStart: () => void;
sendScope: (scope: string) => void;
sendEvent: (event: string) => void;
sendEnvelope: (evn: Uint8Array | string) => void;
sendStatus: (state: RendererStatus) => void;
sendAddMetric: (metric: MetricIPCMessage) => void;
}

export const RENDERER_ID_HEADER = 'sentry-electron-renderer-id';
Expand Down
18 changes: 0 additions & 18 deletions src/main/electron-normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ export function getSentryCachePath(): string {
return join(app.getPath('userData'), 'sentry');
}

/**
* Uses Crashpad on Linux
* https://github.com/electron/electron/issues/27859
*/
function crashpadLinux(): boolean {
if (version.major >= 16) {
return true;
}

// Crashpad Linux for v15 is behind a switch
return app.commandLine.hasSwitch('enable-crashpad');
}

/** Is using Crashpad */
export function usesCrashpad(): boolean {
return process.platform !== 'linux' || crashpadLinux();
}

/**
* Electron >= 25 support `protocol.handle`
*/
Expand Down
23 changes: 0 additions & 23 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ export type {
Breadcrumb,
BreadcrumbHint,
PolymorphicRequest,
// eslint-disable-next-line deprecation/deprecation
Request,
SdkInfo,
Event,
EventHint,
Expand All @@ -21,10 +19,6 @@ export {
addBreadcrumb,
addEventProcessor,
addIntegration,
// eslint-disable-next-line deprecation/deprecation
addOpenTelemetryInstrumentation,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
amqplibIntegration,
captureCheckIn,
captureConsoleIntegration,
Expand All @@ -42,16 +36,11 @@ export {
createTransport,
cron,
dataloaderIntegration,
// eslint-disable-next-line deprecation/deprecation
debugIntegration,
dedupeIntegration,
DEFAULT_USER_INCLUDES,
disableAnrDetectionForCallback,
endSession,
expressErrorHandler,
expressIntegration,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
extraErrorDataIntegration,
fastifyIntegration,
flush,
Expand All @@ -62,8 +51,6 @@ export {
getActiveSpan,
getAutoPerformanceIntegrations,
getClient,
// eslint-disable-next-line deprecation/deprecation
getCurrentHub,
getCurrentScope,
getGlobalScope,
getIsolationScope,
Expand All @@ -85,24 +72,18 @@ export {
linkedErrorsIntegration,
localVariablesIntegration,
lruMemoizerIntegration,
// eslint-disable-next-line deprecation/deprecation
metrics,
modulesIntegration,
mongoIntegration,
mongooseIntegration,
mysql2Integration,
mysqlIntegration,
nativeNodeFetchIntegration,
// eslint-disable-next-line deprecation/deprecation
nestIntegration,
NodeClient,
nodeContextIntegration,
onUnhandledRejectionIntegration,
parameterize,
postgresIntegration,
prismaIntegration,
// eslint-disable-next-line deprecation/deprecation
processThreadBreadcrumbIntegration,
profiler,
redisIntegration,
requestDataIntegration,
Expand All @@ -113,8 +94,6 @@ export {
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
// eslint-disable-next-line deprecation/deprecation
sessionTimingIntegration,
setContext,
setCurrentClient,
setExtra,
Expand All @@ -129,8 +108,6 @@ export {
setupFastifyErrorHandler,
setupHapiErrorHandler,
setupKoaErrorHandler,
// eslint-disable-next-line deprecation/deprecation
setupNestErrorHandler,
setUser,
spanToBaggageHeader,
spanToJSON,
Expand Down
Loading
Loading