Skip to content

Commit 03d4ab1

Browse files
authored
Merge pull request #15867 from getsentry/prepare-release/9.10.0
meta(changelog): Update changelog for 9.10.0
2 parents 905037f + d430d96 commit 03d4ab1

File tree

137 files changed

+2543
-2327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+2543
-2327
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = {
3838
},
3939
},
4040
{
41-
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
41+
files: ['scripts/**/*.ts'],
4242
parserOptions: {
4343
project: ['tsconfig.dev.json'],
4444
},

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ scratch/
1717
# side effects of running AWS lambda layer zip action locally
1818
dist-serverless/
1919
sentry-node-serverless-*.zip
20-
# transpiled transformers
21-
jest/transformers/*.js
2220
# node tarballs
2321
packages/*/sentry-*.tgz
2422
.nxcache

.vscode/launch.json

-29
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,6 @@
5252
"internalConsoleOptions": "openOnSessionStart",
5353
"outputCapture": "std"
5454
},
55-
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
56-
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
57-
// install the recommended extension Tasks Shell Input.
58-
{
59-
"name": "Debug unit tests - just open file",
60-
"type": "node",
61-
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
62-
"request": "launch",
63-
"program": "${workspaceFolder}/node_modules/.bin/jest",
64-
"args": [
65-
"--watch",
66-
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
67-
// you're hitting a single test's breakpoints, in order)
68-
"--runInBand",
69-
// coverage messes up the source maps
70-
"--coverage",
71-
"false",
72-
// remove this to run all package tests
73-
"${relativeFile}"
74-
],
75-
"sourceMaps": true,
76-
"smartStep": true,
77-
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
78-
// "outputCapture" option here; default is to show console logs), but not both
79-
"console": "integratedTerminal",
80-
// since we're not using it, don't automatically switch to it
81-
"internalConsoleOptions": "neverOpen"
82-
},
83-
8455
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
8556
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
8657
// install the recommended extension Tasks Shell Input.

CHANGELOG.md

+82-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,87 @@
1010

1111
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
1212

