Astro E2E Test App
+-
+ SSR Error
+ Endpoint Error
+ Cliennt Error
+ SSR page
+ Static Page
+
diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml new file mode 100644 index 000000000000..8cb80ac7440e --- /dev/null +++ b/.github/actions/install-dependencies/action.yml @@ -0,0 +1,29 @@ +name: "Install yarn dependencies" +description: "Installs yarn dependencies and caches them." + +outputs: + cache_key: + description: "The dependency cache key" + value: ${{ steps.compute_lockfile_hash.outputs.hash }} + +runs: + using: "composite" + steps: + # we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed, + # so no need to reinstall them + - name: Compute dependency cache key + id: compute_lockfile_hash + run: echo "hash=dependencies-${{ hashFiles('yarn.lock', 'packages/*/package.json', 'dev-packages/*/package.json') }}" >> "$GITHUB_OUTPUT" + shell: bash + + - name: Check dependency cache + uses: actions/cache@v4 + id: cache_dependencies + with: + path: ${{ env.CACHED_DEPENDENCY_PATHS }} + key: ${{ steps.compute_lockfile_hash.outputs.hash }} + + - name: Install dependencies + if: steps.cache_dependencies.outputs.cache-hit != 'true' + run: yarn install --ignore-engines --frozen-lockfile + shell: bash diff --git a/.github/actions/install-playwright/action.yml b/.github/actions/install-playwright/action.yml index 7f85f5e743ba..9de6e1a2b104 100644 --- a/.github/actions/install-playwright/action.yml +++ b/.github/actions/install-playwright/action.yml @@ -13,14 +13,23 @@ runs: run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT shell: bash - - name: Cache playwright binaries - uses: actions/cache@v4 + - name: Restore cached playwright binaries + uses: actions/cache/restore@v4 id: playwright-cache with: path: | ~/.cache/ms-playwright key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + # Only store cache on develop branch + - name: Store cached playwright binaries + uses: actions/cache/save@v4 + if: github.event_name == 'push' && github.ref == 'refs/heads/develop' + with: + path: | + ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + # We always install all browsers, if uncached - name: Install Playwright dependencies (uncached) run: npx playwright install chromium webkit firefox --with-deps diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd5b7a7447ec..c66b6e64c8e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -146,22 +146,9 @@ jobs: with: node-version-file: 'package.json' - # we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed, - # so no need to reinstall them - - name: Compute dependency cache key - id: compute_lockfile_hash - run: echo "hash=${{ hashFiles('yarn.lock', '**/package.json') }}" >> "$GITHUB_OUTPUT" - - - name: Check dependency cache - uses: actions/cache@v4 - id: cache_dependencies - with: - path: ${{ env.CACHED_DEPENDENCY_PATHS }} - key: ${{ steps.compute_lockfile_hash.outputs.hash }} - - - name: Install dependencies - if: steps.cache_dependencies.outputs.cache-hit != 'true' - run: yarn install --ignore-engines --frozen-lockfile + - name: Install Dependencies + uses: ./.github/actions/install-dependencies + id: install_dependencies - name: Check for Affected Nx Projects uses: dkhunt27/action-nx-affected-list@v5.3 @@ -200,7 +187,7 @@ jobs: run: yarn build outputs: - dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }} + dependency_cache_key: ${{ steps.install_dependencies.outputs.cache_key }} changed_node_integration: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry-internal/node-integration-tests') }} changed_remix: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry/remix') }} changed_node: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry/node') }} @@ -293,22 +280,9 @@ jobs: with: node-version-file: 'package.json' - # we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed, - # so no need to reinstall them - - name: Compute dependency cache key - id: compute_lockfile_hash - run: echo "hash=${{ hashFiles('yarn.lock', '**/package.json') }}" >> "$GITHUB_OUTPUT" - - - name: Check dependency cache - uses: actions/cache@v4 - id: cache_dependencies - with: - path: ${{ env.CACHED_DEPENDENCY_PATHS }} - key: ${{ steps.compute_lockfile_hash.outputs.hash }} - - - name: Install dependencies - if: steps.cache_dependencies.outputs.cache-hit != 'true' - run: yarn install --ignore-engines --frozen-lockfile + - name: Install Dependencies + uses: ./.github/actions/install-dependencies + id: install_dependencies - name: Check file formatting run: yarn lint:prettier && yarn lint:biome @@ -480,7 +454,8 @@ jobs: strategy: fail-fast: false matrix: - node: [14, 16, 18, 20, 22] + # TODO(lforst): Unpin Node.js version 22 when https://github.com/protobufjs/protobuf.js/issues/2025 is resolved which broke the nodejs tests + node: [14, 16, 18, 20, '22.6.0'] steps: - name: Check out base commit (${{ github.event.pull_request.base.sha }}) uses: actions/checkout@v4 @@ -873,6 +848,7 @@ jobs: [ 'angular-17', 'angular-18', + 'astro-4', 'aws-lambda-layer-cjs', 'aws-serverless-esm', 'node-express', @@ -977,6 +953,7 @@ jobs: with: path: ${{ github.workspace }}/packages/*/*.tgz key: ${{ env.BUILD_CACHE_TARBALL_KEY }} + fail-on-cache-miss: true - name: Install Playwright uses: ./.github/actions/install-playwright @@ -1076,6 +1053,7 @@ jobs: with: path: ${{ github.workspace }}/packages/*/*.tgz key: ${{ env.BUILD_CACHE_TARBALL_KEY }} + fail-on-cache-miss: true - name: Install Playwright uses: ./.github/actions/install-playwright @@ -1446,6 +1424,7 @@ jobs: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} enableCrossOsArchive: true + fail-on-cache-miss: true - name: Restore build cache uses: actions/cache/restore@v4 @@ -1454,6 +1433,7 @@ jobs: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} enableCrossOsArchive: true + fail-on-cache-miss: true - name: Configure safe directory run: | diff --git a/.github/workflows/cleanup-pr-caches.yml b/.github/workflows/cleanup-pr-caches.yml new file mode 100644 index 000000000000..5ebd0b7aad9d --- /dev/null +++ b/.github/workflows/cleanup-pr-caches.yml @@ -0,0 +1,38 @@ +name: "Automation: Cleanup PR caches" +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + permissions: + # `actions:write` permission is required to delete caches + # See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id + actions: write + contents: read + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge + + echo "Fetching list of cache key" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.vscode/settings.json b/.vscode/settings.json index 615ca5b24472..4926554ffe4b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,5 +42,5 @@ "[typescript]": { "editor.defaultFormatter": "biomejs.biome" }, - "cSpell.words": ["arrayify"] + "cSpell.words": ["arrayify", "OTEL"] } diff --git a/CHANGELOG.md b/CHANGELOG.md index be7298ed213a..6c187aebffe3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,27 @@ - "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott +## 8.27.0 + +### Important Changes + +- **fix(nestjs): Exception filters in main app module are not being executed (#13278)** + + With this release nestjs error monitoring is no longer automatically set up after adding the `SentryModule` to your + application, which led to issues in certain scenarios. You will now have to either add the `SentryGlobalFilter` to + your main module providers or decorate the `catch()` method in your existing global exception filters with the newly + released `@WithSentry()` decorator. See the [docs](https://docs.sentry.io/platforms/javascript/guides/nestjs/) for + more details. + +### Other Changes + +- feat: Add options for passing nonces to feedback integration (#13347) +- feat: Add support for SENTRY_SPOTLIGHT env var in Node (#13325) +- feat(deps): bump @prisma/instrumentation from 5.17.0 to 5.18.0 (#13327) +- fix(deno): Don't rely on `Deno.permissions.querySync` (#13378) + +Work in this release was contributed by @charpeni. Thank you for your contribution! + ## 8.26.0 ### Important Changes diff --git a/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/sdkLoadedInMeanwhile/test.ts b/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/sdkLoadedInMeanwhile/test.ts index 44eca49888be..62456093a9a6 100644 --- a/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/sdkLoadedInMeanwhile/test.ts +++ b/dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/sdkLoadedInMeanwhile/test.ts @@ -1,5 +1,5 @@ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; import { expect } from '@playwright/test'; import { TEST_HOST, sentryTest } from '../../../../utils/fixtures'; @@ -28,6 +28,8 @@ sentryTest('it does not download the SDK if the SDK was loaded in the meanwhile' }); }); + const tmpDir = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true }); + await page.route(`${TEST_HOST}/*.*`, route => { const file = route.request().url().split('/').pop(); @@ -35,12 +37,13 @@ sentryTest('it does not download the SDK if the SDK was loaded in the meanwhile' cdnLoadedCount++; } - const filePath = path.resolve(__dirname, `./dist/${file}`); + const filePath = path.resolve(tmpDir, `./${file}`); return fs.existsSync(filePath) ? route.fulfill({ path: filePath }) : route.continue(); }); - const url = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true }); + const url = `${TEST_HOST}/index.html`; + const req = await waitForErrorRequestOnUrl(page, url); const eventData = envelopeRequestParser(req); diff --git a/dev-packages/browser-integration-tests/playwright.config.ts b/dev-packages/browser-integration-tests/playwright.config.ts index b03f758e11dc..45a548311eef 100644 --- a/dev-packages/browser-integration-tests/playwright.config.ts +++ b/dev-packages/browser-integration-tests/playwright.config.ts @@ -31,6 +31,7 @@ const config: PlaywrightTestConfig = { ], globalSetup: require.resolve('./playwright.setup.ts'), + globalTeardown: require.resolve('./playwright.teardown.ts'), }; export default config; diff --git a/dev-packages/browser-integration-tests/playwright.teardown.ts b/dev-packages/browser-integration-tests/playwright.teardown.ts new file mode 100644 index 000000000000..3afbf63f0aa1 --- /dev/null +++ b/dev-packages/browser-integration-tests/playwright.teardown.ts @@ -0,0 +1,5 @@ +import * as childProcess from 'child_process'; + +export default function globalTeardown(): void { + childProcess.execSync('yarn clean', { stdio: 'inherit', cwd: process.cwd() }); +} diff --git a/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/init.js b/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/init.js new file mode 100644 index 000000000000..067dbec23fd4 --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/init.js @@ -0,0 +1,19 @@ +import * as Sentry from '@sentry/browser'; +// Import this separately so that generatePlugin can handle it for CDN scenarios +import { feedbackIntegration } from '@sentry/browser'; + +window.Sentry = Sentry; + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + integrations: [ + feedbackIntegration({ tags: { from: 'integration init' }, styleNonce: 'foo1234', scriptNonce: 'foo1234' }), + ], +}); + +document.addEventListener('securitypolicyviolation', () => { + const container = document.querySelector('#csp-violation'); + if (container) { + container.innerText = 'CSP Violation'; + } +}); diff --git a/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/template.html b/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/template.html new file mode 100644 index 000000000000..919f372ef468 --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/template.html @@ -0,0 +1,13 @@ + + +
+ + + + + + + diff --git a/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/test.ts b/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/test.ts new file mode 100644 index 000000000000..95a8a2eacee8 --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/test.ts @@ -0,0 +1,84 @@ +import { expect } from '@playwright/test'; + +import { TEST_HOST, sentryTest } from '../../../utils/fixtures'; +import { envelopeRequestParser, getEnvelopeType, shouldSkipFeedbackTest } from '../../../utils/helpers'; + +sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => { + if (shouldSkipFeedbackTest()) { + sentryTest.skip(); + } + + const feedbackRequestPromise = page.waitForResponse(res => { + const req = res.request(); + + const postData = req.postData(); + if (!postData) { + return false; + } + + try { + return getEnvelopeType(req) === 'feedback'; + } catch (err) { + return false; + } + }); + + 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 }); + + await page.goto(url); + await page.getByText('Report a Bug').click(); + expect(await page.locator(':visible:text-is("Report a Bug")').count()).toEqual(1); + await page.locator('[name="name"]').fill('Jane Doe'); + await page.locator('[name="email"]').fill('janedoe@example.org'); + await page.locator('[name="message"]').fill('my example feedback'); + await page.locator('[data-sentry-feedback] .btn--primary').click(); + + const feedbackEvent = envelopeRequestParser((await feedbackRequestPromise).request()); + expect(feedbackEvent).toEqual({ + type: 'feedback', + breadcrumbs: expect.any(Array), + contexts: { + feedback: { + contact_email: 'janedoe@example.org', + message: 'my example feedback', + name: 'Jane Doe', + source: 'widget', + url: `${TEST_HOST}/index.html`, + }, + trace: { + trace_id: expect.stringMatching(/\w{32}/), + span_id: expect.stringMatching(/\w{16}/), + }, + }, + level: 'info', + tags: { + from: 'integration init', + }, + timestamp: expect.any(Number), + event_id: expect.stringMatching(/\w{32}/), + environment: 'production', + sdk: { + integrations: expect.arrayContaining(['Feedback']), + version: expect.any(String), + name: 'sentry.javascript.browser', + packages: expect.anything(), + }, + request: { + url: `${TEST_HOST}/index.html`, + headers: { + 'User-Agent': expect.stringContaining(''), + }, + }, + platform: 'javascript', + }); + const cspContainer = await page.locator('#csp-violation'); + expect(cspContainer).not.toContainText('CSP Violation'); +}); diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/subject.js b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/subject.js index f6e1e21e4611..1cbadc6e36e6 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/subject.js @@ -1,3 +1,3 @@ -fetch('http://localhost:7654/foo').then(() => { +fetch('http://sentry-test.io/foo').then(() => { Sentry.captureException('test error'); }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/test.ts b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/test.ts index f4e173940bc4..9ecf29c31014 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/test.ts @@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for basic GET request', async ({ getLocalTestUrl data: { method: 'GET', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/subject.js b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/subject.js index 0ca20f1b5acb..2c014f821a43 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/subject.js @@ -1,3 +1,3 @@ -fetch(new Request('http://localhost:7654/foo')).then(() => { +fetch(new Request('http://sentry-test.io/foo')).then(() => { Sentry.captureException('test error'); }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/test.ts b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/test.ts index 3ffa68776fd2..8d545ea6f566 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/test.ts @@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for basic GET request that uses request object', data: { method: 'GET', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/subject.js b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/subject.js index ea1bf44bc905..e1545e8060c6 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/subject.js @@ -1,4 +1,4 @@ -fetch('http://localhost:7654/foo', { +fetch('http://sentry-test.io/foo', { method: 'POST', body: '{"my":"body"}', headers: { diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/test.ts b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/test.ts index 9267c1099bfd..fd27c71e6ad7 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/test.ts @@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for POST request', async ({ getLocalTestUrl, pag data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js index f95bcb45c166..8202bb03803b 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js @@ -1,6 +1,6 @@ const xhr = new XMLHttpRequest(); -xhr.open('GET', 'http://localhost:7654/foo'); +xhr.open('GET', 'http://sentry-test.io/foo'); xhr.send(); xhr.addEventListener('readystatechange', function () { diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/test.ts b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/test.ts index 858392b38444..9c4b14e89033 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/test.ts @@ -32,7 +32,7 @@ sentryTest('captures Breadcrumb for basic GET request', async ({ getLocalTestUrl data: { method: 'GET', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/subject.js b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/subject.js index f8779b681d58..888d961ae9c5 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/subject.js @@ -1,6 +1,6 @@ const xhr = new XMLHttpRequest(); -xhr.open('POST', 'http://localhost:7654/foo'); +xhr.open('POST', 'http://sentry-test.io/foo'); xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.send('{"my":"body"}'); diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/test.ts b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/test.ts index 8df0e468a12b..985e7e316244 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/test.ts @@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for POST request', async ({ getLocalTestUrl, pag data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/axios/subject.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/axios/subject.js index 5cac9d385e15..1e881c5f7181 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/axios/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/axios/subject.js @@ -1,7 +1,7 @@ import axios from 'axios'; axios - .get('http://localhost:7654/foo', { + .get('http://sentry-test.io/foo', { headers: { Accept: 'application/json', 'Content-Type': 'application/json', Cache: 'no-cache' }, }) .then(response => { diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/axios/test.ts b/dev-packages/browser-integration-tests/suites/integrations/httpclient/axios/test.ts index 3560a2598160..6318b337c165 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/axios/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/axios/test.ts @@ -44,7 +44,7 @@ sentryTest( ], }, request: { - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', method: 'GET', headers: { accept: 'application/json', diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/subject.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/subject.js index 94ab60d92ed9..93da60f0e2e6 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/subject.js @@ -1,4 +1,4 @@ -fetch('http://localhost:7654/foo', { +fetch('http://sentry-test.io/foo', { method: 'GET', credentials: 'include', headers: { diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/test.ts b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/test.ts index bc56277c0f71..6cf8d7c7187f 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/test.ts @@ -46,7 +46,7 @@ sentryTest( ], }, request: { - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', method: 'GET', headers: { accept: 'application/json', diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withAbortController/subject.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withAbortController/subject.js index 78028b473ad7..6cb0fe3156fe 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withAbortController/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withAbortController/subject.js @@ -10,7 +10,7 @@ const startFetch = e => { forceTransaction: true, }, async () => { - await fetch('http://localhost:7654/foo', { signal }) + await fetch('http://sentry-test.io/foo', { signal }) .then(response => response.json()) .then(data => { console.log('Fetch succeeded:', data); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/subject.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/subject.js index 07b538291b73..af5a031c9a61 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/subject.js @@ -1,4 +1,4 @@ -const request = new Request('http://localhost:7654/foo', { +const request = new Request('http://sentry-test.io/foo', { method: 'POST', credentials: 'include', headers: { diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/test.ts b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/test.ts index 3caa6bd19652..e2dcd308417a 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/test.ts @@ -42,7 +42,7 @@ sentryTest('works with a Request passed in', async ({ getLocalTestPath, page }) ], }, request: { - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', method: 'POST', headers: { accept: 'application/json', diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/subject.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/subject.js index 4659addc56d2..7972dd9eb291 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/subject.js @@ -1,4 +1,4 @@ -const request = new Request('http://localhost:7654/foo', { +const request = new Request('http://sentry-test.io/foo', { method: 'POST', credentials: 'include', headers: { diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/test.ts b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/test.ts index 1ae88e8c5f5b..98519cd32129 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/test.ts @@ -44,7 +44,7 @@ sentryTest( ], }, request: { - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', method: 'POST', headers: { accept: 'application/json', diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/subject.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/subject.js index 96e3194dcfe2..8c2f763d2352 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/subject.js @@ -1,4 +1,4 @@ -const request = new Request('http://localhost:7654/foo', { +const request = new Request('http://sentry-test.io/foo', { method: 'POST', credentials: 'include', headers: { diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/test.ts b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/test.ts index 9840f91ba272..4d3fe8458bac 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/test.ts @@ -42,7 +42,7 @@ sentryTest('works with a Request (without body) & options passed in', async ({ g ], }, request: { - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', method: 'POST', headers: { accept: 'application/json', diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/subject.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/subject.js index 7a2e3cdd28c0..563b069e66cc 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/subject.js @@ -1,6 +1,6 @@ const xhr = new XMLHttpRequest(); -xhr.open('GET', 'http://localhost:7654/foo', true); +xhr.open('GET', 'http://sentry-test.io/foo', true); xhr.withCredentials = true; xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json'); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/test.ts b/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/test.ts index 8bf8efa34cc4..f064a8652b48 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/httpClientIntegration/test.ts @@ -42,7 +42,7 @@ sentryTest('works with httpClientIntegration', async ({ getLocalTestPath, page } ], }, request: { - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', method: 'GET', headers: { accept: 'application/json', diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/xhr/subject.js b/dev-packages/browser-integration-tests/suites/integrations/httpclient/xhr/subject.js index 7a2e3cdd28c0..563b069e66cc 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/xhr/subject.js +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/xhr/subject.js @@ -1,6 +1,6 @@ const xhr = new XMLHttpRequest(); -xhr.open('GET', 'http://localhost:7654/foo', true); +xhr.open('GET', 'http://sentry-test.io/foo', true); xhr.withCredentials = true; xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json'); diff --git a/dev-packages/browser-integration-tests/suites/integrations/httpclient/xhr/test.ts b/dev-packages/browser-integration-tests/suites/integrations/httpclient/xhr/test.ts index a3283be9cc00..6595fc0a7399 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/httpclient/xhr/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/httpclient/xhr/test.ts @@ -44,7 +44,7 @@ sentryTest( ], }, request: { - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', method: 'GET', headers: { accept: 'application/json', diff --git a/dev-packages/browser-integration-tests/suites/public-api/init/built-pkg/test.ts b/dev-packages/browser-integration-tests/suites/public-api/init/built-pkg/test.ts index 82b08fad52b6..a33a138927f5 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/init/built-pkg/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/init/built-pkg/test.ts @@ -6,14 +6,14 @@ import { expect } from '@playwright/test'; import { sentryTest } from '../../../../utils/fixtures'; // Regression test against https://github.com/getsentry/sentry-javascript/pull/1896 -sentryTest('should not contain tslib_1__default', async ({ getLocalTestPath }) => { - await getLocalTestPath({ testDir: __dirname }); +sentryTest('should not contain tslib_1__default', async ({ getLocalTestUrl }) => { + const tmpDir = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true }); - const initBundle = fs.readFileSync(path.join(__dirname, 'dist', 'init.bundle.js'), 'utf-8'); + const initBundle = fs.readFileSync(path.join(tmpDir, 'init.bundle.js'), 'utf-8'); expect(initBundle.length).toBeGreaterThan(0); expect(initBundle).not.toContain('tslib_1__default'); - const subjectBundle = fs.readFileSync(path.join(__dirname, 'dist', 'subject.bundle.js'), 'utf-8'); + const subjectBundle = fs.readFileSync(path.join(tmpDir, 'subject.bundle.js'), 'utf-8'); expect(subjectBundle.length).toBeGreaterThan(0); expect(subjectBundle).not.toContain('tslib_1__default'); }); diff --git a/dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts b/dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts index 0b1e056123e8..b2a7fa6dc3ac 100644 --- a/dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts @@ -34,7 +34,7 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT timestamp: expect.any(Number), error_ids: [], trace_ids: [], - urls: [expect.stringContaining('/dist/index.html')], + urls: [expect.stringMatching(/\/dist\/([\w-]+)\/index\.html$/)], replay_id: expect.stringMatching(/\w{32}/), replay_start_timestamp: expect.any(Number), segment_id: 0, @@ -57,7 +57,7 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT name: 'sentry.javascript.browser', }, request: { - url: expect.stringContaining('/dist/index.html'), + url: expect.stringMatching(/\/dist\/([\w-]+)\/index\.html$/), headers: { 'User-Agent': expect.stringContaining(''), }, @@ -94,7 +94,7 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT name: 'sentry.javascript.browser', }, request: { - url: expect.stringContaining('/dist/index.html'), + url: expect.stringMatching(/\/dist\/([\w-]+)\/index\.html$/), headers: { 'User-Agent': expect.stringContaining(''), }, diff --git a/dev-packages/browser-integration-tests/suites/replay/captureReplayFromReplayPackage/test.ts b/dev-packages/browser-integration-tests/suites/replay/captureReplayFromReplayPackage/test.ts index 58260c4c577f..6267413ff84e 100644 --- a/dev-packages/browser-integration-tests/suites/replay/captureReplayFromReplayPackage/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/captureReplayFromReplayPackage/test.ts @@ -34,7 +34,7 @@ sentryTest('should capture replays (@sentry-internal/replay export)', async ({ g timestamp: expect.any(Number), error_ids: [], trace_ids: [], - urls: [expect.stringContaining('/dist/index.html')], + urls: [expect.stringMatching(/\/dist\/([\w-]+)\/index\.html$/)], replay_id: expect.stringMatching(/\w{32}/), replay_start_timestamp: expect.any(Number), segment_id: 0, @@ -57,7 +57,7 @@ sentryTest('should capture replays (@sentry-internal/replay export)', async ({ g name: 'sentry.javascript.browser', }, request: { - url: expect.stringContaining('/dist/index.html'), + url: expect.stringMatching(/\/dist\/([\w-]+)\/index\.html$/), headers: { 'User-Agent': expect.stringContaining(''), }, @@ -94,7 +94,7 @@ sentryTest('should capture replays (@sentry-internal/replay export)', async ({ g name: 'sentry.javascript.browser', }, request: { - url: expect.stringContaining('/dist/index.html'), + url: expect.stringMatching(/\/dist\/([\w-]+)\/index\.html$/), headers: { 'User-Agent': expect.stringContaining(''), }, diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestBody/init.js b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestBody/init.js index c43d5713f173..9db232f536cd 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestBody/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestBody/init.js @@ -6,7 +6,7 @@ window.Replay = Sentry.replayIntegration({ flushMaxDelay: 200, minReplayDuration: 0, - networkDetailAllowUrls: ['http://localhost:7654/foo', 'http://sentry-test.io/foo'], + networkDetailAllowUrls: ['http://sentry-test.io/foo'], networkCaptureBodies: true, }); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestBody/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestBody/test.ts index bd8050b740aa..f8b48ffec598 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestBody/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestBody/test.ts @@ -8,14 +8,14 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures text request body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures text request body', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -34,19 +34,17 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', body: 'input body', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -63,7 +61,7 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse method: 'POST', request_body_size: 10, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -80,7 +78,7 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse }, response: additionalHeaders ? { headers: additionalHeaders } : undefined, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -88,14 +86,14 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse ]); }); -sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures JSON request body', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -114,19 +112,17 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', body: '{"foo":"bar"}', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -143,7 +139,7 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse method: 'POST', request_body_size: 13, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -160,7 +156,7 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse }, response: additionalHeaders ? { headers: additionalHeaders } : undefined, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -168,14 +164,14 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse ]); }); -sentryTest('captures non-text request body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures non-text request body', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -194,7 +190,7 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { @@ -202,15 +198,13 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br body.append('name', 'Anne'); body.append('age', '32'); - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', body: body, }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -227,7 +221,7 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br method: 'POST', request_body_size: 16, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -244,7 +238,7 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br }, response: additionalHeaders ? { headers: additionalHeaders } : undefined, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -259,7 +253,7 @@ sentryTest('captures text request body when matching relative URL', async ({ get const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -282,7 +276,6 @@ sentryTest('captures text request body when matching relative URL', async ({ get await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ fetch('/foo', { method: 'POST', body: 'input body', @@ -290,7 +283,6 @@ sentryTest('captures text request body when matching relative URL', async ({ get // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -332,12 +324,12 @@ sentryTest('captures text request body when matching relative URL', async ({ get ]); }); -sentryTest('does not capture request body when URL does not match', async ({ getLocalTestPath, page }) => { +sentryTest('does not capture request body when URL does not match', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } - await page.route('**/bar', route => { + await page.route('http://sentry-test.io/bar', route => { return route.fulfill({ status: 200, }); @@ -356,19 +348,17 @@ sentryTest('does not capture request body when URL does not match', async ({ get return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/bar', { + fetch('http://sentry-test.io/bar', { method: 'POST', body: 'input body', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -385,7 +375,7 @@ sentryTest('does not capture request body when URL does not match', async ({ get method: 'POST', request_body_size: 10, status_code: 200, - url: 'http://localhost:7654/bar', + url: 'http://sentry-test.io/bar', }, }); @@ -409,7 +399,7 @@ sentryTest('does not capture request body when URL does not match', async ({ get }, }, }, - description: 'http://localhost:7654/bar', + description: 'http://sentry-test.io/bar', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/init.js b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/init.js index 8e8006759bee..5a97a87c2571 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/init.js @@ -6,7 +6,7 @@ window.Replay = Sentry.replayIntegration({ flushMaxDelay: 200, minReplayDuration: 0, - networkDetailAllowUrls: ['http://localhost:7654/foo'], + networkDetailAllowUrls: ['http://sentry-test.io/foo'], networkRequestHeaders: ['X-Test-Header'], }); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/test.ts index 19e85e8b03db..f1952da08f0a 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/test.ts @@ -8,14 +8,14 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('handles empty/missing request headers', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('handles empty/missing request headers', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -32,19 +32,17 @@ sentryTest('handles empty/missing request headers', async ({ getLocalTestPath, p return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request, { replayRecordingSnapshots }] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, replayRequestPromise, @@ -62,7 +60,7 @@ sentryTest('handles empty/missing request headers', async ({ getLocalTestPath, p data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -73,7 +71,7 @@ sentryTest('handles empty/missing request headers', async ({ getLocalTestPath, p statusCode: 200, response: additionalHeaders ? { headers: additionalHeaders } : undefined, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -81,14 +79,14 @@ sentryTest('handles empty/missing request headers', async ({ getLocalTestPath, p ]); }); -sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures request headers as POJO', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -107,13 +105,12 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page, return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request, { replayRecordingSnapshots }] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', headers: { Accept: 'application/json', @@ -126,7 +123,6 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page, // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, replayRequestPromise, @@ -144,7 +140,7 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page, data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -162,7 +158,7 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page, }, response: additionalHeaders ? { headers: additionalHeaders } : undefined, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -170,14 +166,14 @@ sentryTest('captures request headers as POJO', async ({ getLocalTestPath, page, ]); }); -sentryTest('captures request headers on Request', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures request headers on Request', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -194,12 +190,12 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request, { replayRecordingSnapshots }] = await Promise.all([ page.evaluate(() => { - const request = new Request('http://localhost:7654/foo', { + const request = new Request('http://sentry-test.io/foo', { method: 'POST', headers: { Accept: 'application/json', @@ -208,12 +204,11 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag 'X-Custom-Header': 'foo', }, }); - /* eslint-disable */ + fetch(request).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, replayRequestPromise, @@ -231,7 +226,7 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -248,7 +243,7 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag }, response: additionalHeaders ? { headers: additionalHeaders } : undefined, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -256,14 +251,14 @@ sentryTest('captures request headers on Request', async ({ getLocalTestPath, pag ]); }); -sentryTest('captures request headers as Headers instance', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures request headers as Headers instance', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -280,7 +275,7 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); @@ -292,15 +287,13 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest headers.append('Cache', 'no-cache'); headers.append('X-Custom-Header', 'foo'); - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', headers, }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, replayRequestPromise, @@ -318,7 +311,7 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -335,7 +328,7 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest }, response: additionalHeaders ? { headers: additionalHeaders } : undefined, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -343,12 +336,12 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest ]); }); -sentryTest('does not captures request headers if URL does not match', async ({ getLocalTestPath, page }) => { +sentryTest('does not captures request headers if URL does not match', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } - await page.route('**/bar', route => { + await page.route('http://sentry-test.io/bar', route => { return route.fulfill({ status: 200, }); @@ -367,13 +360,12 @@ sentryTest('does not captures request headers if URL does not match', async ({ g return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request, { replayRecordingSnapshots }] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/bar', { + fetch('http://sentry-test.io/bar', { method: 'POST', headers: { Accept: 'application/json', @@ -386,7 +378,6 @@ sentryTest('does not captures request headers if URL does not match', async ({ g // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, replayRequestPromise, @@ -404,7 +395,7 @@ sentryTest('does not captures request headers if URL does not match', async ({ g data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/bar', + url: 'http://sentry-test.io/bar', }, }); @@ -426,7 +417,7 @@ sentryTest('does not captures request headers if URL does not match', async ({ g }, }, }, - description: 'http://localhost:7654/bar', + description: 'http://sentry-test.io/bar', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestSize/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestSize/test.ts index dafa896f2cbd..4da3c7142996 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestSize/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestSize/test.ts @@ -8,12 +8,12 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures request body size when body is sent', async ({ getLocalTestPath, page }) => { +sentryTest('captures request body size when body is sent', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -32,20 +32,18 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request, { replayRecordingSnapshots }] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', body: '{"foo":"bar"}', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, replayRequestPromise, @@ -64,7 +62,7 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest method: 'POST', request_body_size: 13, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -87,7 +85,7 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -95,7 +93,7 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest ]); }); -sentryTest('captures request size from non-text request body', async ({ getLocalTestPath, page }) => { +sentryTest('captures request size from non-text request body', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } @@ -119,22 +117,20 @@ sentryTest('captures request size from non-text request body', async ({ getLocal return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request, { replayRecordingSnapshots }] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ const blob = new Blob(['Hello world!!'], { type: 'text/html' }); - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', body: blob, }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, replayRequestPromise, @@ -153,7 +149,7 @@ sentryTest('captures request size from non-text request body', async ({ getLocal method: 'POST', request_body_size: 26, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -176,7 +172,7 @@ sentryTest('captures request size from non-text request body', async ({ getLocal }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseBody/init.js b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseBody/init.js index f2eb62b8c051..9db232f536cd 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseBody/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseBody/init.js @@ -6,7 +6,7 @@ window.Replay = Sentry.replayIntegration({ flushMaxDelay: 200, minReplayDuration: 0, - networkDetailAllowUrls: ['http://localhost:7654/foo'], + networkDetailAllowUrls: ['http://sentry-test.io/foo'], networkCaptureBodies: true, }); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseBody/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseBody/test.ts index 5e58b63218ef..7ce8ecb87748 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseBody/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseBody/test.ts @@ -8,14 +8,14 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures text response body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures text response body', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: 'response body', @@ -35,18 +35,16 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -63,7 +61,7 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows method: 'POST', response_body_size: 13, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -82,7 +80,7 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows body: 'response body', }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -90,14 +88,14 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows ]); }); -sentryTest('captures JSON response body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures JSON response body', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: JSON.stringify({ res: 'this' }), @@ -117,18 +115,16 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -145,7 +141,7 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows method: 'POST', response_body_size: 14, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -164,7 +160,7 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows body: { res: 'this' }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -172,14 +168,14 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows ]); }); -sentryTest('captures non-text response body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures non-text response body', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'application/octet-stream' } : {}; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: Buffer.from('Hello world'), @@ -199,18 +195,16 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -227,7 +221,7 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b method: 'POST', response_body_size: 24, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -246,7 +240,7 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b body: 'Hello world', }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -256,12 +250,12 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b // This test is flaky // See: https://github.com/getsentry/sentry-javascript/issues/11136 -sentryTest.skip('does not capture response body when URL does not match', async ({ getLocalTestPath, page }) => { +sentryTest.skip('does not capture response body when URL does not match', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } - await page.route('**/bar', route => { + await page.route('http://sentry-test.io/bar', route => { return route.fulfill({ status: 200, body: 'response body', @@ -281,18 +275,16 @@ sentryTest.skip('does not capture response body when URL does not match', async return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/bar', { + fetch('http://sentry-test.io/bar', { method: 'POST', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; @@ -309,7 +301,7 @@ sentryTest.skip('does not capture response body when URL does not match', async method: 'POST', response_body_size: 13, status_code: 200, - url: 'http://localhost:7654/bar', + url: 'http://sentry-test.io/bar', }, }); @@ -333,7 +325,7 @@ sentryTest.skip('does not capture response body when URL does not match', async }, }, }, - description: 'http://localhost:7654/bar', + description: 'http://sentry-test.io/bar', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseHeaders/init.js b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseHeaders/init.js index a2a7a1680123..82bc5a045870 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseHeaders/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseHeaders/init.js @@ -6,7 +6,7 @@ window.Replay = Sentry.replayIntegration({ flushMaxDelay: 200, minReplayDuration: 0, - networkDetailAllowUrls: ['http://localhost:7654/foo'], + networkDetailAllowUrls: ['http://sentry-test.io/foo'], networkResponseHeaders: ['X-Test-Header'], }); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseHeaders/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseHeaders/test.ts index 8486cf541a18..ec4a26dd199f 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseHeaders/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseHeaders/test.ts @@ -8,14 +8,14 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('handles empty headers', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('handles empty headers', async ({ getLocalTestUrl, page, browserName }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } const additionalHeaders = browserName === 'webkit' ? { 'content-type': 'text/plain' } : undefined; - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -34,12 +34,12 @@ sentryTest('handles empty headers', async ({ getLocalTestPath, page, browserName return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request] = await Promise.all([ page.evaluate(() => { - fetch('http://localhost:7654/foo').then(() => { + fetch('http://sentry-test.io/foo').then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); @@ -59,7 +59,7 @@ sentryTest('handles empty headers', async ({ getLocalTestPath, page, browserName data: { method: 'GET', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -71,7 +71,7 @@ sentryTest('handles empty headers', async ({ getLocalTestPath, page, browserName statusCode: 200, response: additionalHeaders ? { headers: additionalHeaders } : undefined, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -79,12 +79,12 @@ sentryTest('handles empty headers', async ({ getLocalTestPath, page, browserName ]); }); -sentryTest('captures response headers', async ({ getLocalTestPath, page }) => { +sentryTest('captures response headers', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, headers: { @@ -110,12 +110,12 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page }) => { return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request] = await Promise.all([ page.evaluate(() => { - fetch('http://localhost:7654/foo').then(() => { + fetch('http://sentry-test.io/foo').then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); @@ -135,7 +135,7 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page }) => { data: { method: 'GET', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -153,7 +153,7 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page }) => { }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -161,12 +161,12 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page }) => { ]); }); -sentryTest('does not capture response headers if URL does not match', async ({ getLocalTestPath, page }) => { +sentryTest('does not capture response headers if URL does not match', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } - await page.route('**/bar', route => { + await page.route('http://sentry-test.io/bar', route => { return route.fulfill({ status: 200, headers: { @@ -192,12 +192,12 @@ sentryTest('does not capture response headers if URL does not match', async ({ g return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request] = await Promise.all([ page.evaluate(() => { - fetch('http://localhost:7654/bar').then(() => { + fetch('http://sentry-test.io/bar').then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); @@ -217,7 +217,7 @@ sentryTest('does not capture response headers if URL does not match', async ({ g data: { method: 'GET', status_code: 200, - url: 'http://localhost:7654/bar', + url: 'http://sentry-test.io/bar', }, }); @@ -236,7 +236,7 @@ sentryTest('does not capture response headers if URL does not match', async ({ g _meta: { warnings: ['URL_SKIPPED'] }, }, }, - description: 'http://localhost:7654/bar', + description: 'http://sentry-test.io/bar', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseSize/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseSize/test.ts index 63e3611d9d8f..0191617d46da 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseSize/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureResponseSize/test.ts @@ -8,12 +8,12 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures response size from Content-Length header if available', async ({ getLocalTestPath, page }) => { +sentryTest('captures response size from Content-Length header if available', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: JSON.stringify({ @@ -40,17 +40,15 @@ sentryTest('captures response size from Content-Length header if available', asy return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo').then(() => { + fetch('http://sentry-test.io/foo').then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, ]); @@ -68,7 +66,7 @@ sentryTest('captures response size from Content-Length header if available', asy method: 'GET', response_body_size: 789, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -92,7 +90,7 @@ sentryTest('captures response size from Content-Length header if available', asy }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -100,12 +98,12 @@ sentryTest('captures response size from Content-Length header if available', asy ]); }); -sentryTest('captures response size without Content-Length header', async ({ getLocalTestPath, page }) => { +sentryTest('captures response size without Content-Length header', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: JSON.stringify({ @@ -132,17 +130,15 @@ sentryTest('captures response size without Content-Length header', async ({ getL return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo').then(() => { + fetch('http://sentry-test.io/foo').then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, ]); @@ -160,7 +156,7 @@ sentryTest('captures response size without Content-Length header', async ({ getL method: 'GET', status_code: 200, // NOT set here from body, as this would be async - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -184,7 +180,7 @@ sentryTest('captures response size without Content-Length header', async ({ getL }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), @@ -192,7 +188,7 @@ sentryTest('captures response size without Content-Length header', async ({ getL ]); }); -sentryTest('captures response size from non-text response body', async ({ getLocalTestPath, page }) => { +sentryTest('captures response size from non-text response body', async ({ getLocalTestUrl, page }) => { if (shouldSkipReplayTest()) { sentryTest.skip(); } @@ -221,19 +217,17 @@ sentryTest('captures response size from non-text response body', async ({ getLoc return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request, { replayRecordingSnapshots }] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }), requestPromise, replayRequestPromise, @@ -251,7 +245,7 @@ sentryTest('captures response size from non-text response body', async ({ getLoc data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -274,7 +268,7 @@ sentryTest('captures response size from non-text response body', async ({ getLoc }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.fetch', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureTimestamps/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureTimestamps/test.ts index cce931062770..d77796f92fc2 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureTimestamps/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureTimestamps/test.ts @@ -8,13 +8,13 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures correct timestamps', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures correct timestamps', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -34,19 +34,17 @@ sentryTest('captures correct timestamps', async ({ getLocalTestPath, page, brows return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.fetch'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ - fetch('http://localhost:7654/foo', { + fetch('http://sentry-test.io/foo', { method: 'POST', body: '{"foo":"bar"}', }).then(() => { // @ts-expect-error Sentry is a global Sentry.captureException('test error'); }); - /* eslint-enable */ }); const request = await requestPromise; diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/init.js b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/init.js index c43d5713f173..9db232f536cd 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/init.js @@ -6,7 +6,7 @@ window.Replay = Sentry.replayIntegration({ flushMaxDelay: 200, minReplayDuration: 0, - networkDetailAllowUrls: ['http://localhost:7654/foo', 'http://sentry-test.io/foo'], + networkDetailAllowUrls: ['http://sentry-test.io/foo'], networkCaptureBodies: true, }); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/test.ts index cd19ba50dd99..d12d74381fc2 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/test.ts @@ -8,13 +8,13 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures text request body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures text request body', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -33,14 +33,13 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send('input body'); xhr.addEventListener('readystatechange', function () { @@ -49,7 +48,6 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -66,7 +64,7 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse method: 'POST', request_body_size: 10, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -82,7 +80,7 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse body: 'input body', }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -90,13 +88,13 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse ]); }); -sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures JSON request body', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -115,14 +113,13 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send('{"foo":"bar"}'); xhr.addEventListener('readystatechange', function () { @@ -131,7 +128,6 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -148,7 +144,7 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse method: 'POST', request_body_size: 13, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -164,7 +160,7 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse body: { foo: 'bar' }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -172,7 +168,7 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse ]); }); -sentryTest('captures non-text request body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures non-text request body', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); @@ -197,18 +193,17 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); const body = new URLSearchParams(); body.append('name', 'Anne'); body.append('age', '32'); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send(body); xhr.addEventListener('readystatechange', function () { @@ -217,7 +212,6 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -234,7 +228,7 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br method: 'POST', request_body_size: 16, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -250,7 +244,7 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br body: 'name=Anne&age=32', }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -264,7 +258,7 @@ sentryTest('captures text request body when matching relative URL', async ({ get sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -287,7 +281,6 @@ sentryTest('captures text request body when matching relative URL', async ({ get await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); xhr.open('POST', '/foo'); @@ -299,7 +292,6 @@ sentryTest('captures text request body when matching relative URL', async ({ get setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -340,13 +332,13 @@ sentryTest('captures text request body when matching relative URL', async ({ get ]); }); -sentryTest('does not capture request body when URL does not match', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('does not capture request body when URL does not match', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/bar', route => { + await page.route('http://sentry-test.io/bar', route => { return route.fulfill({ status: 200, }); @@ -365,14 +357,13 @@ sentryTest('does not capture request body when URL does not match', async ({ get return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/bar'); + xhr.open('POST', 'http://sentry-test.io/bar'); xhr.send('input body'); xhr.addEventListener('readystatechange', function () { @@ -381,7 +372,6 @@ sentryTest('does not capture request body when URL does not match', async ({ get setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -398,7 +388,7 @@ sentryTest('does not capture request body when URL does not match', async ({ get method: 'POST', request_body_size: 10, status_code: 200, - url: 'http://localhost:7654/bar', + url: 'http://sentry-test.io/bar', }, }); @@ -422,7 +412,7 @@ sentryTest('does not capture request body when URL does not match', async ({ get }, }, }, - description: 'http://localhost:7654/bar', + description: 'http://sentry-test.io/bar', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/init.js b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/init.js index 8e8006759bee..5a97a87c2571 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/init.js @@ -6,7 +6,7 @@ window.Replay = Sentry.replayIntegration({ flushMaxDelay: 200, minReplayDuration: 0, - networkDetailAllowUrls: ['http://localhost:7654/foo'], + networkDetailAllowUrls: ['http://sentry-test.io/foo'], networkRequestHeaders: ['X-Test-Header'], }); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/test.ts index c9dd8c455b41..be6ac82d4b5c 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/test.ts @@ -8,13 +8,13 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures request headers', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures request headers', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -33,14 +33,13 @@ sentryTest('captures request headers', async ({ getLocalTestPath, page, browserN return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Cache', 'no-cache'); @@ -53,7 +52,6 @@ sentryTest('captures request headers', async ({ getLocalTestPath, page, browserN setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -69,7 +67,7 @@ sentryTest('captures request headers', async ({ getLocalTestPath, page, browserN data: { method: 'POST', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -87,7 +85,7 @@ sentryTest('captures request headers', async ({ getLocalTestPath, page, browserN }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -95,98 +93,93 @@ sentryTest('captures request headers', async ({ getLocalTestPath, page, browserN ]); }); -sentryTest( - 'does not capture request headers if URL does not match', - async ({ getLocalTestPath, page, browserName }) => { - // These are a bit flaky on non-chromium browsers - if (shouldSkipReplayTest() || browserName !== 'chromium') { - sentryTest.skip(); - } - - await page.route('**/bar', route => { - return route.fulfill({ - status: 200, - }); - }); +sentryTest('does not capture request headers if URL does not match', async ({ getLocalTestUrl, page, browserName }) => { + // These are a bit flaky on non-chromium browsers + if (shouldSkipReplayTest() || browserName !== 'chromium') { + 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' }), - }); + await page.route('http://sentry-test.io/bar', route => { + return route.fulfill({ + status: 200, }); + }); - const requestPromise = waitForErrorRequest(page); - const replayRequestPromise = collectReplayRequests(page, recordingEvents => { - return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); + await page.route('https://dsn.ingest.sentry.io/**/*', route => { + return route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({ id: 'test-id' }), }); + }); + + const requestPromise = waitForErrorRequest(page); + const replayRequestPromise = collectReplayRequests(page, recordingEvents => { + return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); + }); + + const url = await getLocalTestUrl({ testDir: __dirname }); + await page.goto(url); + + void page.evaluate(() => { + const xhr = new XMLHttpRequest(); - const url = await getLocalTestPath({ testDir: __dirname }); - await page.goto(url); - - void page.evaluate(() => { - /* eslint-disable */ - const xhr = new XMLHttpRequest(); - - xhr.open('POST', 'http://localhost:7654/bar'); - xhr.setRequestHeader('Accept', 'application/json'); - xhr.setRequestHeader('Content-Type', 'application/json'); - xhr.setRequestHeader('Cache', 'no-cache'); - xhr.setRequestHeader('X-Test-Header', 'test-value'); - xhr.send(); - - xhr.addEventListener('readystatechange', function () { - if (xhr.readyState === 4) { - // @ts-expect-error Sentry is a global - setTimeout(() => Sentry.captureException('test error', 0)); - } - }); - /* eslint-enable */ + xhr.open('POST', 'http://sentry-test.io/bar'); + xhr.setRequestHeader('Accept', 'application/json'); + xhr.setRequestHeader('Content-Type', 'application/json'); + xhr.setRequestHeader('Cache', 'no-cache'); + xhr.setRequestHeader('X-Test-Header', 'test-value'); + xhr.send(); + + xhr.addEventListener('readystatechange', function () { + if (xhr.readyState === 4) { + // @ts-expect-error Sentry is a global + setTimeout(() => Sentry.captureException('test error', 0)); + } }); + }); - const [request] = await Promise.all([requestPromise]); + const [request] = await Promise.all([requestPromise]); - const eventData = envelopeRequestParser(request); + const eventData = envelopeRequestParser(request); + + expect(eventData.exception?.values).toHaveLength(1); - expect(eventData.exception?.values).toHaveLength(1); + expect(eventData?.breadcrumbs?.length).toBe(1); + expect(eventData!.breadcrumbs![0]).toEqual({ + timestamp: expect.any(Number), + category: 'xhr', + type: 'http', + data: { + method: 'POST', + status_code: 200, + url: 'http://sentry-test.io/bar', + }, + }); - expect(eventData?.breadcrumbs?.length).toBe(1); - expect(eventData!.breadcrumbs![0]).toEqual({ - timestamp: expect.any(Number), - category: 'xhr', - type: 'http', + const { replayRecordingSnapshots } = await replayRequestPromise; + expect(getReplayPerformanceSpans(replayRecordingSnapshots).filter(span => span.op === 'resource.xhr')).toEqual([ + { data: { method: 'POST', - status_code: 200, - url: 'http://localhost:7654/bar', - }, - }); - - const { replayRecordingSnapshots } = await replayRequestPromise; - expect(getReplayPerformanceSpans(replayRecordingSnapshots).filter(span => span.op === 'resource.xhr')).toEqual([ - { - data: { - method: 'POST', - statusCode: 200, - request: { - headers: {}, - _meta: { - warnings: ['URL_SKIPPED'], - }, + statusCode: 200, + request: { + headers: {}, + _meta: { + warnings: ['URL_SKIPPED'], }, - response: { - headers: {}, - _meta: { - warnings: ['URL_SKIPPED'], - }, + }, + response: { + headers: {}, + _meta: { + warnings: ['URL_SKIPPED'], }, }, - description: 'http://localhost:7654/bar', - endTimestamp: expect.any(Number), - op: 'resource.xhr', - startTimestamp: expect.any(Number), }, - ]); - }, -); + description: 'http://sentry-test.io/bar', + endTimestamp: expect.any(Number), + op: 'resource.xhr', + startTimestamp: expect.any(Number), + }, + ]); +}); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts index 50709dc37705..73d063ea1b47 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts @@ -8,13 +8,13 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures request body size when body is sent', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures request body size when body is sent', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -33,15 +33,14 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); const [, request] = await Promise.all([ page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send('{"foo":"bar"}'); xhr.addEventListener('readystatechange', function () { @@ -50,7 +49,6 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }), requestPromise, ]); @@ -68,7 +66,7 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest method: 'POST', request_body_size: 13, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -92,7 +90,7 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -100,7 +98,7 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest ]); }); -sentryTest('captures request size from non-text request body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures request size from non-text request body', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); @@ -125,16 +123,15 @@ sentryTest('captures request size from non-text request body', async ({ getLocal return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); const blob = new Blob(['Hello world!!'], { type: 'text/html' }); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send(blob); xhr.addEventListener('readystatechange', function () { @@ -143,7 +140,6 @@ sentryTest('captures request size from non-text request body', async ({ getLocal setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -160,7 +156,7 @@ sentryTest('captures request size from non-text request body', async ({ getLocal method: 'POST', request_body_size: 26, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -184,7 +180,7 @@ sentryTest('captures request size from non-text request body', async ({ getLocal }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/init.js b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/init.js index f2eb62b8c051..9db232f536cd 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/init.js @@ -6,7 +6,7 @@ window.Replay = Sentry.replayIntegration({ flushMaxDelay: 200, minReplayDuration: 0, - networkDetailAllowUrls: ['http://localhost:7654/foo'], + networkDetailAllowUrls: ['http://sentry-test.io/foo'], networkCaptureBodies: true, }); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/test.ts index 97e9bcd749fa..afa2c669f204 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/test.ts @@ -8,13 +8,13 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures text response body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures text response body', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: 'response body', @@ -37,14 +37,13 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send(); xhr.addEventListener('readystatechange', function () { @@ -53,7 +52,6 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -70,7 +68,7 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows method: 'POST', response_body_size: 13, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -86,7 +84,7 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows body: 'response body', }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -94,13 +92,13 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows ]); }); -sentryTest('captures JSON response body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures JSON response body', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: JSON.stringify({ res: 'this' }), @@ -123,14 +121,13 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send(); xhr.addEventListener('readystatechange', function () { @@ -139,7 +136,6 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -156,7 +152,7 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows method: 'POST', response_body_size: 14, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -172,7 +168,7 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows body: { res: 'this' }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -180,13 +176,13 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows ]); }); -sentryTest('captures JSON response body when responseType=json', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures JSON response body when responseType=json', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: JSON.stringify({ res: 'this' }), @@ -209,14 +205,13 @@ sentryTest('captures JSON response body when responseType=json', async ({ getLoc return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); // Setting this to json ensures that xhr.response returns a POJO xhr.responseType = 'json'; xhr.send(); @@ -227,7 +222,6 @@ sentryTest('captures JSON response body when responseType=json', async ({ getLoc setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -244,7 +238,7 @@ sentryTest('captures JSON response body when responseType=json', async ({ getLoc method: 'POST', response_body_size: 14, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -260,7 +254,7 @@ sentryTest('captures JSON response body when responseType=json', async ({ getLoc body: { res: 'this' }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -268,13 +262,13 @@ sentryTest('captures JSON response body when responseType=json', async ({ getLoc ]); }); -sentryTest('captures non-text response body', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures non-text response body', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', async route => { + await page.route('http://sentry-test.io/foo', async route => { return route.fulfill({ status: 200, body: Buffer.from('Hello world'), @@ -297,14 +291,13 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send(); xhr.addEventListener('readystatechange', function () { @@ -313,7 +306,6 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -330,7 +322,7 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b method: 'POST', response_body_size: 24, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -346,7 +338,7 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b body: 'Hello world', }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -354,99 +346,94 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b ]); }); -sentryTest( - 'does not capture response body when URL does not match', - async ({ getLocalTestPath, page, browserName }) => { - // These are a bit flaky on non-chromium browsers - if (shouldSkipReplayTest() || browserName !== 'chromium') { - sentryTest.skip(); - } - - await page.route('**/bar', route => { - return route.fulfill({ - status: 200, - body: 'response body', - headers: { - 'Content-Length': '', - }, - }); - }); +sentryTest('does not capture response body when URL does not match', async ({ getLocalTestUrl, page, browserName }) => { + // These are a bit flaky on non-chromium browsers + if (shouldSkipReplayTest() || browserName !== 'chromium') { + 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' }), - }); + await page.route('http://sentry-test.io/bar', route => { + return route.fulfill({ + status: 200, + body: 'response body', + headers: { + 'Content-Length': '', + }, }); + }); - const requestPromise = waitForErrorRequest(page); - const replayRequestPromise = collectReplayRequests(page, recordingEvents => { - return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); + 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 getLocalTestPath({ testDir: __dirname }); - await page.goto(url); + const requestPromise = waitForErrorRequest(page); + const replayRequestPromise = collectReplayRequests(page, recordingEvents => { + return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); + }); - void page.evaluate(() => { - /* eslint-disable */ - const xhr = new XMLHttpRequest(); + const url = await getLocalTestUrl({ testDir: __dirname }); + await page.goto(url); - xhr.open('POST', 'http://localhost:7654/bar'); - xhr.send(); + void page.evaluate(() => { + const xhr = new XMLHttpRequest(); - xhr.addEventListener('readystatechange', function () { - if (xhr.readyState === 4) { - // @ts-expect-error Sentry is a global - setTimeout(() => Sentry.captureException('test error', 0)); - } - }); - /* eslint-enable */ + xhr.open('POST', 'http://sentry-test.io/bar'); + xhr.send(); + + xhr.addEventListener('readystatechange', function () { + if (xhr.readyState === 4) { + // @ts-expect-error Sentry is a global + setTimeout(() => Sentry.captureException('test error', 0)); + } }); + }); - const request = await requestPromise; - const eventData = envelopeRequestParser(request); + const request = await requestPromise; + const eventData = envelopeRequestParser(request); - expect(eventData.exception?.values).toHaveLength(1); + expect(eventData.exception?.values).toHaveLength(1); - expect(eventData?.breadcrumbs?.length).toBe(1); - expect(eventData!.breadcrumbs![0]).toEqual({ - timestamp: expect.any(Number), - category: 'xhr', - type: 'http', + expect(eventData?.breadcrumbs?.length).toBe(1); + expect(eventData!.breadcrumbs![0]).toEqual({ + timestamp: expect.any(Number), + category: 'xhr', + type: 'http', + data: { + method: 'POST', + response_body_size: 13, + status_code: 200, + url: 'http://sentry-test.io/bar', + }, + }); + + const { replayRecordingSnapshots } = await replayRequestPromise; + expect(getReplayPerformanceSpans(replayRecordingSnapshots).filter(span => span.op === 'resource.xhr')).toEqual([ + { data: { method: 'POST', - response_body_size: 13, - status_code: 200, - url: 'http://localhost:7654/bar', - }, - }); - - const { replayRecordingSnapshots } = await replayRequestPromise; - expect(getReplayPerformanceSpans(replayRecordingSnapshots).filter(span => span.op === 'resource.xhr')).toEqual([ - { - data: { - method: 'POST', - statusCode: 200, - request: { - headers: {}, - _meta: { - warnings: ['URL_SKIPPED'], - }, + statusCode: 200, + request: { + headers: {}, + _meta: { + warnings: ['URL_SKIPPED'], }, - response: { - size: 13, - headers: {}, - _meta: { - warnings: ['URL_SKIPPED'], - }, + }, + response: { + size: 13, + headers: {}, + _meta: { + warnings: ['URL_SKIPPED'], }, }, - description: 'http://localhost:7654/bar', - endTimestamp: expect.any(Number), - op: 'resource.xhr', - startTimestamp: expect.any(Number), }, - ]); - }, -); + description: 'http://sentry-test.io/bar', + endTimestamp: expect.any(Number), + op: 'resource.xhr', + startTimestamp: expect.any(Number), + }, + ]); +}); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/init.js b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/init.js index a2a7a1680123..82bc5a045870 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/init.js @@ -6,7 +6,7 @@ window.Replay = Sentry.replayIntegration({ flushMaxDelay: 200, minReplayDuration: 0, - networkDetailAllowUrls: ['http://localhost:7654/foo'], + networkDetailAllowUrls: ['http://sentry-test.io/foo'], networkResponseHeaders: ['X-Test-Header'], }); diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/test.ts index 754c2adf588f..4726f69c641d 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/test.ts @@ -8,13 +8,13 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures response headers', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures response headers', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, headers: { @@ -40,14 +40,13 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page, browser return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('GET', 'http://localhost:7654/foo'); + xhr.open('GET', 'http://sentry-test.io/foo'); xhr.send(); xhr.addEventListener('readystatechange', function () { @@ -56,7 +55,6 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page, browser setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -72,7 +70,7 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page, browser data: { method: 'GET', status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -90,7 +88,7 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page, browser }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -100,13 +98,13 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page, browser sentryTest( 'does not capture response headers if URL does not match', - async ({ getLocalTestPath, page, browserName }) => { + async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/bar', route => { + await page.route('http://sentry-test.io/bar', route => { return route.fulfill({ status: 200, headers: { @@ -132,14 +130,13 @@ sentryTest( return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('GET', 'http://localhost:7654/bar'); + xhr.open('GET', 'http://sentry-test.io/bar'); xhr.send(); xhr.addEventListener('readystatechange', function () { @@ -148,7 +145,6 @@ sentryTest( setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -164,7 +160,7 @@ sentryTest( data: { method: 'GET', status_code: 200, - url: 'http://localhost:7654/bar', + url: 'http://sentry-test.io/bar', }, }); @@ -187,7 +183,7 @@ sentryTest( }, }, }, - description: 'http://localhost:7654/bar', + description: 'http://sentry-test.io/bar', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseSize/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseSize/test.ts index 5024e65741e9..dda9e4e642c1 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseSize/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseSize/test.ts @@ -10,13 +10,13 @@ import { sentryTest( 'captures response size from Content-Length header if available', - async ({ getLocalTestPath, page, browserName }) => { + async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, headers: { @@ -38,14 +38,13 @@ sentryTest( return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('GET', 'http://localhost:7654/foo'); + xhr.open('GET', 'http://sentry-test.io/foo'); xhr.send(); xhr.addEventListener('readystatechange', function () { @@ -54,7 +53,6 @@ sentryTest( setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -71,7 +69,7 @@ sentryTest( method: 'GET', response_body_size: 789, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -95,7 +93,7 @@ sentryTest( }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -104,13 +102,13 @@ sentryTest( }, ); -sentryTest('captures response size without Content-Length header', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures response size without Content-Length header', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, body: JSON.stringify({ @@ -135,14 +133,13 @@ sentryTest('captures response size without Content-Length header', async ({ getL return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('GET', 'http://localhost:7654/foo'); + xhr.open('GET', 'http://sentry-test.io/foo'); xhr.send(); xhr.addEventListener('readystatechange', function () { @@ -151,7 +148,6 @@ sentryTest('captures response size without Content-Length header', async ({ getL setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -159,8 +155,8 @@ sentryTest('captures response size without Content-Length header', async ({ getL expect(eventData.exception?.values).toHaveLength(1); - expect(eventData?.breadcrumbs?.length).toBe(1); - expect(eventData!.breadcrumbs![0]).toEqual({ + expect(eventData.breadcrumbs?.length).toBe(1); + expect(eventData.breadcrumbs![0]).toEqual({ timestamp: expect.any(Number), category: 'xhr', type: 'http', @@ -168,7 +164,7 @@ sentryTest('captures response size without Content-Length header', async ({ getL method: 'GET', response_body_size: 29, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -192,7 +188,7 @@ sentryTest('captures response size without Content-Length header', async ({ getL }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), @@ -200,13 +196,13 @@ sentryTest('captures response size without Content-Length header', async ({ getL ]); }); -sentryTest('captures response size for non-string bodies', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures response size for non-string bodies', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', async route => { + await page.route('http://sentry-test.io/foo', async route => { return route.fulfill({ status: 200, body: Buffer.from('Hello world'), @@ -229,14 +225,13 @@ sentryTest('captures response size for non-string bodies', async ({ getLocalTest return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); await page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.send(); xhr.addEventListener('readystatechange', function () { @@ -245,7 +240,6 @@ sentryTest('captures response size for non-string bodies', async ({ getLocalTest setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; @@ -262,7 +256,7 @@ sentryTest('captures response size for non-string bodies', async ({ getLocalTest method: 'POST', response_body_size: 24, status_code: 200, - url: 'http://localhost:7654/foo', + url: 'http://sentry-test.io/foo', }, }); @@ -286,7 +280,7 @@ sentryTest('captures response size for non-string bodies', async ({ getLocalTest }, }, }, - description: 'http://localhost:7654/foo', + description: 'http://sentry-test.io/foo', endTimestamp: expect.any(Number), op: 'resource.xhr', startTimestamp: expect.any(Number), diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureTimestamps/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureTimestamps/test.ts index d5d065f83ec5..e89fa6e4a24e 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureTimestamps/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureTimestamps/test.ts @@ -8,13 +8,13 @@ import { shouldSkipReplayTest, } from '../../../../../utils/replayHelpers'; -sentryTest('captures correct timestamps', async ({ getLocalTestPath, page, browserName }) => { +sentryTest('captures correct timestamps', async ({ getLocalTestUrl, page, browserName }) => { // These are a bit flaky on non-chromium browsers if (shouldSkipReplayTest() || browserName !== 'chromium') { sentryTest.skip(); } - await page.route('**/foo', route => { + await page.route('http://sentry-test.io/foo', route => { return route.fulfill({ status: 200, }); @@ -34,14 +34,13 @@ sentryTest('captures correct timestamps', async ({ getLocalTestPath, page, brows return getReplayPerformanceSpans(recordingEvents).some(span => span.op === 'resource.xhr'); }); - const url = await getLocalTestPath({ testDir: __dirname }); + const url = await getLocalTestUrl({ testDir: __dirname }); await page.goto(url); void page.evaluate(() => { - /* eslint-disable */ const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost:7654/foo'); + xhr.open('POST', 'http://sentry-test.io/foo'); xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Cache', 'no-cache'); @@ -54,7 +53,6 @@ sentryTest('captures correct timestamps', async ({ getLocalTestPath, page, brows setTimeout(() => Sentry.captureException('test error', 0)); } }); - /* eslint-enable */ }); const request = await requestPromise; diff --git a/dev-packages/browser-integration-tests/suites/sessions/initial-scope/test.ts b/dev-packages/browser-integration-tests/suites/sessions/initial-scope/test.ts index 8a9ba80cdbc4..9d7b07f1cfd1 100644 --- a/dev-packages/browser-integration-tests/suites/sessions/initial-scope/test.ts +++ b/dev-packages/browser-integration-tests/suites/sessions/initial-scope/test.ts @@ -16,14 +16,10 @@ sentryTest('should start a new session on pageload.', async ({ getLocalTestPath, expect(session.did).toBe('1337'); }); -sentryTest('should start a new session with navigation.', async ({ getLocalTestPath, page, browserName }) => { - // Navigations get CORS error on Firefox and WebKit as we're using `file://` protocol. - if (browserName !== 'chromium') { - sentryTest.skip(); - } +sentryTest('should start a new session with navigation.', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); - const url = await getLocalTestPath({ testDir: __dirname }); - await page.route('**/foo', (route: Route) => route.fulfill({ path: `${__dirname}/dist/index.html` })); + await page.route('**/foo', (route: Route) => route.continue({ url })); await page.route('https://dsn.ingest.sentry.io/**/*', route => { return route.fulfill({ diff --git a/dev-packages/browser-integration-tests/suites/sessions/start-session/test.ts b/dev-packages/browser-integration-tests/suites/sessions/start-session/test.ts index 62c969d2e76d..65f9eef8e9ae 100644 --- a/dev-packages/browser-integration-tests/suites/sessions/start-session/test.ts +++ b/dev-packages/browser-integration-tests/suites/sessions/start-session/test.ts @@ -15,14 +15,9 @@ sentryTest('should start a new session on pageload.', async ({ getLocalTestPath, expect(session.status).toBe('ok'); }); -sentryTest('should start a new session with navigation.', async ({ getLocalTestPath, page, browserName }) => { - // Navigations get CORS error on Firefox and WebKit as we're using `file://` protocol. - if (browserName !== 'chromium') { - sentryTest.skip(); - } - - const url = await getLocalTestPath({ testDir: __dirname }); - await page.route('**/foo', (route: Route) => route.fulfill({ path: `${__dirname}/dist/index.html` })); +sentryTest('should start a new session with navigation.', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); + await page.route('**/foo', (route: Route) => route.continue({ url })); await page.route('https://dsn.ingest.sentry.io/**/*', route => { return route.fulfill({ diff --git a/dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/test.ts b/dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/test.ts index 62c969d2e76d..65f9eef8e9ae 100644 --- a/dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/test.ts +++ b/dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/test.ts @@ -15,14 +15,9 @@ sentryTest('should start a new session on pageload.', async ({ getLocalTestPath, expect(session.status).toBe('ok'); }); -sentryTest('should start a new session with navigation.', async ({ getLocalTestPath, page, browserName }) => { - // Navigations get CORS error on Firefox and WebKit as we're using `file://` protocol. - if (browserName !== 'chromium') { - sentryTest.skip(); - } - - const url = await getLocalTestPath({ testDir: __dirname }); - await page.route('**/foo', (route: Route) => route.fulfill({ path: `${__dirname}/dist/index.html` })); +sentryTest('should start a new session with navigation.', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); + await page.route('**/foo', (route: Route) => route.continue({ url })); await page.route('https://dsn.ingest.sentry.io/**/*', route => { return route.fulfill({ diff --git a/dev-packages/browser-integration-tests/utils/fixtures.ts b/dev-packages/browser-integration-tests/utils/fixtures.ts index cf34c9b7e693..e154ddc25988 100644 --- a/dev-packages/browser-integration-tests/utils/fixtures.ts +++ b/dev-packages/browser-integration-tests/utils/fixtures.ts @@ -1,3 +1,4 @@ +import crypto from 'crypto'; import fs from 'fs'; import path from 'path'; /* eslint-disable no-empty-pattern */ @@ -11,16 +12,19 @@ export const TEST_HOST = 'http://sentry-test.io'; const getAsset = (assetDir: string, asset: string): string => { const assetPath = `${assetDir}/${asset}`; + // Try to find the asset in the same directory if (fs.existsSync(assetPath)) { return assetPath; } + // Else, try to find it in the parent directory const parentDirAssetPath = `${path.dirname(assetDir)}/${asset}`; if (fs.existsSync(parentDirAssetPath)) { return parentDirAssetPath; } + // Else use a static asset return `utils/defaults/${asset}`; }; @@ -54,44 +58,50 @@ const sentryTest = base.extend