Skip to content

Commit f297b78

Browse files
author
Luca Forstner
committed
Merge remote-tracking branch 'origin/develop' into lforst-nextjs-otel
2 parents ac79853 + 072422f commit f297b78

File tree

59 files changed

+788
-456
lines changed

Some content is hidden

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

59 files changed

+788
-456
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,8 @@ jobs:
10481048
# TODO(v8): Re-enable hapi tests
10491049
# 'node-hapi-app',
10501050
'node-exports-test-app',
1051-
'vue-3'
1051+
'vue-3',
1052+
'webpack-5'
10521053
]
10531054
build-command:
10541055
- false

MIGRATION.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ To make sure these integrations work properly you'll have to change how you
355355

356356
Removed top-level exports: `tracingOrigins`, `MetricsAggregator`, `metricsAggregatorIntegration`, `Severity`,
357357
`Sentry.configureScope`, `Span`, `spanStatusfromHttpCode`, `makeMain`, `lastEventId`, `pushScope`, `popScope`,
358-
`addGlobalEventProcessor`, `timestampWithMs`, `addExtensionMethods`
358+
`addGlobalEventProcessor`, `timestampWithMs`, `addExtensionMethods`, `addGlobalEventProcessor`
359359

360360
Removed `@sentry/utils` exports: `timestampWithMs`, `addOrUpdateIntegration`, `tracingContextFromHeaders`, `walk`
361361

