Skip to content

Commit 2de6c89

Browse files
authored
Merge branch 'develop' into sig/browsertracing-nextjs
2 parents 71bdbcb + 0e7c492 commit 2de6c89

File tree

48 files changed

+772
-276
lines changed

Some content is hidden

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

48 files changed

+772
-276
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ jobs:
867867
'create-remix-app-express',
868868
'create-remix-app-express-legacy',
869869
'create-remix-app-express-vite-dev',
870+
'default-browser',
870871
'node-express-esm-loader',
871872
'node-express-esm-preload',
872873
'node-express-esm-without-loader',

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

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

13-
Work in this release was contributed by @MonstraG. Thank you for your contribution!
13+
Work in this release was contributed by @MonstraG and @Zen-cronic. Thank you for your contributions!
1414

1515
## 8.25.0
1616

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
/test-results/
26+
/playwright-report/
27+
/playwright/.cache/
28+
29+
!*.d.ts
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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, 'src/index.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: [
21+
new webpack.EnvironmentPlugin(['E2E_TEST_DSN']),
22+
new HtmlWebpackPlugin({
23+
template: path.join(__dirname, 'public/index.html'),
24+
}),
25+
],
26+
mode: 'production',
27+
},
28+
(err, stats) => {
29+
if (err) {
30+
console.error(err.stack || err);
31+
if (err.details) {
32+
console.error(err.details);
33+
}
34+
return;
35+
}
36+
37+
const info = stats.toJson();
38+
39+
if (stats.hasErrors()) {
40+
console.error(info.errors);
41+
process.exit(1);
42+
}
43+
44+
if (stats.hasWarnings()) {
45+
console.warn(info.warnings);
46+
process.exit(1);
47+
}
48+
},
49+
);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "default-browser-test-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@sentry/browser": "latest || *",
7+
"@types/node": "16.7.13",
8+
"typescript": "4.9.5"
9+
},
10+
"scripts": {
11+
"start": "serve -s build",
12+
"build": "node build.mjs",
13+
"test": "playwright test",
14+
"clean": "npx rimraf node_modules pnpm-lock.yaml",
15+
"test:build": "pnpm install && npx playwright install && pnpm build",
16+
"test:assert": "pnpm test"
17+
},
18+
"browserslist": {
19+
"production": [
20+
">0.2%",
21+
"not dead",
22+
"not op_mini all"
23+
],
24+
"development": [
25+
"last 1 chrome version",
26+
"last 1 firefox version",
27+
"last 1 safari version"
28+
]
29+
},
30+
"devDependencies": {
31+
"@playwright/test": "^1.44.1",
32+
"@sentry-internal/test-utils": "link:../../../test-utils",
33+
"webpack": "^5.91.0",
34+
"serve": "14.0.1",
35+
"terser-webpack-plugin": "^5.3.10",
36+
"html-webpack-plugin": "^5.6.0"
37+
},
38+
"volta": {
39+
"extends": "../../package.json"
40+
}
41+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: `pnpm start`,
5+
});
6+
7+
export default config;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Default Browser App</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
11+
<input type="button" value="Capture Exception" id="exception-button" />
12+
13+
<div id="navigation">
14+
15+
<a id="navigation-link" href="#navigation-target">Navigation Link</a>
16+
17+
<div id="navigation-target">Navigated Element</div>
18+
19+
</div>
20+
21+
<!-- The script tags for the bundled JavaScript files will be injected here by HtmlWebpackPlugin in build.mjs-->
22+
</body>
23+
</html>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
Sentry.init({
4+
dsn: process.env.E2E_TEST_DSN,
5+
integrations: [Sentry.browserTracingIntegration()],
6+
tracesSampleRate: 1.0,
7+
release: 'e2e-test',
8+
environment: 'qa',
9+
tunnel: 'http://localhost:3031',
10+
});
11+
12+
document.getElementById('exception-button').addEventListener('click', () => {
13+
throw new Error('I am an error!');
14+
});
15+
16+
document.getElementById('navigation-link').addEventListener('click', () => {
17+
document.getElementById('navigation-target').scrollIntoView({ behavior: 'smooth' });
18+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { startEventProxyServer } from '@sentry-internal/test-utils';
2+
3+
startEventProxyServer({
4+
port: 3031,
5+
proxyServerName: 'default-browser',
6+
});
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { expect, test } from '@playwright/test';
2+
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils';
3+
4+
test('captures an error', async ({ page }) => {
5+
const errorEventPromise = waitForError('default-browser', event => {
6+
return !event.type && event.exception?.values?.[0]?.value === 'I am an error!';
7+
});
8+
9+
await page.goto('/');
10+
11+
const exceptionButton = page.locator('id=exception-button');
12+
await exceptionButton.click();
13+
14+
const errorEvent = await errorEventPromise;
15+
16+
expect(errorEvent.exception?.values).toHaveLength(1);
17+
expect(errorEvent.exception?.values?.[0]?.value).toBe('I am an error!');
18+
19+
expect(errorEvent.transaction).toBe('/');
20+
21+
expect(errorEvent.request).toEqual({
22+
url: 'http://localhost:3030/',
23+
headers: expect.any(Object),
24+
});
25+
26+
expect(errorEvent.contexts?.trace).toEqual({
27+
trace_id: expect.any(String),
28+
span_id: expect.any(String),
29+
});
30+
});
31+
32+
test('sets correct transactionName', async ({ page }) => {
33+
const transactionPromise = waitForTransaction('default-browser', async transactionEvent => {
34+
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
35+
});
36+
37+
const errorEventPromise = waitForError('default-browser', event => {
38+
return !event.type && event.exception?.values?.[0]?.value === 'I am an error!';
39+
});
40+
41+
await page.goto('/');
42+
const transactionEvent = await transactionPromise;
43+
44+
const exceptionButton = page.locator('id=exception-button');
45+
await exceptionButton.click();
46+
47+
const errorEvent = await errorEventPromise;
48+
49+
expect(errorEvent.exception?.values).toHaveLength(1);
50+
expect(errorEvent.exception?.values?.[0]?.value).toBe('I am an error!');
51+
52+
expect(errorEvent.transaction).toEqual('/');
53+
54+
expect(errorEvent.contexts?.trace).toEqual({
55+
trace_id: transactionEvent.contexts?.trace?.trace_id,
56+
span_id: expect.not.stringContaining(transactionEvent.contexts?.trace?.span_id || ''),
57+
});
58+
});
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import { expect, test } from '@playwright/test';
2+
import { waitForTransaction } from '@sentry-internal/test-utils';
3+
4+
test('captures a pageload transaction', async ({ page }) => {
5+
const transactionPromise = waitForTransaction('default-browser', async transactionEvent => {
6+
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
7+
});
8+
9+
await page.goto(`/`);
10+
11+
const pageLoadTransaction = await transactionPromise;
12+
13+
expect(pageLoadTransaction).toEqual({
14+
contexts: {
15+
trace: {
16+
data: expect.objectContaining({
17+
'sentry.idle_span_finish_reason': 'idleTimeout',
18+
'sentry.op': 'pageload',
19+
'sentry.origin': 'auto.pageload.browser',
20+
'sentry.sample_rate': 1,
21+
'sentry.source': 'url',
22+
}),
23+
op: 'pageload',
24+
origin: 'auto.pageload.browser',
25+
span_id: expect.stringMatching(/[a-f0-9]{16}/),
26+
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
27+
},
28+
},
29+
environment: 'qa',
30+
event_id: expect.stringMatching(/[a-f0-9]{32}/),
31+
measurements: {
32+
'connection.rtt': {
33+
unit: 'millisecond',
34+
value: expect.any(Number),
35+
},
36+
fcp: {
37+
unit: 'millisecond',
38+
value: expect.any(Number),
39+
},
40+
fp: {
41+
unit: 'millisecond',
42+
value: expect.any(Number),
43+
},
44+
lcp: {
45+
unit: 'millisecond',
46+
value: expect.any(Number),
47+
},
48+
ttfb: {
49+
unit: 'millisecond',
50+
value: expect.any(Number),
51+
},
52+
'ttfb.requestTime': {
53+
unit: 'millisecond',
54+
value: expect.any(Number),
55+
},
56+
},
57+
platform: 'javascript',
58+
release: 'e2e-test',
59+
request: {
60+
headers: {
61+
'User-Agent': expect.any(String),
62+
},
63+
url: 'http://localhost:3030/',
64+
},
65+
sdk: {
66+
integrations: expect.any(Array),
67+
name: 'sentry.javascript.browser',
68+
packages: [
69+
{
70+
name: 'npm:@sentry/browser',
71+
version: expect.any(String),
72+
},
73+
],
74+
version: expect.any(String),
75+
},
76+
spans: expect.any(Array),
77+
start_timestamp: expect.any(Number),
78+
timestamp: expect.any(Number),
79+
transaction: '/',
80+
transaction_info: {
81+
source: 'url',
82+
},
83+
type: 'transaction',
84+
});
85+
});
86+
87+
test('captures a navigation transaction', async ({ page }) => {
88+
page.on('console', msg => console.log(msg.text()));
89+
const pageLoadTransactionPromise = waitForTransaction('default-browser', async transactionEvent => {
90+
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
91+
});
92+
93+
const navigationTransactionPromise = waitForTransaction('default-browser', async transactionEvent => {
94+
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation';
95+
});
96+
97+
await page.goto(`/`);
98+
await pageLoadTransactionPromise;
99+
100+
const linkElement = page.locator('id=navigation-link');
101+
102+
await linkElement.click();
103+
104+
const navigationTransaction = await navigationTransactionPromise;
105+
106+
expect(navigationTransaction).toMatchObject({
107+
contexts: {
108+
trace: {
109+
op: 'navigation',
110+
origin: 'auto.navigation.browser',
111+
},
112+
},
113+
transaction: '/',
114+
transaction_info: {
115+
source: 'url',
116+
},
117+
});
118+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2018",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"esModuleInterop": true,
8+
"allowSyntheticDefaultImports": true,
9+
"strict": true,
10+
"forceConsistentCasingInFileNames": true,
11+
"noFallthroughCasesInSwitch": true,
12+
"module": "esnext",
13+
"moduleResolution": "node",
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"noEmit": true,
17+
"jsx": "react"
18+
},
19+
"include": ["src", "tests"]
20+
}

0 commit comments

Comments
 (0)