Skip to content

Commit 3045390

Browse files
authored
feat(browser): Export BrowserTracing from @sentry/browser (#7472)
1 parent 90bd190 commit 3045390

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

packages/browser/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@sentry/replay": "7.43.0",
2121
"@sentry/types": "7.43.0",
2222
"@sentry/utils": "7.43.0",
23+
"@sentry-internal/tracing": "7.43.0",
2324
"tslib": "^1.9.3"
2425
},
2526
"devDependencies": {

packages/browser/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export { INTEGRATIONS as Integrations };
2929
export { Replay } from '@sentry/replay';
3030
// __ROLLUP_EXCLUDE_REPLAY_FROM_BUNDLES_END__
3131

32+
// __ROLLUP_EXCLUDE_BROWSER_TRACING_FROM_BUNDLES_BEGIN__
33+
export { BrowserTracing } from '@sentry-internal/tracing';
34+
// __ROLLUP_EXCLUDE_BROWSER_TRACING_FROM_BUNDLES_END__
35+
3236
// __ROLLUP_EXCLUDE_OFFLINE_FROM_BUNDLES_BEGIN__
3337
export { makeBrowserOfflineTransport } from './transports/offline';
3438
// __ROLLUP_EXCLUDE_OFFLINE_FROM_BUNDLES_END__

packages/tracing-internal/src/browser/browsertracing.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-lines */
22
import type { Hub, IdleTransaction } from '@sentry/core';
3-
import { extractTraceparentData, startIdleTransaction, TRACING_DEFAULTS } from '@sentry/core';
3+
import { addTracingExtensions, extractTraceparentData, startIdleTransaction, TRACING_DEFAULTS } from '@sentry/core';
44
import type { EventProcessor, Integration, Transaction, TransactionContext, TransactionSource } from '@sentry/types';
55
import { baggageHeaderToDynamicSamplingContext, getDomElement, logger } from '@sentry/utils';
66

@@ -172,6 +172,8 @@ export class BrowserTracing implements Integration {
172172
private _collectWebVitals: () => void;
173173

174174
public constructor(_options?: Partial<BrowserTracingOptions>) {
175+
addTracingExtensions();
176+
175177
this.options = {
176178
...DEFAULT_BROWSER_TRACING_OPTIONS,
177179
..._options,

rollup/bundleHelpers.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function makeBaseBundleConfig(options) {
3535
includeReplay,
3636
includeOffline,
3737
includeBrowserProfiling,
38+
includeBrowserTracing,
3839
} = options;
3940

4041
const nodeResolvePlugin = makeNodeResolvePlugin();
@@ -47,6 +48,7 @@ export function makeBaseBundleConfig(options) {
4748
const excludeReplayShimPlugin = makeExcludeBlockPlugin('REPLAY_SHIM');
4849
const excludeOfflineTransport = makeExcludeBlockPlugin('OFFLINE');
4950
const excludeBrowserProfiling = makeExcludeBlockPlugin('BROWSER_PROFILING');
51+
const excludeBrowserTracing = makeExcludeBlockPlugin('BROWSER_TRACING');
5052
const replayShimPlugin = makeReplayShimPlugin();
5153

5254
// The `commonjs` plugin is the `esModuleInterop` of the bundling world. When used with `transformMixedEsModules`, it
@@ -82,6 +84,10 @@ export function makeBaseBundleConfig(options) {
8284
standAloneBundleConfig.plugins.push(excludeBrowserProfiling);
8385
}
8486

87+
if (!includeBrowserTracing) {
88+
standAloneBundleConfig.plugins.push(excludeBrowserTracing);
89+
}
90+
8591
// used by `@sentry/integrations` and `@sentry/wasm` (bundles which need to be combined with a stand-alone SDK bundle)
8692
const addOnBundleConfig = {
8793
// These output settings are designed to mimic an IIFE. We don't use Rollup's `iife` format because we don't want to

0 commit comments

Comments
 (0)