@@ -370,6 +370,7 @@ Removed `@sentry/utils` exports: `timestampWithMs`, `addOrUpdateIntegration`, `t
370370
- [Removal of `addGlobalEventProcessor` in favour of `addEventProcessor`](./MIGRATION.md#removal-of-addglobaleventprocessor-in-favour-of-addeventprocessor)
371371
- [Removal of `lastEventId()` method](./MIGRATION.md#deprecate-lasteventid)
372372
- [Remove `void` from transport return types](./MIGRATION.md#remove-void-from-transport-return-types)
373+
- [Remove `addGlobalEventProcessor` in favor of `addEventProcessor`](./MIGRATION.md#remove-addglobaleventprocessor-in-favor-of-addeventprocessor)
373374

374375
#### Deprecation of `Hub` and `getCurrentHub()`
375376

@@ -540,7 +541,7 @@ addGlobalEventProcessor(event => {
540541

541542
```js
542543
// v8
543-
addEventProcessor(event => {
544+
Sentry.getGlobalScope().addEventProcessor(event => {
544545
delete event.extra;
545546
return event;
546547
});
@@ -569,6 +570,26 @@ interface Transport {
569570
}
570571
```
571572

573+
#### Remove `addGlobalEventProcessor` in favor of `addEventProcessor`
574+
575+
In v8, we are removing the `addGlobalEventProcessor` function in favor of `addEventProcessor`.
576+
577+
```js
578+
// v7
579+
addGlobalEventProcessor(event => {
580+
delete event.extra;
581+
return event;
582+
});
583+
```
584+
585+
```js
586+
// v8
587+
addEventProcessor(event => {
588+
delete event.extra;
589+
return event;
590+
});
591+
```
592+
572593
### Browser SDK (Browser, React, Vue, Angular, Ember, etc.)
573594

574595
Removed top-level exports: `Offline`, `makeXHRTransport`, `BrowserTracing`, `wrap`
@@ -897,7 +918,7 @@ replacement API.
897918

898919
### Ember SDK
899920

900-
Removed top-level exports: `InitSentryForEmber`
921+
Removed top-level exports: `InitSentryForEmber`, `StartTransactionFunction`
901922

902923
- [Removal of `InitSentryForEmber` export](./MIGRATION.md#removal-of-initsentryforember-export)
903924

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sentry:registry=http://127.0.0.1:4873
2+
@sentry-internal:registry=http://127.0.0.1:4873
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as path from 'path';
2+
import * as url from 'url';
3+
import HtmlWebpackPlugin from 'html-webpack-plugin';
4+
import TerserPlugin from 'terser-webpack-plugin';
5+
import webpack from 'webpack';
6+
7+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
8+
9+
webpack(
10+
{
11+
entry: path.join(__dirname, 'entry.js'),
12+
output: {
13+
path: path.join(__dirname, 'build'),
14+
filename: 'app.js',
15+
},
16+
optimization: {
17+
minimize: true,
18+
minimizer: [new TerserPlugin()],
19+
},
20+
plugins: [new HtmlWebpackPlugin(), new webpack.EnvironmentPlugin(['E2E_TEST_DSN'])],
21+
mode: 'production',
22+
},
23+
(err, stats) => {
24+
if (err) {
25+
console.error(err.stack || err);
26+
if (err.details) {
27+
console.error(err.details);
28+
}
29+
return;
30+
}
31+
32+
const info = stats.toJson();
33+
34+
if (stats.hasErrors()) {
35+
console.error(info.errors);
36+
process.exit(1);
37+
}
38+
39+
if (stats.hasWarnings()) {
40+
console.warn(info.warnings);
41+
process.exit(1);
42+
}
43+
},
44+
);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { browserTracingIntegration, captureException, init } from '@sentry/browser';
2+
3+
init({
4+
dsn: process.env.E2E_TEST_DSN,
5+
integrations: [browserTracingIntegration()],
6+
});
7+
8+
setTimeout(() => {
9+
const eventId = captureException(new Error('I am an error!'));
10+
window.capturedExceptionId = eventId;
11+
}, 2000);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "webpack-5-test",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"start": "serve -s build",
6+
"build": "node build.mjs",
7+
"test:build": "pnpm install && npx playwright install && pnpm build",
8+
"test:assert": "playwright test"
9+
},
10+
"devDependencies": {
11+
"@playwright/test": "^1.42.1",
12+
"@sentry/browser": "latest || *",
13+
"webpack": "^5.91.0",
14+
"terser-webpack-plugin": "^5.3.10",
15+
"html-webpack-plugin": "^5.6.0",
16+
"serve": "^14.2.1"
17+
}
18+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import type { PlaywrightTestConfig } from '@playwright/test';
2+
import { devices } from '@playwright/test';
3+
4+
/**
5+
* See https://playwright.dev/docs/test-configuration.
6+
*/
7+
const config: PlaywrightTestConfig = {
8+
testDir: './tests',
9+
/* Maximum time one test can run for. */
10+
timeout: 150_000,
11+
expect: {
12+
/**
13+
* Maximum time expect() should wait for the condition to be met.
14+
* For example in `await expect(locator).toHaveText();`
15+
*/
16+
timeout: 5000,
17+
},
18+
/* Run tests in files in parallel */
19+
fullyParallel: true,
20+
/* Fail the build on CI if you accidentally left test.only in the source code. */
21+
forbidOnly: !!process.env.CI,
22+
/* Retry on CI only */
23+
retries: 0,
24+
/* Opt out of parallel tests on CI. */
25+
workers: 1,
26+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
27+
reporter: 'list',
28+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
29+
use: {
30+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
31+
actionTimeout: 0,
32+
33+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
34+
trace: 'on-first-retry',
35+
},
36+
37+
/* Configure projects for major browsers */
38+
projects: [
39+
{
40+
name: 'chromium',
41+
use: {
42+
...devices['Desktop Chrome'],
43+
},
44+
},
45+
// For now we only test Chrome!
46+
// {
47+
// name: 'firefox',
48+
// use: {
49+
// ...devices['Desktop Firefox'],
50+
// },
51+
// },
52+
// {
53+
// name: 'webkit',
54+
// use: {
55+
// ...devices['Desktop Safari'],
56+
// },
57+
// },
58+
],
59+
60+
/* Run your local dev server before starting the tests */
61+
webServer: {
62+
command: 'pnpm start',
63+
port: 3030,
64+
env: {
65+
PORT: '3030',
66+
},
67+
},
68+
};
69+
70+
export default config;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { expect, test } from '@playwright/test';
2+
import axios, { AxiosError } from 'axios';
3+
4+
const EVENT_POLLING_TIMEOUT = 90_000;
5+
6+
const authToken = process.env.E2E_TEST_AUTH_TOKEN;
7+
const sentryTestOrgSlug = process.env.E2E_TEST_SENTRY_ORG_SLUG;
8+
const sentryTestProject = process.env.E2E_TEST_SENTRY_TEST_PROJECT;
9+
10+
test('Sends an exception to Sentry', async ({ page }) => {
11+
await page.goto('/');
12+
13+
const exceptionIdHandle = await page.waitForFunction(() => window.capturedExceptionId);
14+
const exceptionEventId = await exceptionIdHandle.jsonValue();
15+
16+
console.log(`Polling for error eventId: ${exceptionEventId}`);
17+
18+
await expect
19+
.poll(
20+
async () => {
21+
try {
22+
const response = await axios.get(
23+
`https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/events/${exceptionEventId}/`,
24+
{ headers: { Authorization: `Bearer ${authToken}` } },
25+
);
26+
return response.status;
27+
} catch (e) {
28+
if (e instanceof AxiosError && e.response) {
29+
if (e.response.status !== 404) {
30+
throw e;
31+
} else {
32+
return e.response.status;
33+
}
34+
} else {
35+
throw e;
36+
}
37+
}
38+
},
39+
{
40+
timeout: EVENT_POLLING_TIMEOUT,
41+
},
42+
)
43+
.toBe(200);
44+
});

dev-packages/node-integration-tests/suites/anr/basic-session.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Sentry.init({
1515
autoSessionTracking: true,
1616
});
1717

18+
Sentry.setUser({ email: '[email protected]' });
19+
Sentry.addBreadcrumb({ message: 'important message!' });
20+
1821
function longWork() {
1922
for (let i = 0; i < 20; i++) {
2023
const salt = crypto.randomBytes(128).toString('base64');

dev-packages/node-integration-tests/suites/anr/basic.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Sentry.init({
1515
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
1616
});
1717

18+
Sentry.setUser({ email: '[email protected]' });
19+
Sentry.addBreadcrumb({ message: 'important message!' });
20+
1821
function longWork() {
1922
for (let i = 0; i < 20; i++) {
2023
const salt = crypto.randomBytes(128).toString('base64');

dev-packages/node-integration-tests/suites/anr/basic.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Sentry.init({
1515
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
1616
});
1717

18+
Sentry.setUser({ email: '[email protected]' });
19+
Sentry.addBreadcrumb({ message: 'important message!' });
20+
1821
function longWork() {
1922
for (let i = 0; i < 20; i++) {
2023
const salt = crypto.randomBytes(128).toString('base64');

dev-packages/node-integration-tests/suites/anr/forked.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Sentry.init({
1515
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
1616
});
1717

18+
Sentry.setUser({ email: '[email protected]' });
19+
Sentry.addBreadcrumb({ message: 'important message!' });
20+
1821
function longWork() {
1922
for (let i = 0; i < 20; i++) {
2023
const salt = crypto.randomBytes(128).toString('base64');
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import * as assert from 'assert';
2+
import * as crypto from 'crypto';
3+
4+
import * as Sentry from '@sentry/node';
5+
6+
setTimeout(() => {
7+
process.exit();
8+
}, 10000);
9+
10+
Sentry.init({
11+
dsn: 'https://[email protected]/1337',
12+
release: '1.0',
13+
debug: true,
14+
autoSessionTracking: false,
15+
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
16+
});
17+
18+
async function longWork() {
19+
await new Promise(resolve => setTimeout(resolve, 1000));
20+
21+
for (let i = 0; i < 20; i++) {
22+
const salt = crypto.randomBytes(128).toString('base64');
23+
const hash = crypto.pbkdf2Sync('myPassword', salt, 10000, 512, 'sha512');
24+
assert.ok(hash);
25+
}
26+
}
27+
28+
function neverResolve() {
29+
return new Promise(() => {
30+
//
31+
});
32+
}
33+
34+
const fns = [
35+
neverResolve,
36+
neverResolve,
37+
neverResolve,
38+
neverResolve,
39+
neverResolve,
40+
longWork, // [5]
41+
neverResolve,
42+
neverResolve,
43+
neverResolve,
44+
neverResolve,
45+
];
46+
47+
for (let id = 0; id < 10; id++) {
48+
Sentry.withIsolationScope(async () => {
49+
Sentry.setUser({ id });
50+
51+
await fns[id]();
52+
});
53+
}

dev-packages/node-integration-tests/suites/anr/stop-and-start.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Sentry.init({
1717
integrations: [anr],
1818
});
1919

20+
Sentry.setUser({ email: '[email protected]' });
21+
Sentry.addBreadcrumb({ message: 'important message!' });
22+
2023
function longWorkIgnored() {
2124
for (let i = 0; i < 20; i++) {
2225
const salt = crypto.randomBytes(128).toString('base64');

0 commit comments

Comments
 (0)