13+
## 9.10.0
14+
15+
### Important Changes
16+
17+
- **feat: Add support for logs**
18+
19+
- feat(node): Add logging public APIs to Node SDKs ([#15764](https://github.com/getsentry/sentry-javascript/pull/15764))
20+
- feat(core): Add support for `beforeSendLog` ([#15814](https://github.com/getsentry/sentry-javascript/pull/15814))
21+
- feat(core): Add support for parameterizing logs ([#15812](https://github.com/getsentry/sentry-javascript/pull/15812))
22+
- fix: Remove critical log severity level ([#15824](https://github.com/getsentry/sentry-javascript/pull/15824))
23+
24+
All JavaScript SDKs other than `@sentry/cloudflare` and `@sentry/deno` now support sending logs via dedicated methods as part of Sentry's [upcoming logging product](https://github.com/getsentry/sentry/discussions/86804).
25+
26+
Logging is gated by an experimental option, `_experiments.enableLogs`.
27+
28+
```js
29+
Sentry.init({
30+
dsn: 'PUBLIC_DSN',
31+
// `enableLogs` must be set to true to use the logging features
32+
_experiments: { enableLogs: true },
33+
});
34+
35+
const { trace, debug, info, warn, error, fatal, fmt } = Sentry.logger;
36+
37+
trace('Starting database connection', { database: 'users' });
38+
debug('Cache miss for user', { userId: 123 });
39+
error('Failed to process payment', { orderId: 'order_123', amount: 99.99 });
40+
fatal('Database connection pool exhausted', { database: 'users', activeConnections: 100 });
41+
42+
// Structured logging via the `fmt` helper function. When you use `fmt`, the string template and parameters are sent separately so they can be queried independently in Sentry.
43+
44+
info(fmt(`Updated profile for user ${userId}`));
45+
warn(fmt(`Rate limit approaching for endpoint ${endpoint}. Requests: ${requests}, Limit: ${limit}`));
46+
```
47+
48+
With server-side SDKs like `@sentry/node`, `@sentry/bun` or server-side of `@sentry/nextjs` or `@sentry/sveltekit`, you can do structured logging without needing the `fmt` helper function.
49+
50+
```js
51+
const { info, warn } = Sentry.logger;
52+
53+
info('User %s logged in successfully', [123]);
54+
warn('Failed to load user %s data', [123], { errorCode: 404 });
55+
```
56+
57+
To filter logs, or update them before they are sent to Sentry, you can use the `_experiments.beforeSendLog` option.
58+
59+
- **feat(browser): Add `diagnoseSdkConnectivity()` function to programmatically detect possible connectivity issues ([#15821](https://github.com/getsentry/sentry-javascript/pull/15821))**
60+
61+
The `diagnoseSdkConnectivity()` function can be used to programmatically detect possible connectivity issues with the Sentry SDK.
62+
63+
```js
64+
const result = await Sentry.diagnoseSdkConnectivity();
65+
```
66+
67+
The result will be an object with the following properties:
68+
69+
- `"no-client-active"`: There was no active client when the function was called. This possibly means that the SDK was not initialized yet.
70+
- `"sentry-unreachable"`: The Sentry SaaS servers were not reachable. This likely means that there is an ad blocker active on the page or that there are other connection issues.
71+
- `undefined`: The SDK is working as expected.
72+
73+
- **SDK Tracing Performance Improvements for Node SDKs**
74+
75+
- feat: Stop using `dropUndefinedKeys` ([#15796](https://github.com/getsentry/sentry-javascript/pull/15796))
76+
- feat(node): Only add span listeners for instrumentation when used ([#15802](https://github.com/getsentry/sentry-javascript/pull/15802))
77+
- ref: Avoid `dropUndefinedKeys` for `spanToJSON` calls ([#15792](https://github.com/getsentry/sentry-javascript/pull/15792))
78+
- ref: Avoid using `SentryError` for PromiseBuffer control flow ([#15822](https://github.com/getsentry/sentry-javascript/pull/15822))
79+
- ref: Stop using `dropUndefinedKeys` in SpanExporter ([#15794](https://github.com/getsentry/sentry-javascript/pull/15794))
80+
- ref(core): Avoid using `SentryError` for event processing control flow ([#15823](https://github.com/getsentry/sentry-javascript/pull/15823))
81+
- ref(node): Avoid `dropUndefinedKeys` in Node SDK init ([#15797](https://github.com/getsentry/sentry-javascript/pull/15797))
82+
- ref(opentelemetry): Avoid sampling work for non-root spans ([#15820](https://github.com/getsentry/sentry-javascript/pull/15820))
83+
84+
We've been hard at work making performance improvements to the Sentry Node SDKs (`@sentry/node`, `@sentry/aws-serverless`, `@sentry/nestjs`, etc.). We've seen that upgrading from `9.7.0` to `9.10.0` leads to 30-40% improvement in request latency for HTTP web-server applications that use tracing with high sample rates. Non web-server applications and non-tracing applications will see smaller improvements.
85+
86+
### Other Changes
87+
88+
- chore(deps): Bump `rrweb` to `2.35.0` ([#15825](https://github.com/getsentry/sentry-javascript/pull/15825))
89+
- deps: Bump bundler plugins to `3.2.3` ([#15829](https://github.com/getsentry/sentry-javascript/pull/15829))
90+
- feat: Always truncate stored breadcrumb messages to 2kb ([#15819](https://github.com/getsentry/sentry-javascript/pull/15819))
91+
- feat(nextjs): Disable server webpack-handling for static builds ([#15751](https://github.com/getsentry/sentry-javascript/pull/15751))
92+
- fix(nuxt): Don't override Nuxt options if undefined ([#15795](https://github.com/getsentry/sentry-javascript/pull/15795))
93+
1394
## 9.9.0
1495

1596
### Important Changes
@@ -42,7 +123,7 @@
42123

43124
- **feat(browser): Add `logger.X` methods to browser SDK ([#15763](https://github.com/getsentry/sentry-javascript/pull/15763))**
44125

45-
For Sentry's [upcoming logging product](https://github.com/getsentry/sentry/discussions/86804), the SDK now supports sending logs via dedicated
126+
For Sentry's [upcoming logging product](https://github.com/getsentry/sentry/discussions/86804), the SDK now supports sending logs via dedicated methods.
46127

47128
```js
48129
Sentry.init({

CONTRIBUTING.md

-17
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `
7373

7474
Note: you must run `yarn build` before `yarn test` will work.
7575

76-
## Debugging Tests
77-
78-
If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.
79-
80-
0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
81-
tab in the sidebar as one of the recommended workspace extensions.
82-
83-
1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
84-
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
85-
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
86-
4. Click the green "play" button to run the tests in the open file in watch mode.
87-
88-
Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
89-
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
90-
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
91-
part of the buggy test.
92-
9376
## Debug Build Flags
9477

9578
Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
try {
2+
// Create an AggregateError with multiple error objects
3+
const error1 = new Error('First error message');
4+
const error2 = new TypeError('Second error message');
5+
const error3 = new RangeError('Third error message');
6+
7+
// Create the AggregateError with these errors and a message
8+
const aggregateError = new AggregateError([error1, error2, error3], 'Multiple errors occurred');
9+
10+
throw aggregateError;
11+
} catch (err) {
12+
Sentry.captureException(err);
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
5+
6+
sentryTest('should capture an AggregateError with embedded errors', async ({ getLocalTestUrl, page }) => {
7+
const url = await getLocalTestUrl({ testDir: __dirname });
8+
const req = await waitForErrorRequestOnUrl(page, url);
9+
const eventData = envelopeRequestParser(req);
10+
11+
expect(eventData.exception?.values).toHaveLength(4); // AggregateError + 3 embedded errors
12+
13+
// Verify the embedded errors come first
14+
expect(eventData.exception?.values?.[0]).toMatchObject({
15+
type: 'RangeError',
16+
value: 'Third error message',
17+
mechanism: {
18+
type: 'chained',
19+
handled: true,
20+
source: expect.stringMatching(/^errors\[\d+\]$/),
21+
exception_id: expect.any(Number),
22+
},
23+
});
24+
25+
expect(eventData.exception?.values?.[1]).toMatchObject({
26+
type: 'TypeError',
27+
value: 'Second error message',
28+
mechanism: {
29+
type: 'chained',
30+
handled: true,
31+
source: expect.stringMatching(/^errors\[\d+\]$/),
32+
exception_id: expect.any(Number),
33+
},
34+
});
35+
36+
expect(eventData.exception?.values?.[2]).toMatchObject({
37+
type: 'Error',
38+
value: 'First error message',
39+
mechanism: {
40+
type: 'chained',
41+
handled: true,
42+
source: expect.stringMatching(/^errors\[\d+\]$/),
43+
exception_id: expect.any(Number),
44+
},
45+
});
46+
47+
// Verify the AggregateError comes last
48+
expect(eventData.exception?.values?.[3]).toMatchObject({
49+
type: 'AggregateError',
50+
value: 'Multiple errors occurred',
51+
mechanism: {
52+
type: 'generic',
53+
handled: true,
54+
is_exception_group: true,
55+
exception_id: expect.any(Number),
56+
},
57+
stacktrace: {
58+
frames: expect.any(Array),
59+
},
60+
});
61+
62+
// Get parent exception ID for reference checks
63+
const parentId = eventData.exception?.values?.[3].mechanism?.exception_id;
64+
65+
// Verify parent_id references match for all child errors
66+
for (let i = 0; i < 3; i++) {
67+
expect(eventData.exception?.values?.[i].mechanism?.parent_id).toBe(parentId);
68+
}
69+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
_experiments: {
8+
enableLogs: true,
9+
},
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Sentry.logger.trace('test trace');
2+
Sentry.logger.debug('test debug');
3+
Sentry.logger.info('test info');
4+
Sentry.logger.warn('test warn');
5+
Sentry.logger.error('test error');
6+
Sentry.logger.fatal('test fatal');
7+
8+
const formattedMessage = (message, stringArg, boolArg, numberArg) => {
9+
return Sentry.logger.fmt`test ${message} ${stringArg} ${boolArg} ${numberArg}`;
10+
};
11+
12+
Sentry.logger.trace(formattedMessage('trace', 'stringArg', false, 123));
13+
Sentry.logger.debug(formattedMessage('debug', 'stringArg', false, 123));
14+
Sentry.logger.info(formattedMessage('info', 'stringArg', false, 123));
15+
Sentry.logger.warn(formattedMessage('warn', 'stringArg', false, 123));
16+
Sentry.logger.error(formattedMessage('error', 'stringArg', false, 123));
17+
Sentry.logger.fatal(formattedMessage('fatal', 'stringArg', false, 123));
18+
19+
Sentry.flush();

0 commit comments

Comments
 (0)