Skip to content

Commit 43e3a69

Browse files
committed
feat(browser): Deprecate BrowserTracing integration
There is a proper replacement for all of them now.
1 parent 300bba4 commit 43e3a69

File tree

14 files changed

+151
-2
lines changed

14 files changed

+151
-2
lines changed

MIGRATION.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,122 @@ npx @sentry/migr8@latest
1010
This will let you select which updates to run, and automatically update your code. Make sure to still review all code
1111
changes!
1212

13+
## Depreacted `BrowserTracing` integration
14+
15+
The `BrowserTracing` integration, together with the custom routing instrumentations passed to it, are deprecated in v8.
16+
Instead, you should use `Sentry.browserTracingIntegration()`.
17+
18+
Package-specific browser tracing integrations are available directly. In most cases, there is a single integration
19+
provided for each package, which will make sure to set up performance tracing correctly for the given SDK. For react, we
20+
provide multiple integrations to cover different router integrations:
21+
22+
### `@sentry/browser`, `@sentry/svelte`, `@sentry/gatsby`
23+
24+
```js
25+
import * as Sentry from '@sentry/browser';
26+
27+
Sentry.init({
28+
integrations: [Sentry.browserTracingIntegration()],
29+
});
30+
```
31+
32+
### `@sentry/react`
33+
34+
```js
35+
import * as Sentry from '@sentry/react';
36+
37+
Sentry.init({
38+
integrations: [
39+
// No react router
40+
Sentry.browserTracingIntegration(),
41+
// OR, if you are using react router, instead use one of the following:
42+
Sentry.reactRouterV6BrowserTracingIntegration({
43+
useEffect,
44+
useLocation,
45+
useNavigationType,
46+
createRoutesFromChildren,
47+
matchRoutes,
48+
stripBasename,
49+
}),
50+
Sentry.reactRouterV5BrowserTracingIntegration({
51+
history,
52+
}),
53+
Sentry.reactRouterV4BrowserTracingIntegration({
54+
history,
55+
}),
56+
Sentry.reactRouterV3BrowserTracingIntegration({
57+
history,
58+
routes,
59+
match,
60+
}),
61+
],
62+
});
63+
```
64+
65+
### `@sentry/vue`
66+
67+
```js
68+
import * as Sentry from '@sentry/vue';
69+
70+
Sentry.init({
71+
integrations: [
72+
Sentry.browserTracingIntegration({
73+
// pass router in, if applicable
74+
router,
75+
}),
76+
],
77+
});
78+
```
79+
80+
### `@sentry/angular` & `@sentry/angular-ivy`
81+
82+
```js
83+
import * as Sentry from '@sentry/angular';
84+
85+
Sentry.init({
86+
integrations: [Sentry.browserTracingIntegration()],
87+
});
88+
89+
// You still need to add the Trace Service like before!
90+
```
91+
92+
### `@sentry/remix`
93+
94+
```js
95+
import * as Sentry from '@sentry/remix';
96+
97+
Sentry.init({
98+
integrations: [
99+
Sentry.browserTracingIntegration({
100+
useEffect,
101+
useLocation,
102+
useMatches,
103+
}),
104+
],
105+
});
106+
```
107+
108+
### `@sentry/nextjs`, `@sentry/astro`, `@sentry/sveltekit`
109+
110+
Browser tracing is automatically set up for you in these packages. If you need to customize the options, you can do it
111+
like this:
112+
113+
```js
114+
import * as Sentry from '@sentry/nextjs';
115+
116+
Sentry.init({
117+
integrations: [
118+
Sentry.browserTracingIntegration({
119+
// add custom options here
120+
}),
121+
],
122+
});
123+
```
124+
125+
### `@sentry/ember`
126+
127+
Browser tracing is automatically set up for you. You can configure it as before through configuration.
128+
13129
## Deprecated `transactionContext` passed to `tracesSampler`
14130

15131
Instead of an `transactionContext` being passed to the `tracesSampler` callback, the callback will directly receive
@@ -43,6 +159,7 @@ The following list shows how integrations should be migrated:
43159

