-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into lforst-inject-tracing-metadata-twp
- Loading branch information
Showing
83 changed files
with
1,703 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
dev-packages/e2e-tests/test-applications/default-browser/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
|
||
!*.d.ts |
2 changes: 2 additions & 0 deletions
2
dev-packages/e2e-tests/test-applications/default-browser/.npmrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@sentry:registry=http://127.0.0.1:4873 | ||
@sentry-internal:registry=http://127.0.0.1:4873 |
49 changes: 49 additions & 0 deletions
49
dev-packages/e2e-tests/test-applications/default-browser/build.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as path from 'path'; | ||
import * as url from 'url'; | ||
import HtmlWebpackPlugin from 'html-webpack-plugin'; | ||
import TerserPlugin from 'terser-webpack-plugin'; | ||
import webpack from 'webpack'; | ||
|
||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); | ||
|
||
webpack( | ||
{ | ||
entry: path.join(__dirname, 'src/index.js'), | ||
output: { | ||
path: path.join(__dirname, 'build'), | ||
filename: 'app.js', | ||
}, | ||
optimization: { | ||
minimize: true, | ||
minimizer: [new TerserPlugin()], | ||
}, | ||
plugins: [ | ||
new webpack.EnvironmentPlugin(['E2E_TEST_DSN']), | ||
new HtmlWebpackPlugin({ | ||
template: path.join(__dirname, 'public/index.html'), | ||
}), | ||
], | ||
mode: 'production', | ||
}, | ||
(err, stats) => { | ||
if (err) { | ||
console.error(err.stack || err); | ||
if (err.details) { | ||
console.error(err.details); | ||
} | ||
return; | ||
} | ||
|
||
const info = stats.toJson(); | ||
|
||
if (stats.hasErrors()) { | ||
console.error(info.errors); | ||
process.exit(1); | ||
} | ||
|
||
if (stats.hasWarnings()) { | ||
console.warn(info.warnings); | ||
process.exit(1); | ||
} | ||
}, | ||
); |
41 changes: 41 additions & 0 deletions
41
dev-packages/e2e-tests/test-applications/default-browser/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "default-browser-test-app", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@sentry/browser": "latest || *", | ||
"@types/node": "16.7.13", | ||
"typescript": "4.9.5" | ||
}, | ||
"scripts": { | ||
"start": "serve -s build", | ||
"build": "node build.mjs", | ||
"test": "playwright test", | ||
"clean": "npx rimraf node_modules pnpm-lock.yaml", | ||
"test:build": "pnpm install && npx playwright install && pnpm build", | ||
"test:assert": "pnpm test" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.44.1", | ||
"@sentry-internal/test-utils": "link:../../../test-utils", | ||
"webpack": "^5.91.0", | ||
"serve": "14.0.1", | ||
"terser-webpack-plugin": "^5.3.10", | ||
"html-webpack-plugin": "^5.6.0" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
dev-packages/e2e-tests/test-applications/default-browser/playwright.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { getPlaywrightConfig } from '@sentry-internal/test-utils'; | ||
|
||
const config = getPlaywrightConfig({ | ||
startCommand: `pnpm start`, | ||
}); | ||
|
||
export default config; |
23 changes: 23 additions & 0 deletions
23
dev-packages/e2e-tests/test-applications/default-browser/public/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Default Browser App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
|
||
<input type="button" value="Capture Exception" id="exception-button" /> | ||
|
||
<div id="navigation"> | ||
|
||
<a id="navigation-link" href="#navigation-target">Navigation Link</a> | ||
|
||
<div id="navigation-target">Navigated Element</div> | ||
|
||
</div> | ||
|
||
<!-- The script tags for the bundled JavaScript files will be injected here by HtmlWebpackPlugin in build.mjs--> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
dev-packages/e2e-tests/test-applications/default-browser/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
Sentry.init({ | ||
dsn: process.env.E2E_TEST_DSN, | ||
integrations: [Sentry.browserTracingIntegration()], | ||
tracesSampleRate: 1.0, | ||
release: 'e2e-test', | ||
environment: 'qa', | ||
tunnel: 'http://localhost:3031', | ||
}); | ||
|
||
document.getElementById('exception-button').addEventListener('click', () => { | ||
throw new Error('I am an error!'); | ||
}); | ||
|
||
document.getElementById('navigation-link').addEventListener('click', () => { | ||
document.getElementById('navigation-target').scrollIntoView({ behavior: 'smooth' }); | ||
}); |
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/default-browser/start-event-proxy.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { startEventProxyServer } from '@sentry-internal/test-utils'; | ||
|
||
startEventProxyServer({ | ||
port: 3031, | ||
proxyServerName: 'default-browser', | ||
}); |
58 changes: 58 additions & 0 deletions
58
dev-packages/e2e-tests/test-applications/default-browser/tests/errors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils'; | ||
|
||
test('captures an error', async ({ page }) => { | ||
const errorEventPromise = waitForError('default-browser', event => { | ||
return !event.type && event.exception?.values?.[0]?.value === 'I am an error!'; | ||
}); | ||
|
||
await page.goto('/'); | ||
|
||
const exceptionButton = page.locator('id=exception-button'); | ||
await exceptionButton.click(); | ||
|
||
const errorEvent = await errorEventPromise; | ||
|
||
expect(errorEvent.exception?.values).toHaveLength(1); | ||
expect(errorEvent.exception?.values?.[0]?.value).toBe('I am an error!'); | ||
|
||
expect(errorEvent.transaction).toBe('/'); | ||
|
||
expect(errorEvent.request).toEqual({ | ||
url: 'http://localhost:3030/', | ||
headers: expect.any(Object), | ||
}); | ||
|
||
expect(errorEvent.contexts?.trace).toEqual({ | ||
trace_id: expect.any(String), | ||
span_id: expect.any(String), | ||
}); | ||
}); | ||
|
||
test('sets correct transactionName', async ({ page }) => { | ||
const transactionPromise = waitForTransaction('default-browser', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload'; | ||
}); | ||
|
||
const errorEventPromise = waitForError('default-browser', event => { | ||
return !event.type && event.exception?.values?.[0]?.value === 'I am an error!'; | ||
}); | ||
|
||
await page.goto('/'); | ||
const transactionEvent = await transactionPromise; | ||
|
||
const exceptionButton = page.locator('id=exception-button'); | ||
await exceptionButton.click(); | ||
|
||
const errorEvent = await errorEventPromise; | ||
|
||
expect(errorEvent.exception?.values).toHaveLength(1); | ||
expect(errorEvent.exception?.values?.[0]?.value).toBe('I am an error!'); | ||
|
||
expect(errorEvent.transaction).toEqual('/'); | ||
|
||
expect(errorEvent.contexts?.trace).toEqual({ | ||
trace_id: transactionEvent.contexts?.trace?.trace_id, | ||
span_id: expect.not.stringContaining(transactionEvent.contexts?.trace?.span_id || ''), | ||
}); | ||
}); |
Oops, something went wrong.