diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6004a046f126..4ac4a75e150b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -371,7 +371,6 @@ jobs: path: | ${{ github.workspace }}/packages/browser/build/bundles/** ${{ github.workspace }}/packages/integrations/build/bundles/** - ${{ github.workspace }}/packages/tracing/build/bundles/** ${{ github.workspace }}/packages/replay/build/bundles/** ${{ github.workspace }}/packages/**/*.tgz @@ -482,7 +481,7 @@ jobs: yarn test:integration job_browser_playwright_tests: - name: Playwright (${{ matrix.bundle }})${{ (matrix.tracing_only && ' tracing only') || '' }} Tests + name: Playwright (${{ matrix.bundle }}) Tests needs: [job_get_metadata, job_build] if: needs.job_get_metadata.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request' runs-on: ubuntu-20.04 @@ -499,16 +498,13 @@ jobs: - bundle_es6_min - bundle_replay_es6 - bundle_replay_es6_min - tracing_only: - - true - - false - exclude: - # `tracing_only` only makes a difference for bundles - tests of the esm and cjs builds always include the - # tracing tests - - bundle: esm - tracing_only: false - - bundle: cjs - tracing_only: false + - bundle_tracing_es5 + - bundle_tracing_es5_min + - bundle_tracing_es6 + - bundle_tracing_es6_min + - bundle_tracing_replay_es6 + - bundle_tracing_replay_es6_min + steps: - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v3 @@ -543,7 +539,6 @@ jobs: - name: Run Playwright tests env: PW_BUNDLE: ${{ matrix.bundle }} - PW_TRACING_ONLY: ${{ matrix.tracing_only }} run: | cd packages/browser-integration-tests yarn test:ci diff --git a/.size-limit.js b/.size-limit.js index edc8a5466235..863b3628ebb1 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -53,13 +53,13 @@ module.exports = [ }, { name: '@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified)', - path: 'packages/tracing/build/bundles/bundle.tracing.es5.min.js', + path: 'packages/browser/build/bundles/bundle.tracing.es5.min.js', gzip: true, limit: '37 KB', }, { name: '@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified)', - path: 'packages/tracing/build/bundles/bundle.tracing.min.js', + path: 'packages/browser/build/bundles/bundle.tracing.min.js', gzip: true, limit: '35 KB', }, @@ -80,7 +80,7 @@ module.exports = [ }, { name: '@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified)', - path: 'packages/tracing/build/bundles/bundle.tracing.replay.min.js', + path: 'packages/browser/build/bundles/bundle.tracing.replay.min.js', gzip: true, limit: '80 KB', }, diff --git a/packages/browser-integration-tests/package.json b/packages/browser-integration-tests/package.json index 242fe0ce0d5e..9b3c52e62ab0 100644 --- a/packages/browser-integration-tests/package.json +++ b/packages/browser-integration-tests/package.json @@ -25,6 +25,12 @@ "test:bundle:es6:min": "PW_BUNDLE=bundle_es6_min yarn test", "test:bundle:replay:es6": "PW_BUNDLE=bundle_replay_es6 yarn test", "test:bundle:replay:es6:min": "PW_BUNDLE=bundle_replay_es6_min yarn test", + "test:bundle:tracing:es5": "PW_BUNDLE=bundle_tracing_es5 yarn test", + "test:bundle:tracing:es5:min": "PW_BUNDLE=bundle_tracing_es5_min yarn test", + "test:bundle:tracing:es6": "PW_BUNDLE=bundle_tracing_es6 yarn test", + "test:bundle:tracing:es6:min": "PW_BUNDLE=bundle_tracing_es6_min yarn test", + "test:bundle:tracing:replay:es6": "PW_BUNDLE=bundle_tracing_replay_es6 yarn test", + "test:bundle:tracing:replay:es6:min": "PW_BUNDLE=bundle_tracing_replay_es6_min yarn test", "test:cjs": "PW_BUNDLE=cjs yarn test", "test:esm": "PW_BUNDLE=esm yarn test", "test:ci": "playwright test ./suites --browser='all' --reporter='line'", diff --git a/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/test.ts b/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/test.ts index 7b42d280248d..2fba18b0804b 100644 --- a/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/test.ts +++ b/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should report a transaction in an envelope', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const transaction = await getFirstSentryEnvelopeRequest(page, url); @@ -13,6 +17,10 @@ sentryTest('should report a transaction in an envelope', async ({ getLocalTestPa }); sentryTest('should report finished spans as children of the root transaction', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const transaction = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/test.ts b/packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/test.ts index 88ed63b08864..1870f679b3da 100644 --- a/packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/test.ts +++ b/packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should be able to handle circular data', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts b/packages/browser-integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts index fecda098bf43..fe45323474f0 100644 --- a/packages/browser-integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts +++ b/packages/browser-integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should attach measurement to transaction', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const event = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/replay/dsc/test.ts b/packages/browser-integration-tests/suites/replay/dsc/test.ts index 0819e9f7bf71..f4cca11e2339 100644 --- a/packages/browser-integration-tests/suites/replay/dsc/test.ts +++ b/packages/browser-integration-tests/suites/replay/dsc/test.ts @@ -2,12 +2,16 @@ import { expect } from '@playwright/test'; import type { EventEnvelopeHeaders } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; +import { + envelopeHeaderRequestParser, + getFirstSentryEnvelopeRequest, + shouldSkipTracingTest, +} from '../../../utils/helpers'; import { getReplaySnapshot, shouldSkipReplayTest, waitForReplayRunning } from '../../../utils/replayHelpers'; sentryTest('should add replay_id to dsc of transactions', async ({ getLocalTestPath, page, browserName }) => { // This is flaky on webkit, so skipping there... - if (shouldSkipReplayTest() || browserName === 'webkit') { + if (shouldSkipReplayTest() || shouldSkipTracingTest() || browserName === 'webkit') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browserTracingIntegrationShim/test.ts b/packages/browser-integration-tests/suites/tracing/browserTracingIntegrationShim/test.ts index 5d2b96232d16..e37181ee815b 100644 --- a/packages/browser-integration-tests/suites/tracing/browserTracingIntegrationShim/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browserTracingIntegrationShim/test.ts @@ -1,14 +1,13 @@ import { expect } from '@playwright/test'; import { sentryTest } from '../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../utils/helpers'; sentryTest( 'exports a shim Integrations.BrowserTracing integration for non-tracing bundles', async ({ getLocalTestPath, page }) => { - const bundle = process.env.PW_BUNDLE; - const tracingOnly = Boolean(process.env.PW_TRACING_ONLY); - - if (!bundle || !bundle.startsWith('bundle_') || tracingOnly) { + // Skip in tracing tests + if (!shouldSkipTracingTest()) { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browserTracingShim/test.ts b/packages/browser-integration-tests/suites/tracing/browserTracingShim/test.ts index 74cb8b2fce9f..7b6027694734 100644 --- a/packages/browser-integration-tests/suites/tracing/browserTracingShim/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browserTracingShim/test.ts @@ -1,12 +1,11 @@ import { expect } from '@playwright/test'; import { sentryTest } from '../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../utils/helpers'; sentryTest('exports a shim BrowserTracing integration for non-tracing bundles', async ({ getLocalTestPath, page }) => { - const bundle = process.env.PW_BUNDLE; - const tracingOnly = Boolean(process.env.PW_TRACING_ONLY); - - if (!bundle || !bundle.startsWith('bundle_') || tracingOnly) { + // Skip in tracing tests + if (!shouldSkipTracingTest()) { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts index 8b201b7d7bbf..eca82197d80c 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts @@ -3,13 +3,17 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; async function getPropertyValue(handle: JSHandle, prop: string) { return (await handle.getProperty(prop))?.jsonValue(); } sentryTest('should finish a custom transaction when the page goes background', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const pageloadTransaction = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts index af7de77b93f7..17f5920c57de 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts @@ -2,13 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest( 'should finish pageload transaction when the page goes background', async ({ browserName, getLocalTestPath, page }) => { // TODO: This is flakey on firefox... trace.status is sometimes undefined - if (['firefox'].includes(browserName)) { + if (shouldSkipTracingTest() || ['firefox'].includes(browserName)) { sentryTest.skip(); } const url = await getLocalTestPath({ testDir: __dirname }); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/interactions/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/interactions/test.ts index faff888fc2e8..9b161699b9c0 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/interactions/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/interactions/test.ts @@ -3,7 +3,11 @@ import { expect } from '@playwright/test'; import type { Event, Span, SpanContext, Transaction } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest, getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers'; +import { + getFirstSentryEnvelopeRequest, + getMultipleSentryEnvelopeRequests, + shouldSkipTracingTest, +} from '../../../../utils/helpers'; type TransactionJSON = ReturnType & { spans: ReturnType[]; @@ -17,7 +21,7 @@ const wait = (time: number) => new Promise(res => setTimeout(res, time)); sentryTest('should capture interaction transaction.', async ({ browserName, getLocalTestPath, page }) => { const supportedBrowsers = ['chromium', 'firefox']; - if (!supportedBrowsers.includes(browserName)) { + if (shouldSkipTracingTest() || !supportedBrowsers.includes(browserName)) { sentryTest.skip(); } @@ -54,7 +58,7 @@ sentryTest('should capture interaction transaction.', async ({ browserName, getL sentryTest('should create only one transaction per interaction', async ({ browserName, getLocalTestPath, page }) => { const supportedBrowsers = ['chromium', 'firefox']; - if (!supportedBrowsers.includes(browserName)) { + if (shouldSkipTracingTest() || !supportedBrowsers.includes(browserName)) { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-disabled/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-disabled/test.ts index c392258570d9..6dab208d1c4e 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-disabled/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-disabled/test.ts @@ -3,11 +3,11 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should not capture long task when flag is disabled.', async ({ browserName, getLocalTestPath, page }) => { // Long tasks only work on chrome - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-enabled/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-enabled/test.ts index 9ee877e39268..54da1074c1c5 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-enabled/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-enabled/test.ts @@ -3,11 +3,11 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture long task.', async ({ browserName, getLocalTestPath, page }) => { // Long tasks only work on chrome - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/meta/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/meta/test.ts index c447f41c8660..ae89fd383cbb 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/meta/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/meta/test.ts @@ -2,11 +2,19 @@ import { expect } from '@playwright/test'; import type { Event, EventEnvelopeHeaders } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { + envelopeHeaderRequestParser, + getFirstSentryEnvelopeRequest, + shouldSkipTracingTest, +} from '../../../../utils/helpers'; sentryTest( 'should create a pageload transaction based on `sentry-trace` ', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); @@ -24,6 +32,10 @@ sentryTest( sentryTest( 'should pick up `baggage` tag, propagate the content in transaction and not add own data', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const envHeader = await getFirstSentryEnvelopeRequest(page, url, envelopeHeaderRequestParser); @@ -41,6 +53,10 @@ sentryTest( sentryTest( "should create a navigation that's not influenced by `sentry-trace` ", async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const pageloadRequest = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/navigation/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/navigation/test.ts index 77157951f494..5a46a65a4392 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/navigation/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/navigation/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should create a navigation transaction on page navigation', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const pageloadRequest = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/pageload/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/pageload/test.ts index fc7de0b067b7..7624b26466e5 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/pageload/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/pageload/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should create a pageload transaction', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts index ca1deada91d0..d7cf60e3e726 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( 'should attach `sentry-trace` and `baggage` header to request matching tracePropagationTargets', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts index 6e3fea23e09b..19c949ad07a7 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( '[pre-v8] should prefer custom tracePropagationTargets over tracingOrigins', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts index 0983c53a5622..47c24618492a 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( '[pre-v8] should attach `sentry-trace` and `baggage` header to request matching tracingOrigins', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts index c046912e6621..3edbd3d3c99b 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( 'should attach `sentry-trace` and `baggage` header to request matching default tracePropagationTargets', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts index 0767ced38bb5..445fa0fdba70 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( 'should not attach `sentry-trace` and `baggage` header to request not matching default tracePropagationTargets', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts b/packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts index 8d5b75e4907c..bc94930e0be5 100644 --- a/packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts +++ b/packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts @@ -2,11 +2,19 @@ import { expect } from '@playwright/test'; import type { EventEnvelopeHeaders } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; +import { + envelopeHeaderRequestParser, + getFirstSentryEnvelopeRequest, + shouldSkipTracingTest, +} from '../../../utils/helpers'; sentryTest( 'should only include transaction name if source is better than an unparameterized URL', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const envHeader = await getFirstSentryEnvelopeRequest(page, url, envelopeHeaderRequestParser); diff --git a/packages/browser-integration-tests/suites/tracing/envelope-header/test.ts b/packages/browser-integration-tests/suites/tracing/envelope-header/test.ts index b70ae62b4903..b8df56e72f7c 100644 --- a/packages/browser-integration-tests/suites/tracing/envelope-header/test.ts +++ b/packages/browser-integration-tests/suites/tracing/envelope-header/test.ts @@ -2,11 +2,19 @@ import { expect } from '@playwright/test'; import type { EventEnvelopeHeaders } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; +import { + envelopeHeaderRequestParser, + getFirstSentryEnvelopeRequest, + shouldSkipTracingTest, +} from '../../../utils/helpers'; sentryTest( 'should send dynamic sampling context data in trace envelope header of a transaction envelope', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const envHeader = await getFirstSentryEnvelopeRequest(page, url, envelopeHeaderRequestParser); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/connection-rtt/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/connection-rtt/test.ts index 273609e97d15..4dbb8f186d42 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/connection-rtt/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/connection-rtt/test.ts @@ -3,10 +3,10 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest.beforeEach(({ browserName }) => { - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } }); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts index 8b8ca6b0f7b8..b60cdce9703b 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should add browser-related spans to pageload transaction', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts index 83ae9580d84d..e98cb5b3d9b2 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts @@ -3,9 +3,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should add resource spans to pageload transaction', async ({ getLocalTestPath, page, browser }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + // Intercepting asset requests to avoid network-related flakiness and random retries (on Firefox). await page.route('**/path/to/image.svg', (route: Route) => route.fulfill({ path: `${__dirname}/assets/image.svg` })); await page.route('**/path/to/script.js', (route: Route) => route.fulfill({ path: `${__dirname}/assets/script.js` })); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts index a445cc967147..0dee366c75f4 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts @@ -2,10 +2,10 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest.beforeEach(async ({ browserName, page }) => { - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts index 966760096add..55e0b4d0e833 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts @@ -2,11 +2,11 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture a FID vital.', async ({ browserName, getLocalTestPath, page }) => { // FID measurement is not generated on webkit - if (browserName === 'webkit') { + if (shouldSkipTracingTest() || browserName === 'webkit') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts index b120e580a55c..3a97c62d7f68 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts @@ -2,11 +2,11 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture FP vital.', async ({ browserName, getLocalTestPath, page }) => { // FP is not generated on webkit or firefox - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } @@ -24,6 +24,10 @@ sentryTest('should capture FP vital.', async ({ browserName, getLocalTestPath, p }); sentryTest('should capture FCP vital.', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts index 7511abf60d09..63bfde0a6c46 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts @@ -3,10 +3,10 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture a LCP vital with element details.', async ({ browserName, getLocalTestPath, page }) => { - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-ttfb/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-ttfb/test.ts index 81d5f1f7430e..0a4b1e6d3da6 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-ttfb/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-ttfb/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture TTFB vital.', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/request/fetch/test.ts b/packages/browser-integration-tests/suites/tracing/request/fetch/test.ts index a5b8185e20f1..7b374422a2f3 100644 --- a/packages/browser-integration-tests/suites/tracing/request/fetch/test.ts +++ b/packages/browser-integration-tests/suites/tracing/request/fetch/test.ts @@ -3,9 +3,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers'; +import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should create spans for multiple fetch requests', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); // Because we fetch from http://example.com, fetch will throw a CORS error in firefox and webkit. @@ -38,6 +42,10 @@ sentryTest('should create spans for multiple fetch requests', async ({ getLocalT }); sentryTest('should attach `sentry-trace` header to multiple fetch requests', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/request/xhr/test.ts b/packages/browser-integration-tests/suites/tracing/request/xhr/test.ts index 39b2a37749b8..c1553e495999 100644 --- a/packages/browser-integration-tests/suites/tracing/request/xhr/test.ts +++ b/packages/browser-integration-tests/suites/tracing/request/xhr/test.ts @@ -3,9 +3,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should create spans for multiple XHR requests', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); @@ -26,6 +30,10 @@ sentryTest('should create spans for multiple XHR requests', async ({ getLocalTes }); sentryTest('should attach `sentry-trace` header to multiple XHR requests', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/utils/generatePlugin.ts b/packages/browser-integration-tests/utils/generatePlugin.ts index 0c37e15b2426..7ca686992bc3 100644 --- a/packages/browser-integration-tests/utils/generatePlugin.ts +++ b/packages/browser-integration-tests/utils/generatePlugin.ts @@ -6,8 +6,9 @@ import type { Compiler } from 'webpack'; const PACKAGES_DIR = '../../packages'; -const tracingOnly = process.env.PW_TRACING_ONLY === 'true'; - +/** + * Possible values: See BUNDLE_PATHS.browser + */ const bundleKey = process.env.PW_BUNDLE; // `esm` and `cjs` builds are modules that can be imported / aliased by webpack @@ -26,16 +27,12 @@ const BUNDLE_PATHS: Record> = { bundle_es6_min: 'build/bundles/bundle.min.js', bundle_replay_es6: 'build/bundles/bundle.replay.js', bundle_replay_es6_min: 'build/bundles/bundle.replay.min.js', - }, - tracing: { - cjs: 'build/npm/cjs/index.js', - esm: 'build/npm/esm/index.js', - bundle_es5: 'build/bundles/bundle.tracing.es5.js', - bundle_es5_min: 'build/bundles/bundle.tracing.es5.min.js', - bundle_es6: 'build/bundles/bundle.tracing.js', - bundle_es6_min: 'build/bundles/bundle.tracing.min.js', - bundle_replay_es6: 'build/bundles/bundle.tracing.replay.js', - bundle_replay_es6_min: 'build/bundles/bundle.tracing.replay.min.js', + bundle_tracing_es5: 'build/bundles/bundle.tracing.es5.js', + bundle_tracing_es5_min: 'build/bundles/bundle.tracing.es5.min.js', + bundle_tracing_es6: 'build/bundles/bundle.tracing.js', + bundle_tracing_es6_min: 'build/bundles/bundle.tracing.min.js', + bundle_tracing_replay_es6: 'build/bundles/bundle.tracing.replay.js', + bundle_tracing_replay_es6_min: 'build/bundles/bundle.tracing.replay.min.js', }, integrations: { cjs: 'build/npm/cjs/index.js', @@ -44,16 +41,12 @@ const BUNDLE_PATHS: Record> = { bundle_es5_min: 'build/bundles/[INTEGRATION_NAME].es5.min.js', bundle_es6: 'build/bundles/[INTEGRATION_NAME].js', bundle_es6_min: 'build/bundles/[INTEGRATION_NAME].min.js', - bundle_replay_es6: 'build/bundles/[INTEGRATION_NAME].js', - bundle_replay_es6_min: 'build/bundles/[INTEGRATION_NAME].min.js', }, wasm: { cjs: 'build/npm/cjs/index.js', esm: 'build/npm/esm/index.js', bundle_es6: 'build/bundles/wasm.js', bundle_es6_min: 'build/bundles/wasm.min.js', - bundle_replay_es6: 'build/bundles/wasm.js', - bundle_replay_es6_min: 'build/bundles/wasm.min.js', }, }; @@ -100,7 +93,6 @@ function generateSentryAlias(): Record { } class SentryScenarioGenerationPlugin { - public requiresTracing: boolean = false; public requiredIntegrations: string[] = []; public requiresWASMIntegration: boolean = false; @@ -114,8 +106,8 @@ class SentryScenarioGenerationPlugin { // To help Webpack resolve Sentry modules in `import` statements in cases where they're provided in bundles rather than in `node_modules` '@sentry/browser': 'Sentry', '@sentry/tracing': 'Sentry', - '@sentry/integrations': 'Sentry.Integrations', '@sentry/replay': 'Sentry', + '@sentry/integrations': 'Sentry.Integrations', '@sentry/wasm': 'Sentry.Integrations', } : {}; @@ -127,9 +119,7 @@ class SentryScenarioGenerationPlugin { parser.hooks.import.tap( this._name, (statement: { specifiers: [{ imported: { name: string } }] }, source: string) => { - if (source === '@sentry/tracing') { - this.requiresTracing = true; - } else if (source === '@sentry/integrations') { + if (source === '@sentry/integrations') { this.requiredIntegrations.push(statement.specifiers[0].imported.name.toLowerCase()); } else if (source === '@sentry/wasm') { this.requiresWASMIntegration = true; @@ -142,10 +132,14 @@ class SentryScenarioGenerationPlugin { compiler.hooks.compilation.tap(this._name, compilation => { HtmlWebpackPlugin.getHooks(compilation).alterAssetTags.tapAsync(this._name, (data, cb) => { if (useBundle && bundleKey) { - const useTracingBundle = tracingOnly || this.requiresTracing; - const bundleName = useTracingBundle ? 'tracing' : 'browser'; + const bundleName = 'browser'; + const bundlePath = BUNDLE_PATHS[bundleName][bundleKey]; + + // Convert e.g. bundle_tracing_es5_min to bundle_es5_min + const integrationBundleKey = bundleKey.replace('_replay', '').replace('_tracing', ''); + const bundleObject = createHtmlTagObject('script', { - src: path.resolve(PACKAGES_DIR, bundleName, BUNDLE_PATHS[bundleName][bundleKey]), + src: path.resolve(PACKAGES_DIR, bundleName, bundlePath), }); this.requiredIntegrations.forEach(integration => { @@ -153,16 +147,16 @@ class SentryScenarioGenerationPlugin { src: path.resolve( PACKAGES_DIR, 'integrations', - BUNDLE_PATHS['integrations'][bundleKey].replace('[INTEGRATION_NAME]', integration), + BUNDLE_PATHS['integrations'][integrationBundleKey].replace('[INTEGRATION_NAME]', integration), ), }); data.assetTags.scripts.unshift(integrationObject); }); - if (this.requiresWASMIntegration && BUNDLE_PATHS['wasm'][bundleKey]) { + if (this.requiresWASMIntegration && BUNDLE_PATHS['wasm'][integrationBundleKey]) { const wasmObject = createHtmlTagObject('script', { - src: path.resolve(PACKAGES_DIR, 'wasm', BUNDLE_PATHS['wasm'][bundleKey]), + src: path.resolve(PACKAGES_DIR, 'wasm', BUNDLE_PATHS['wasm'][integrationBundleKey]), }); data.assetTags.scripts.unshift(wasmObject); diff --git a/packages/browser-integration-tests/utils/helpers.ts b/packages/browser-integration-tests/utils/helpers.ts index 25630ceba2fd..bbdb0c2d0655 100644 --- a/packages/browser-integration-tests/utils/helpers.ts +++ b/packages/browser-integration-tests/utils/helpers.ts @@ -125,6 +125,18 @@ export function waitForErrorRequest(page: Page): Promise { }); } +/** + * We can only test tracing tests in certain bundles/packages: + * - NPM (ESM, CJS) + * - CDN bundles that contain Tracing + * + * @returns `true` if we should skip the tracing test + */ +export function shouldSkipTracingTest(): boolean { + const bundle = process.env.PW_BUNDLE as string | undefined; + return bundle != null && !bundle.includes('tracing') && !bundle.includes('esm') && !bundle.includes('cjs'); +} + /** * Waits until a number of requests matching urlRgx at the given URL arrive. * If the timout option is configured, this function will abort waiting, even if it hasn't reveived the configured diff --git a/packages/browser/package.json b/packages/browser/package.json index 6c04362b76b2..7fff37cdc75f 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -49,12 +49,14 @@ "scripts": { "build": "run-p build:transpile build:bundle build:types", "build:dev": "yarn build", - "build:bundle": "rollup --config rollup.bundle.config.js", + "build:bundle": "run-p build:bundle:es5 build:bundle:es6", + "build:bundle:es5": "JS_VERSION=es5 rollup -c rollup.bundle.config.js", + "build:bundle:es6": "JS_VERSION=es6 rollup -c rollup.bundle.config.js", "build:transpile": "rollup -c rollup.npm.config.js", "build:types": "tsc -p tsconfig.types.json", "build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch", "build:dev:watch": "yarn build:watch", - "build:bundle:watch": "rollup --config rollup.bundle.config.js --watch", + "build:bundle:watch": "rollup -c rollup.bundle.config.js --watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", @@ -66,7 +68,7 @@ "lint": "run-s lint:prettier lint:eslint", "lint:eslint": "eslint . --format stylish", "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", - "validate:es5": "es-check es5 build/bundles/bundle.es5.js", + "validate:es5": "es-check es5 'build/bundles/*.es5*.js'", "size:check": "run-p size:check:es5 size:check:es6", "size:check:es5": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES5: \",$1,\"kB\";}'", "size:check:es6": "cat build/bundles/bundle.es6.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES6: \",$1,\"kB\";}'", diff --git a/packages/browser/rollup.bundle.config.js b/packages/browser/rollup.bundle.config.js index 6ef24dd841a5..3bb87e0c5e7b 100644 --- a/packages/browser/rollup.bundle.config.js +++ b/packages/browser/rollup.bundle.config.js @@ -2,7 +2,13 @@ import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/ind const builds = []; -['es5', 'es6'].forEach(jsVersion => { +const targets = process.env.JS_VERSION ? [process.env.JS_VERSION] : ['es5', 'es6']; + +if (targets.some(target => target !== 'es5' && target !== 'es6')) { + throw new Error('JS_VERSION must be either "es5" or "es6"'); +} + +targets.forEach(jsVersion => { const baseBundleConfig = makeBaseBundleConfig({ bundleType: 'standalone', entrypoints: ['src/index.bundle.ts'], @@ -11,18 +17,39 @@ const builds = []; outputFileBase: () => `bundles/bundle${jsVersion === 'es5' ? '.es5' : ''}`, }); - builds.push(...makeBundleConfigVariants(baseBundleConfig)); -}); + const tracingBaseBundleConfig = makeBaseBundleConfig({ + bundleType: 'standalone', + entrypoints: ['src/index.bundle.tracing.ts'], + jsVersion, + licenseTitle: '@sentry/browser & @sentry/tracing', + outputFileBase: () => `bundles/bundle.tracing${jsVersion === 'es5' ? '.es5' : ''}`, + }); -// Full bundle incl. replay only available for es6 -const replayBaseBundleConfig = makeBaseBundleConfig({ - bundleType: 'standalone', - entrypoints: ['src/index.bundle.replay.ts'], - jsVersion: 'es6', - licenseTitle: '@sentry/browser & @sentry/replay', - outputFileBase: () => 'bundles/bundle.replay', + builds.push(...makeBundleConfigVariants(baseBundleConfig), ...makeBundleConfigVariants(tracingBaseBundleConfig)); }); -builds.push(...makeBundleConfigVariants(replayBaseBundleConfig)); +if (targets.includes('es6')) { + // Replay bundles only available for es6 + const replayBaseBundleConfig = makeBaseBundleConfig({ + bundleType: 'standalone', + entrypoints: ['src/index.bundle.replay.ts'], + jsVersion: 'es6', + licenseTitle: '@sentry/browser & @sentry/replay', + outputFileBase: () => 'bundles/bundle.replay', + }); + + const tracingReplayBaseBundleConfig = makeBaseBundleConfig({ + bundleType: 'standalone', + entrypoints: ['src/index.bundle.tracing.replay.ts'], + jsVersion: 'es6', + licenseTitle: '@sentry/browser & @sentry/tracing & @sentry/replay', + outputFileBase: () => 'bundles/bundle.tracing.replay', + }); + + builds.push( + ...makeBundleConfigVariants(replayBaseBundleConfig), + ...makeBundleConfigVariants(tracingReplayBaseBundleConfig), + ); +} export default builds; diff --git a/packages/browser/src/exports.ts b/packages/browser/src/exports.ts index 7fdd9ba2d5fe..321ebd2c6c51 100644 --- a/packages/browser/src/exports.ts +++ b/packages/browser/src/exports.ts @@ -9,7 +9,6 @@ export type { // eslint-disable-next-line deprecation/deprecation Severity, SeverityLevel, - Span, StackFrame, Stacktrace, Thread, diff --git a/packages/browser/src/index.bundle.replay.ts b/packages/browser/src/index.bundle.replay.ts index 9a220d0ecca9..affadece35da 100644 --- a/packages/browser/src/index.bundle.replay.ts +++ b/packages/browser/src/index.bundle.replay.ts @@ -11,3 +11,4 @@ Sentry.Integrations.BrowserTracing = BrowserTracing; export * from './index.bundle.base'; export { BrowserTracing, addTracingExtensions, Replay }; +// Note: We do not export a shim for `Span` here, as that is quite complex and would blow up the bundle diff --git a/packages/browser/src/index.bundle.tracing.replay.ts b/packages/browser/src/index.bundle.tracing.replay.ts new file mode 100644 index 000000000000..418aeb61bd18 --- /dev/null +++ b/packages/browser/src/index.bundle.tracing.replay.ts @@ -0,0 +1,17 @@ +import { addExtensionMethods, BrowserTracing, Span } from '@sentry-internal/tracing'; +import { Replay } from '@sentry/replay'; + +import * as Sentry from './index.bundle.base'; + +// TODO (v8): Remove this as it was only needed for backwards compatibility +// We want replay to be available under Sentry.Replay, to be consistent +// with the NPM package version. +Sentry.Integrations.Replay = Replay; + +Sentry.Integrations.BrowserTracing = BrowserTracing; + +// We are patching the global object with our hub extension methods +addExtensionMethods(); + +export { Replay, BrowserTracing, Span, addExtensionMethods }; +export * from './index.bundle.base'; diff --git a/packages/tracing/src/index.bundle.ts b/packages/browser/src/index.bundle.tracing.ts similarity index 59% rename from packages/tracing/src/index.bundle.ts rename to packages/browser/src/index.bundle.tracing.ts index 8169e348b0a7..3aa5d960d19a 100644 --- a/packages/tracing/src/index.bundle.ts +++ b/packages/browser/src/index.bundle.tracing.ts @@ -1,5 +1,6 @@ // This is exported so the loader does not fail when switching off Replay import { Replay } from '@sentry-internal/integration-shims'; +import { addExtensionMethods, BrowserTracing, Span } from '@sentry-internal/tracing'; import * as Sentry from './index.bundle.base'; @@ -8,5 +9,10 @@ import * as Sentry from './index.bundle.base'; // with the NPM package version. Sentry.Integrations.Replay = Replay; -export { Replay }; +Sentry.Integrations.BrowserTracing = BrowserTracing; + +// We are patching the global object with our hub extension methods +addExtensionMethods(); + +export { Replay, BrowserTracing, Span, addExtensionMethods }; export * from './index.bundle.base'; diff --git a/packages/browser/src/index.bundle.ts b/packages/browser/src/index.bundle.ts index d16c008e7575..869139e7e591 100644 --- a/packages/browser/src/index.bundle.ts +++ b/packages/browser/src/index.bundle.ts @@ -10,3 +10,4 @@ Sentry.Integrations.BrowserTracing = BrowserTracing; export * from './index.bundle.base'; export { BrowserTracing, addTracingExtensions, Replay }; +// Note: We do not export a shim for `Span` here, as that is quite complex and would blow up the bundle diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index b3c0e7750bd2..75137f210816 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -30,6 +30,7 @@ export { trace, } from '@sentry/core'; export type { SpanStatusType } from '@sentry/core'; +export type { Span } from '@sentry/types'; export { makeBrowserOfflineTransport } from './transports/offline'; export { onProfilingStartRouteTransaction } from './profiling/hubextensions'; export { BrowserProfilingIntegration } from './profiling/integration'; diff --git a/packages/tracing/test/index.bundle.replay.test.ts b/packages/browser/test/unit/index.bundle.tracing.replay.test.ts similarity index 85% rename from packages/tracing/test/index.bundle.replay.test.ts rename to packages/browser/test/unit/index.bundle.tracing.replay.test.ts index b860e6336679..ac951e24445d 100644 --- a/packages/tracing/test/index.bundle.replay.test.ts +++ b/packages/browser/test/unit/index.bundle.tracing.replay.test.ts @@ -1,9 +1,9 @@ import { BrowserTracing } from '@sentry-internal/tracing'; import { Replay } from '@sentry/browser'; -import * as TracingReplayBundle from '../src/index.bundle.replay'; +import * as TracingReplayBundle from '../../src/index.bundle.tracing.replay'; -describe('index.bundle.replay', () => { +describe('index.bundle.tracing.replay', () => { it('has correct exports', () => { Object.keys(TracingReplayBundle.Integrations).forEach(key => { // Skip BrowserTracing because it doesn't have a static id field. diff --git a/packages/tracing/test/index.bundle.test.ts b/packages/browser/test/unit/index.bundle.tracing.test.ts similarity index 87% rename from packages/tracing/test/index.bundle.test.ts rename to packages/browser/test/unit/index.bundle.tracing.test.ts index db1cb7b9f433..1f92a02858ac 100644 --- a/packages/tracing/test/index.bundle.test.ts +++ b/packages/browser/test/unit/index.bundle.tracing.test.ts @@ -1,9 +1,9 @@ import { Replay as ReplayShim } from '@sentry-internal/integration-shims'; import { BrowserTracing } from '@sentry-internal/tracing'; -import * as TracingBundle from '../src/index.bundle'; +import * as TracingBundle from '../../src/index.bundle.tracing'; -describe('index.bundle', () => { +describe('index.bundle.tracing', () => { it('has correct exports', () => { Object.keys(TracingBundle.Integrations).forEach(key => { // Skip BrowserTracing because it doesn't have a static id field. diff --git a/packages/overhead-metrics/test-apps/booking-app/with-replay.html b/packages/overhead-metrics/test-apps/booking-app/with-replay.html index 9c4e0da222a7..7f471cc12c94 100644 --- a/packages/overhead-metrics/test-apps/booking-app/with-replay.html +++ b/packages/overhead-metrics/test-apps/booking-app/with-replay.html @@ -215,7 +215,7 @@

This is a test app.

- + - + - + - +