44160
| Old | New | Packages |
45161
| ---------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------- |
162+
| `new BrowserTracing()` | `browserTracingIntegration()` | `@sentry/browser` |
46163
| `new InboundFilters()` | `inboundFiltersIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
47164
| `new FunctionToString()` | `functionToStringIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
48165
| `new LinkedErrors()` | `linkedErrorsIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |

packages/browser/src/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export function bundleBrowserTracingIntegration(
201201
options: Parameters<typeof browserTracingIntegration>[0] = {},
202202
): Integration {
203203
// Migrate some options from the old integration to the new one
204+
// eslint-disable-next-line deprecation/deprecation
204205
const opts: ConstructorParameters<typeof BrowserTracing>[0] = options;
205206

206207
if (typeof options.markBackgroundSpan === 'boolean') {
@@ -215,5 +216,6 @@ export function bundleBrowserTracingIntegration(
215216
opts.startTransactionOnLocationChange = options.instrumentNavigation;
216217
}
217218

219+
// eslint-disable-next-line deprecation/deprecation
218220
return new BrowserTracing(opts);
219221
}

packages/browser/src/index.bundle.feedback.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import * as Sentry from './index.bundle.base';
1414
// eslint-disable-next-line deprecation/deprecation
1515
Sentry.Integrations.Replay = Replay;
1616

17+
// eslint-disable-next-line deprecation/deprecation
1718
Sentry.Integrations.BrowserTracing = BrowserTracing;
1819

1920
export * from './index.bundle.base';
2021
export {
22+
// eslint-disable-next-line deprecation/deprecation
2123
BrowserTracing,
2224
browserTracingIntegration,
2325
addTracingExtensions,

packages/browser/src/index.bundle.replay.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import * as Sentry from './index.bundle.base';
1414
// eslint-disable-next-line deprecation/deprecation
1515
Sentry.Integrations.Replay = Replay;
1616

17+
// eslint-disable-next-line deprecation/deprecation
1718
Sentry.Integrations.BrowserTracing = BrowserTracing;
1819

1920
export * from './index.bundle.base';
2021
export {
22+
// eslint-disable-next-line deprecation/deprecation
2123
BrowserTracing,
2224
browserTracingIntegration,
2325
addTracingExtensions,

packages/browser/src/index.bundle.tracing.replay.feedback.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as Sentry from './index.bundle.base';
1111
// eslint-disable-next-line deprecation/deprecation
1212
Sentry.Integrations.Replay = Replay;
1313

14+
// eslint-disable-next-line deprecation/deprecation
1415
Sentry.Integrations.BrowserTracing = BrowserTracing;
1516

1617
// We are patching the global object with our hub extension methods
@@ -23,6 +24,7 @@ export {
2324
Replay,
2425
feedbackIntegration,
2526
replayIntegration,
27+
// eslint-disable-next-line deprecation/deprecation
2628
BrowserTracing,
2729
browserTracingIntegration,
2830
Span,

packages/browser/src/index.bundle.tracing.replay.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as Sentry from './index.bundle.base';
1111
// eslint-disable-next-line deprecation/deprecation
1212
Sentry.Integrations.Replay = Replay;
1313

14+
// eslint-disable-next-line deprecation/deprecation
1415
Sentry.Integrations.BrowserTracing = BrowserTracing;
1516

1617
// We are patching the global object with our hub extension methods
@@ -23,6 +24,7 @@ export {
2324
Replay,
2425
replayIntegration,
2526
feedbackIntegration,
27+
// eslint-disable-next-line deprecation/deprecation
2628
BrowserTracing,
2729
browserTracingIntegration,
2830
Span,

packages/browser/src/index.bundle.tracing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as Sentry from './index.bundle.base';
1111
// eslint-disable-next-line deprecation/deprecation
1212
Sentry.Integrations.Replay = Replay;
1313

14+
// eslint-disable-next-line deprecation/deprecation
1415
Sentry.Integrations.BrowserTracing = BrowserTracing;
1516

1617
// We are patching the global object with our hub extension methods
@@ -23,6 +24,7 @@ export {
2324
Replay,
2425
feedbackIntegration,
2526
replayIntegration,
27+
// eslint-disable-next-line deprecation/deprecation
2628
BrowserTracing,
2729
browserTracingIntegration,
2830
Span,

packages/browser/src/index.bundle.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import * as Sentry from './index.bundle.base';
1515
// eslint-disable-next-line deprecation/deprecation
1616
Sentry.Integrations.Replay = Replay;
1717

18+
// eslint-disable-next-line deprecation/deprecation
1819
Sentry.Integrations.BrowserTracing = BrowserTracing;
1920

2021
export * from './index.bundle.base';
2122
export {
23+
// eslint-disable-next-line deprecation/deprecation
2224
BrowserTracing,
2325
addTracingExtensions,
2426
// eslint-disable-next-line deprecation/deprecation

packages/browser/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export {
5454
} from '@sentry-internal/feedback';
5555

5656
export {
57+
// eslint-disable-next-line deprecation/deprecation
5758
BrowserTracing,
5859
defaultRequestInstrumentationOptions,
5960
instrumentOutgoingRequests,

packages/integration-shims/src/BrowserTracing.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { consoleSandbox } from '@sentry/utils';
55
* This is a shim for the BrowserTracing integration.
66
* It is needed in order for the CDN bundles to continue working when users add/remove tracing
77
* from it, without changing their config. This is necessary for the loader mechanism.
8+
*
9+
* @deprecated Use `browserTracingIntegration()` instead.
810
*/
911
class BrowserTracingShim implements Integration {
1012
/**
@@ -19,6 +21,7 @@ class BrowserTracingShim implements Integration {
1921

2022
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2123
public constructor(_options: any) {
24+
// eslint-disable-next-line deprecation/deprecation
2225
this.name = BrowserTracingShim.id;
2326

2427
consoleSandbox(() => {
@@ -39,10 +42,15 @@ class BrowserTracingShim implements Integration {
3942
* from it, without changing their config. This is necessary for the loader mechanism.
4043
*/
4144
function browserTracingIntegrationShim(_options: unknown): Integration {
45+
// eslint-disable-next-line deprecation/deprecation
4246
return new BrowserTracingShim({});
4347
}
4448

45-
export { BrowserTracingShim as BrowserTracing, browserTracingIntegrationShim as browserTracingIntegration };
49+
export {
50+
// eslint-disable-next-line deprecation/deprecation
51+
BrowserTracingShim as BrowserTracing,
52+
browserTracingIntegrationShim as browserTracingIntegration,
53+
};
4654

4755
/** Shim function */
4856
export function addTracingExtensions(): void {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ const DEFAULT_BROWSER_TRACING_OPTIONS: BrowserTracingOptions = {
156156
*
157157
* The integration can be configured with a variety of options, and can be extended to use
158158
* any routing library. This integration uses {@see IdleTransaction} to create transactions.
159+
*
160+
* @deprecated Use `browserTracingIntegration()` instead.
159161
*/
160162
export class BrowserTracing implements Integration {
161163
// This class currently doesn't have a static `id` field like the other integration classes, because it prevented

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ export * from '../exports';
22

33
export type { RequestInstrumentationOptions } from './request';
44

5-
export { BrowserTracing, BROWSER_TRACING_INTEGRATION_ID } from './browsertracing';
5+
export {
6+
// eslint-disable-next-line deprecation/deprecation
7+
BrowserTracing,
8+
BROWSER_TRACING_INTEGRATION_ID,
9+
} from './browsertracing';
610
export {
711
browserTracingIntegration,
812
startBrowserTracingNavigationSpan,

packages/tracing-internal/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
export type { LazyLoadedIntegration } from './node';
1414

1515
export {
16+
// eslint-disable-next-line deprecation/deprecation
1617
BrowserTracing,
1718
browserTracingIntegration,
1819
startBrowserTracingNavigationSpan,

packages/tracing/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
* import { BrowserTracing } from '@sentry/browser';
3939
* new BrowserTracing()
4040
*/
41+
// eslint-disable-next-line deprecation/deprecation
4142
export const BrowserTracing = BrowserTracingT;
4243

4344
// BrowserTracing is already exported as part of `Integrations` below (and for the moment will remain so for
@@ -50,6 +51,7 @@ export const BrowserTracing = BrowserTracingT;
5051
* import { BrowserTracing } from '@sentry/browser';
5152
* new BrowserTracing()
5253
*/
54+
// eslint-disable-next-line deprecation/deprecation
5355
export type BrowserTracing = BrowserTracingT;
5456

5557
/**

0 commit comments

Comments
 (0)