Skip to content

meta: Sync develop to master for 9.0.0 #15350

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

Merged
merged 18 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
54f56a9
chore(docs): Add notice of AWS Lambda Layer changes for v9 (#15322)
andreiborza Feb 6, 2025
dbdbfa7
docs: Align migration guide with docs (#15324)
lforst Feb 6, 2025
0c53293
Merge pull request #15326 from getsentry/master
github-actions[bot] Feb 6, 2025
e10db30
chore(nextjs): Bump sentry webpack plugin to 3.1.2 (#15284)
chargome Feb 6, 2025
f2a777a
chore: Bump volta to node 20 (#15315)
chargome Feb 6, 2025
86f76e4
meta: Add v9 draft changelog and sync with v8 changelog (#15331)
lforst Feb 6, 2025
cbc9da9
fix(nextjs): Use batched devserver symbolication endpoint (#15335)
lforst Feb 7, 2025
dd55860
test(node): Remove last example.com requests in node integration test…
Lms24 Feb 7, 2025
2bcdf9c
feat(deps): Bump @sentry/rollup-plugin from 2.22.7 to 3.1.2 (#15329)
dependabot[bot] Feb 7, 2025
6deb156
chore: Update versions in migraton notice (#15336)
andreiborza Feb 7, 2025
53194d7
test(browser): Avoid using `example.com` for browser-integration-test…
mydea Feb 7, 2025
36878d1
feat(nuxt): Add `enabled` to disable Sentry module (#15337)
s1gr1d Feb 7, 2025
61f5fd5
feat(react-router): Add basic package (#15289)
chargome Feb 7, 2025
725a548
feat(node): Add missing `vercelAIIntegration` export (#15318)
aryanvdesh Feb 7, 2025
22f841e
feat(flags): add Statsig browser integration (#15319)
aliu39 Feb 8, 2025
538fc0a
meta(changelog): Update changelog for 9.0.0
lforst Feb 10, 2025
3c48ac6
ci: Re-enable AWS lambda layer publishing (#15348)
lforst Feb 10, 2025
8d3851c
Merge pull request #15349 from getsentry/prepare-release/9.0.0
lforst Feb 10, 2025
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
27 changes: 13 additions & 14 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,19 @@ targets:
includeNames: /^sentry-internal-eslint-config-sdk-\d.*\.tgz$/

# AWS Lambda Layer target
# TODO(v9): Once stable, re-add this target to publish the AWS Lambda layer
# - name: aws-lambda-layer
# includeNames: /^sentry-node-serverless-\d+.\d+.\d+(-(beta|alpha|rc)\.\d+)?\.zip$/
# layerName: SentryNodeServerlessSDKv9
# compatibleRuntimes:
# - name: node
# versions:
# - nodejs10.x
# - nodejs12.x
# - nodejs14.x
# - nodejs16.x
# - nodejs18.x
# - nodejs20.x
# license: MIT
- name: aws-lambda-layer
includeNames: /^sentry-node-serverless-\d+.\d+.\d+(-(beta|alpha|rc)\.\d+)?\.zip$/
layerName: SentryNodeServerlessSDKv9
compatibleRuntimes:
- name: node
versions:
- nodejs10.x
- nodejs12.x
- nodejs14.x
- nodejs16.x
- nodejs18.x
- nodejs20.x
license: MIT

# CDN Bundle Target
- name: gcs
Expand Down
354 changes: 352 additions & 2 deletions CHANGELOG.md

Large diffs are not rendered by default.

40 changes: 25 additions & 15 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ These docs walk through how to migrate our JavaScript SDKs through different maj

# Upgrading from 8.x to 9.x

Version 9 of the Sentry JavaScript SDK concerns API cleanup and version support changes.
This update contains behavioral changes that will not be caught by type checkers, linters or tests, so we recommend carefully reading through the entire migration guide instead of purely relying on automatic tooling.
Version 9 of the Sentry JavaScript SDK primarily introduces API cleanup and version support changes.
This update contains behavioral changes that will not be caught by type checkers, linters, or tests, so we recommend carefully reading through the entire migration guide instead of relying on automatic tooling.

`v9` of the SDK is compatible with Sentry self-hosted versions 24.4.2 or higher (unchanged from v8).
Version 9 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or higher (unchanged from v8).
Lower versions may continue to work, but may not support all features.

## 1. Version Support Changes:
Expand All @@ -27,16 +27,16 @@ This includes features like Nullish Coalescing (`??`), Optional Chaining (`?.`),
If you observe failures due to syntax or features listed above, it may indicate that your current runtime does not support ES2020.
If your runtime does not support ES2020, we recommend transpiling the SDK using Babel or similar tooling.

**Node.js:** The minimum supported Node.js version is **18.0.0**, except for ESM-only SDKs (`@sentry/astro`, `@sentry/nuxt`, `@sentry/sveltekit`) which require Node.js version **18.19.1** or higher.
**Node.js:** The minimum supported Node.js version is **18.0.0** (Released Apr 19, 2022), except for ESM-only SDKs (`@sentry/astro`, `@sentry/nuxt`, `@sentry/sveltekit`) which require Node.js version **18.19.1** (Released Feb 14, 2024) or higher.

**Browsers:** Due to SDK code now including ES2020 features, the minimum supported browser list now looks as follows:

- Chrome 80
- Edge 80
- Safari 14, iOS Safari 14.4
- Firefox 74
- Opera 67
- Samsung Internet 13.0
- Chrome 80 (Released Feb 5, 2020)
- Edge 80 (Released Feb 7, 2020)
- Safari 14, iOS Safari 14.4 (Released Sep 16, 2020)
- Firefox 74 (Released Mar 10, 2020)
- Opera 67 (Released Mar 12, 2020)
- Samsung Internet 13.0 (Released Nov 20, 2020)

If you need to support older browsers, we recommend transpiling your code using SWC, Babel or similar tooling.

Expand All @@ -54,11 +54,21 @@ Support for the following frameworks and library versions are dropped:

### TypeScript Version Policy

In preparation for v2 of the OpenTelemetry SDK, which will raise the minimum required TypeScript version, the minimum required TypeScript version is increased to version `5.0.4`.
In preparation for v2 of the OpenTelemetry SDK, the minimum required TypeScript version is increased to version `5.0.4`.

Additionally, like the OpenTelemetry SDK, the Sentry JavaScript SDK will follow [DefinitelyType's version support policy](https://github.com/DefinitelyTyped/DefinitelyTyped#support-window) which has a support time frame of 2 years for any released version of TypeScript.

Older Typescript versions _may_ continue to be compatible, but no guarantees apply.
Older TypeScript versions _may_ continue to be compatible, but no guarantees apply.

### AWS Lambda Layer Changes

A new AWS Lambda Layer for version 9 will be published as `SentryNodeServerlessSDKv9`.
The ARN will be published in the [Sentry docs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/install/cjs-layer/) once available.

The previous `SentryNodeServerlessSDK` layer will not receive new updates anymore.

Updates and fixes for version 8 will be published as `SentryNodeServerlessSDKv8`.
The ARN will be published in the [Sentry docs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/install/cjs-layer/) once available.

## 2. Behavior Changes

Expand All @@ -80,7 +90,7 @@ Older Typescript versions _may_ continue to be compatible, but no guarantees app
While in v8, the passed scope was set active directly on the passed scope, in v9, the scope is cloned. This behavior change does not apply to `@sentry/node` where the scope was already cloned.
This change was made to ensure that the span only remains active within the callback and to align behavior between `@sentry/node` and all other SDKs.
As a result of the change, span hierarchy should be more accurate.
However, modifying the scope (e.g. set tags) within the `startSpan` callback behaves a bit differently now.
However, modifying the scope (for example, setting tags) within the `startSpan` callback behaves a bit differently now.

```js
startSpan({ name: 'example', scope: customScope }, () => {
Expand All @@ -91,12 +101,12 @@ Older Typescript versions _may_ continue to be compatible, but no guarantees app
```

- Passing `undefined` as a `tracesSampleRate` option value will now be treated the same as if the attribute was not defined at all.
In previous versions, it was checked whether the `tracesSampleRate` property existed in the SDK options to determine whether to propagate trace data for distributed tracing.
In previous versions, it was checked whether the `tracesSampleRate` property existed in the SDK options to decide if trace data should be propagated for tracing.
Consequentially, this sometimes caused the SDK to propagate negative sampling decisions when `tracesSampleRate: undefined` was passed.
This is no longer the case and sampling decisions will be deferred to downstream SDKs for distributed tracing.
This is more of a bugfix rather than a breaking change, however, depending on the setup of your SDKs, an increase in sampled traces may be observed.

- If you use the optional `captureConsoleIntegration` and set `attachStackTrace: true` in your `Sentry.init` call, console messages will no longer be marked as unhandled (i.e. `handled: false`) but as handled (i.e. `handled: true`).
- If you use the optional `captureConsoleIntegration` and set `attachStackTrace: true` in your `Sentry.init` call, console messages will no longer be marked as unhandled (`handled: false`) but as handled (`handled: true`).
If you want to keep sending them as unhandled, configure the `handled` option when adding the integration:

```js
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Flag evaluation error hook', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
sentryTest.skip();
}

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});

const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

await page.evaluate(bufferSize => {
const client = (window as any).statsigClient;
for (let i = 1; i <= bufferSize; i++) {
client.checkGate(`feat${i}`); // values default to false
}

client.setMockGateValue(`feat${bufferSize + 1}`, true);
client.checkGate(`feat${bufferSize + 1}`); // eviction

client.setMockGateValue('feat3', true);
client.checkGate('feat3'); // update
}, FLAG_BUFFER_SIZE);

const reqPromise = waitForErrorRequest(page);
await page.locator('#error').click();
const req = await reqPromise;
const event = envelopeRequestParser(req);

const expectedFlags = [{ flag: 'feat2', result: false }];
for (let i = 4; i <= FLAG_BUFFER_SIZE; i++) {
expectedFlags.push({ flag: `feat${i}`, result: false });
}
expectedFlags.push({ flag: `feat${FLAG_BUFFER_SIZE + 1}`, result: true });
expectedFlags.push({ flag: 'feat3', result: true });

expect(event.contexts?.flags?.values).toEqual(expectedFlags);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as Sentry from '@sentry/browser';

class MockStatsigClient {
constructor() {
this._gateEvaluationListeners = [];
this._mockGateValues = {};
}

on(event, listener) {
this._gateEvaluationListeners.push(listener);
}

checkGate(name) {
const value = this._mockGateValues[name] || false; // unknown features default to false.
this._gateEvaluationListeners.forEach(listener => {
listener({ gate: { name, value } });
});
return value;
}

setMockGateValue(name, value) {
this._mockGateValues[name] = value;
}
}

window.statsigClient = new MockStatsigClient();

window.Sentry = Sentry;
window.sentryStatsigIntegration = Sentry.statsigIntegration({ featureFlagClient: window.statsigClient });

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
sampleRate: 1.0,
integrations: [window.sentryStatsigIntegration],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.getElementById('error').addEventListener('click', () => {
throw new Error('Button triggered error');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<button id="error">Throw Error</button>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

import type { Scope } from '@sentry/browser';

sentryTest('Flag evaluations in forked scopes are stored separately.', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
sentryTest.skip();
}

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});

const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

const forkedReqPromise = waitForErrorRequest(page, event => !!event.tags?.isForked === true);
const mainReqPromise = waitForErrorRequest(page, event => !!event.tags?.isForked === false);

await page.evaluate(() => {
const Sentry = (window as any).Sentry;
const errorButton = document.querySelector('#error') as HTMLButtonElement;
const client = (window as any).statsigClient;

client.setMockGateValue('shared', true);
client.setMockGateValue('main', true);

client.checkGate('shared');

Sentry.withScope((scope: Scope) => {
client.setMockGateValue('forked', true);
client.setMockGateValue('shared', false); // override the value in the parent scope.

client.checkGate('forked');
client.checkGate('shared');
scope.setTag('isForked', true);
errorButton.click();
});

client.checkGate('main');
Sentry.getCurrentScope().setTag('isForked', false);
errorButton.click();
return true;
});

const forkedReq = await forkedReqPromise;
const forkedEvent = envelopeRequestParser(forkedReq);

const mainReq = await mainReqPromise;
const mainEvent = envelopeRequestParser(mainReq);

expect(forkedEvent.contexts?.flags?.values).toEqual([
{ flag: 'forked', result: true },
{ flag: 'shared', result: false },
]);

expect(mainEvent.contexts?.flags?.values).toEqual([
{ flag: 'shared', result: true },
{ flag: 'main', result: true },
]);
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
window.calls = {};
const xhr = new XMLHttpRequest();
xhr.open('GET', 'http://example.com');
xhr.open('GET', 'http://sentry-test-site.example');
xhr.onreadystatechange = function wat() {
window.calls[xhr.readyState] = window.calls[xhr.readyState] ? window.calls[xhr.readyState] + 1 : 1;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sentryTest(
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('http://example.com/', route => {
await page.route('http://sentry-test-site.example/', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ document.getElementById('go-background').addEventListener('click', () => {
});

document.getElementById('fetch').addEventListener('click', () => {
fetch('https://example.com', { method: 'POST', body: 'foo' });
fetch('https://sentry-test-site.example', { method: 'POST', body: 'foo' });
});

document.getElementById('xhr').addEventListener('click', () => {
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://example.com');
xhr.open('GET', 'https://sentry-test-site.example');
xhr.send();
});
Loading
Loading