diff --git a/packages/browser/package.json b/packages/browser/package.json index fb2a3ccd2a54..a4d9d54bb414 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -20,6 +20,7 @@ "@sentry/replay": "7.43.0", "@sentry/types": "7.43.0", "@sentry/utils": "7.43.0", + "@sentry-internal/tracing": "7.43.0", "tslib": "^1.9.3" }, "devDependencies": { diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index 5714a6f680d6..44f3e11dcfa4 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -29,6 +29,10 @@ export { INTEGRATIONS as Integrations }; export { Replay } from '@sentry/replay'; // __ROLLUP_EXCLUDE_REPLAY_FROM_BUNDLES_END__ +// __ROLLUP_EXCLUDE_BROWSER_TRACING_FROM_BUNDLES_BEGIN__ +export { BrowserTracing } from '@sentry-internal/tracing'; +// __ROLLUP_EXCLUDE_BROWSER_TRACING_FROM_BUNDLES_END__ + // __ROLLUP_EXCLUDE_OFFLINE_FROM_BUNDLES_BEGIN__ export { makeBrowserOfflineTransport } from './transports/offline'; // __ROLLUP_EXCLUDE_OFFLINE_FROM_BUNDLES_END__ diff --git a/packages/tracing-internal/src/browser/browsertracing.ts b/packages/tracing-internal/src/browser/browsertracing.ts index 3575c0a20e91..99ce53dd022b 100644 --- a/packages/tracing-internal/src/browser/browsertracing.ts +++ b/packages/tracing-internal/src/browser/browsertracing.ts @@ -1,6 +1,6 @@ /* eslint-disable max-lines */ import type { Hub, IdleTransaction } from '@sentry/core'; -import { extractTraceparentData, startIdleTransaction, TRACING_DEFAULTS } from '@sentry/core'; +import { addTracingExtensions, extractTraceparentData, startIdleTransaction, TRACING_DEFAULTS } from '@sentry/core'; import type { EventProcessor, Integration, Transaction, TransactionContext, TransactionSource } from '@sentry/types'; import { baggageHeaderToDynamicSamplingContext, getDomElement, logger } from '@sentry/utils'; @@ -172,6 +172,8 @@ export class BrowserTracing implements Integration { private _collectWebVitals: () => void; public constructor(_options?: Partial) { + addTracingExtensions(); + this.options = { ...DEFAULT_BROWSER_TRACING_OPTIONS, ..._options, diff --git a/rollup/bundleHelpers.js b/rollup/bundleHelpers.js index e81069990fa4..6266717aec0b 100644 --- a/rollup/bundleHelpers.js +++ b/rollup/bundleHelpers.js @@ -35,6 +35,7 @@ export function makeBaseBundleConfig(options) { includeReplay, includeOffline, includeBrowserProfiling, + includeBrowserTracing, } = options; const nodeResolvePlugin = makeNodeResolvePlugin(); @@ -47,6 +48,7 @@ export function makeBaseBundleConfig(options) { const excludeReplayShimPlugin = makeExcludeBlockPlugin('REPLAY_SHIM'); const excludeOfflineTransport = makeExcludeBlockPlugin('OFFLINE'); const excludeBrowserProfiling = makeExcludeBlockPlugin('BROWSER_PROFILING'); + const excludeBrowserTracing = makeExcludeBlockPlugin('BROWSER_TRACING'); const replayShimPlugin = makeReplayShimPlugin(); // The `commonjs` plugin is the `esModuleInterop` of the bundling world. When used with `transformMixedEsModules`, it @@ -82,6 +84,10 @@ export function makeBaseBundleConfig(options) { standAloneBundleConfig.plugins.push(excludeBrowserProfiling); } + if (!includeBrowserTracing) { + standAloneBundleConfig.plugins.push(excludeBrowserTracing); + } + // used by `@sentry/integrations` and `@sentry/wasm` (bundles which need to be combined with a stand-alone SDK bundle) const addOnBundleConfig = { // These output settings are designed to mimic an IIFE. We don't use Rollup's `iife` format because we don't want to