Skip to content

Commit

Permalink
Merge branch 'develop' into onur/remix-express-formdata
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan authored Mar 8, 2024
2 parents 5ec2c0f + 24c4eba commit 8145fb2
Show file tree
Hide file tree
Showing 100 changed files with 1,068 additions and 1,939 deletions.
83 changes: 76 additions & 7 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ stable release of `8.x` comes out).

## 1. Version Support changes:

**Node.js**: We now official support Node 14.8+ for our CJS package, and Node 18.8+ for our ESM package. This applies to
`@sentry/node` and all of our node-based server-side sdks (`@sentry/nextjs`, `@sentry/serverless`, etc.). We no longer
test against Node 8, 10, or 12 and cannot guarantee that the SDK will work as expected on these versions.
**Node.js**: We now official support Node 14.18+ for our CJS package, and Node 18.8+ for our ESM package. This applies
to `@sentry/node` and all of our node-based server-side sdks (`@sentry/nextjs`, `@sentry/serverless`, etc.). We no
longer test against Node 8, 10, or 12 and cannot guarantee that the SDK will work as expected on these versions.

**Browser**: Our browser SDKs (`@sentry/browser`, `@sentry/react`, `@sentry/vue`, etc.) now require ES2017+ compatible
browsers. This means that we no longer support IE11 (end of an era). This also means that the Browser SDK requires the
Expand Down Expand Up @@ -254,6 +254,7 @@ We now support the following integrations out of the box:
- [Browser SDK](./MIGRATION.md#browser-sdk-browser-react-vue-angular-ember-etc)
- [Server-side SDKs (Node, Deno, Bun)](./MIGRATION.md#server-side-sdks-node-deno-bun-etc)
- [Next.js SDK](./MIGRATION.md#nextjs-sdk)
- [SvelteKit SDK](./MIGRATION.md#sveltekit-sdk)
- [Astro SDK](./MIGRATION.md#astro-sdk)

### General
Expand Down Expand Up @@ -581,6 +582,78 @@ Sentry.init({
});
```

### SvelteKit SDK

#### Breaking `sentrySvelteKit()` changes

We upgraded the `@sentry/vite-plugin` which is a dependency of the SvelteKit SDK from version 0.x to 2.x. With this
change, resolving uploaded source maps should work out of the box much more often than before
([more information](https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js/artifact-bundles/)).

To allow future upgrades of the Vite plugin without breaking stable and public APIs in `sentrySvelteKit`, we modified
the `sourceMapsUploadOptions` to remove the hard dependency on the API of the plugin. While you previously could specify
all [version 0.x Vite plugin options](https://www.npmjs.com/package/@sentry/vite-plugin/v/0.6.1), we now reduced them to
a subset of [2.x options](https://www.npmjs.com/package/@sentry/vite-plugin/v/2.14.2#options). All of these options are
optional just like before but here's an example of using the new options.

```js
// Before (v7):
sentrySvelteKit({
sourceMapsUploadOptions: {
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
release: '1.0.1',
injectRelease: true,
include: ['./build/*/**/*'],
ignore: ['**/build/client/**/*']
},
}),

// After (v8):
sentrySvelteKit({
sourceMapsUploadOptions: {
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
release: {
name: '1.0.1',
inject: true
},
sourcemaps: {
assets: ['./build/*/**/*'],
ignore: ['**/build/client/**/*'],
filesToDeleteAfterUpload: ['./build/**/*.map']
},
},
}),
```

In the future, we might add additional [options](https://www.npmjs.com/package/@sentry/vite-plugin/v/2.14.2#options)
from the Vite plugin but if you would like to specify some of them directly, you can do this by passing in an
`unstable_sentryVitePluginOptions` object:

```js
sentrySvelteKit({
sourceMapsUploadOptions: {
// ...
release: {
name: '1.0.1',
},
unstable_sentryVitePluginOptions: {
release: {
setCommits: {
auto: true
}
}
}
},
}),
```

Important: we DO NOT guarantee stability of `unstable_sentryVitePluginOptions`. They can be removed or updated at any
time, including breaking changes within the same major version of the SDK.

## 5. Behaviour Changes

- [Updated behaviour of `tracePropagationTargets` in the browser](./MIGRATION.md#updated-behaviour-of-tracepropagationtargets-in-the-browser-http-tracing-headers--cors)
Expand Down Expand Up @@ -969,10 +1042,6 @@ instead now.
Instead, you can get the currently active span via `Sentry.getActiveSpan()`. Setting a span on the scope happens
automatically when you use the new performance APIs `startSpan()` and `startSpanManual()`.

## Deprecate `scope.setTransactionName()`

Instead, either set this as attributes or tags, or use an event processor to set `event.transaction`.

## Deprecate `scope.getTransaction()` and `getActiveTransaction()`

Instead, you should not rely on the active transaction, but just use `startSpan()` APIs, which handle this for you.
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "index.js",
"license": "MIT",
"engines": {
"node": ">=14.8"
"node": ">=14.18"
},
"private": true,
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [
Sentry.browserTracingIntegration({
// To avoid having this test run for 15s
childSpanTimeout: 4000,
}),
],
defaultIntegrations: false,
tracesSampleRate: 1,
});

const activeSpan = Sentry.getActiveSpan();
if (activeSpan) {
Sentry.startInactiveSpan({ name: 'pageload-child-span' });
} else {
setTimeout(() => {
Sentry.startInactiveSpan({ name: 'pageload-child-span' });
}, 200);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import {
envelopeRequestParser,
shouldSkipTracingTest,
waitForTransactionRequestOnUrl,
} from '../../../../utils/helpers';

// This tests asserts that the pageload span will finish itself after the child span timeout if it
// has a child span without adding any additional ones or finishing any of them finishing. All of the child spans that
// are still running should have the status "cancelled".
sentryTest('should send a pageload span terminated via child span timeout', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}

const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForTransactionRequestOnUrl(page, url);

const eventData = envelopeRequestParser(req);

expect(eventData.contexts?.trace?.op).toBe('pageload');
expect(eventData.spans?.length).toBeGreaterThanOrEqual(1);
const testSpan = eventData.spans?.find(span => span.description === 'pageload-child-span');
expect(testSpan).toBeDefined();
expect(testSpan?.status).toBe('cancelled');
});

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ sentryTest(
expect(eventData.measurements).toBeDefined();
expect(eventData.measurements?.lcp?.value).toBeDefined();

expect(eventData.tags?.['lcp.element']).toBe('body > img');
expect(eventData.tags?.['lcp.size']).toBe(107400);
expect(eventData.tags?.['lcp.url']).toBe('https://example.com/path/to/image.png');
expect(eventData.contexts?.trace?.data?.['lcp.element']).toBe('body > img');
expect(eventData.contexts?.trace?.data?.['lcp.size']).toBe(107400);
expect(eventData.contexts?.trace?.data?.['lcp.url']).toBe('https://example.com/path/to/image.png');

const lcp = await (await page.waitForFunction('window._LCP')).jsonValue();
const lcp2 = await (await page.waitForFunction('window._LCP2')).jsonValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sentryTest('should capture a "GOOD" CLS vital with its source(s).', async ({ get
expect(eventData.measurements?.cls?.value).toBeGreaterThan(0.03);
expect(eventData.measurements?.cls?.value).toBeLessThan(0.07);

expect(eventData.tags?.['cls.source.1']).toBe('body > div#content > p#partial');
expect(eventData.contexts?.trace?.data?.['cls.source.1']).toBe('body > div#content > p#partial');
});

sentryTest('should capture a "MEH" CLS vital with its source(s).', async ({ getLocalTestPath, page }) => {
Expand All @@ -37,7 +37,7 @@ sentryTest('should capture a "MEH" CLS vital with its source(s).', async ({ getL
expect(eventData.measurements?.cls?.value).toBeGreaterThan(0.18);
expect(eventData.measurements?.cls?.value).toBeLessThan(0.23);

expect(eventData.tags?.['cls.source.1']).toBe('body > div#content > p');
expect(eventData.contexts?.trace?.data?.['cls.source.1']).toBe('body > div#content > p');
});

sentryTest('should capture a "POOR" CLS vital with its source(s).', async ({ getLocalTestPath, page }) => {
Expand All @@ -50,5 +50,5 @@ sentryTest('should capture a "POOR" CLS vital with its source(s).', async ({ get
// Flakey value dependent on timings -> we check for a range
expect(eventData.measurements?.cls?.value).toBeGreaterThan(0.34);
expect(eventData.measurements?.cls?.value).toBeLessThan(0.36);
expect(eventData.tags?.['cls.source.1']).toBe('body > div#content > p');
expect(eventData.contexts?.trace?.data?.['cls.source.1']).toBe('body > div#content > p');
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ sentryTest('should capture a LCP vital with element details.', async ({ browserN
sentryTest.skip();
}

await page.route('**/path/to/image.png', (route: Route) =>
route.fulfill({ path: `${__dirname}/assets/sentry-logo-600x179.png` }),
);
page.route('**', route => route.continue());
page.route('**/path/to/image.png', async (route: Route) => {
return route.fulfill({ path: `${__dirname}/assets/sentry-logo-600x179.png` });
});

const url = await getLocalTestPath({ testDir: __dirname });
const [eventData] = await Promise.all([
Expand All @@ -24,7 +25,7 @@ sentryTest('should capture a LCP vital with element details.', async ({ browserN
expect(eventData.measurements).toBeDefined();
expect(eventData.measurements?.lcp?.value).toBeDefined();

expect(eventData.tags?.['lcp.element']).toBe('body > img');
expect(eventData.tags?.['lcp.size']).toBe(107400);
expect(eventData.tags?.['lcp.url']).toBe('https://example.com/path/to/image.png');
expect(eventData.contexts?.trace?.data?.['lcp.element']).toBe('body > img');
expect(eventData.contexts?.trace?.data?.['lcp.size']).toBe(107400);
expect(eventData.contexts?.trace?.data?.['lcp.url']).toBe('https://example.com/path/to/image.png');
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@sentry/node-experimental": "latest || *",
"@sentry/node": "latest || *",
"@sentry/sveltekit": "latest || *",
"@sentry/remix": "latest || *",
"@sentry/astro": "latest || *",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,52 @@
import * as SentryAstro from '@sentry/astro';
import * as SentryBun from '@sentry/bun';
import * as SentryNextJs from '@sentry/nextjs';
import * as SentryNode from '@sentry/node-experimental';
import * as SentryNode from '@sentry/node';
import * as SentryNodeExperimental from '@sentry/node-experimental';
import * as SentryRemix from '@sentry/remix';
import * as SentryServerless from '@sentry/serverless';
import * as SentrySvelteKit from '@sentry/sveltekit';

/* List of exports that are safe to ignore / we don't require in any depending package */
const NODE_EXPORTS_IGNORE = [
const NODE_EXPERIMENTAL_EXPORTS_IGNORE = [
'default',
// Probably generated by transpilation, no need to require it
'__esModule',
// These Node exports were only made for type definition fixes (see #10339)
'Undici',
// These are not re-exported where not needed
'Http',
'DebugSession',
'AnrIntegrationOptions',
'LocalVariablesIntegrationOptions',
'Undici',
];

/* List of exports that are safe to ignore / we don't require in any depending package */
const NODE_EXPORTS_IGNORE = [
'default',
// Probably generated by transpilation, no need to require it
'__esModule',
];

/* Sanitized list of node exports */
const nodeExperimentalExports = Object.keys(SentryNodeExperimental).filter(
e => !NODE_EXPERIMENTAL_EXPORTS_IGNORE.includes(e),
);
const nodeExports = Object.keys(SentryNode).filter(e => !NODE_EXPORTS_IGNORE.includes(e));

type Dependent = {
package: string;
exports: string[];
ignoreExports?: string[];
skip?: boolean;
compareWith: string[];
};

const DEPENDENTS: Dependent[] = [
{
package: '@sentry/astro',
compareWith: nodeExports,
exports: Object.keys(SentryAstro),
},
{
package: '@sentry/bun',
compareWith: nodeExperimentalExports,
exports: Object.keys(SentryBun),
ignoreExports: [
// not supported in bun:
Expand All @@ -44,35 +58,36 @@ const DEPENDENTS: Dependent[] = [
},
{
package: '@sentry/nextjs',
compareWith: nodeExperimentalExports,
// Next.js doesn't require explicit exports, so we can just merge top level and `default` exports:
// @ts-expect-error: `default` is not in the type definition but it's defined
exports: Object.keys({ ...SentryNextJs, ...SentryNextJs.default }),
},
{
package: '@sentry/remix',
compareWith: nodeExperimentalExports,
exports: Object.keys(SentryRemix),
},
{
package: '@sentry/serverless',
compareWith: nodeExperimentalExports,
exports: Object.keys(SentryServerless),
ignoreExports: ['cron', 'hapiErrorPlugin'],
},
{
package: '@sentry/sveltekit',
compareWith: nodeExperimentalExports,
exports: Object.keys(SentrySvelteKit),
},
];

/* Sanitized list of node exports */
const nodeExports = Object.keys(SentryNode).filter(e => !NODE_EXPORTS_IGNORE.includes(e));

console.log('🔎 Checking for consistent exports of @sentry/node exports in depending packages');

const missingExports: Record<string, string[]> = {};
const dependentsToCheck = DEPENDENTS.filter(d => !d.skip);

for (const nodeExport of nodeExports) {
for (const dependent of dependentsToCheck) {
for (const dependent of dependentsToCheck) {
for (const nodeExport of dependent.compareWith) {
if (dependent.ignoreExports?.includes(nodeExport)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "8.0.0-alpha.2",
"license": "MIT",
"engines": {
"node": ">=14.8"
"node": ">=14.18"
},
"private": true,
"main": "build/cjs/index.js",
Expand Down
Loading

0 comments on commit 8145fb2

Please sign in to comment.