Skip to content

Commit cfb86d2

Browse files
authored
Update BrowserTracing import for tree shaking (#4474)
In getsentry/sentry-javascript#4204 we updated the `BrowserTracing` import in the JS SDK to be exported individually. We want users to use this individual import so that the other integrations are treeshaken. This patch updates our documentation to import `BrowserTracing` directly from `@sentry/tracing` instead of through the `Integrations` object, which hopefully should lead to a bundle size reduction for people.
1 parent 2c50eb4 commit cfb86d2

File tree

30 files changed

+74
-75
lines changed

30 files changed

+74
-75
lines changed

src/includes/getting-started-config/javascript.angular.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Once this is done, Sentry's Angular SDK captures all unhandled exceptions and tr
44
import { enableProdMode } from "@angular/core";
55
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
66
import * as Sentry from "@sentry/angular";
7-
import { Integrations } from "@sentry/tracing";
7+
import { BrowserTracing } from "@sentry/tracing";
88
import { AppModule } from "./app/app.module";
99

1010
Sentry.init({
@@ -13,7 +13,7 @@ Sentry.init({
1313
// Registers and configures the Tracing integration,
1414
// which automatically instruments your application to monitor its
1515
// performance, including custom Angular routing instrumentation
16-
new Integrations.BrowserTracing({
16+
new BrowserTracing({
1717
tracingOrigins: ["localhost", "https://yourserver.io/api"],
1818
routingInstrumentation: Sentry.routingInstrumentation,
1919
}),

src/includes/getting-started-config/javascript.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Once this is done, Sentry's JavaScript SDK captures all unhandled exceptions and
22

33
```javascript {tabTitle: ESM}
44
import * as Sentry from "@sentry/browser";
5-
import { Integrations } from "@sentry/tracing";
5+
import { BrowserTracing } from "@sentry/tracing";
66

77
Sentry.init({
88
dsn: "___PUBLIC_DSN___",
99

1010
// Alternatively, use `process.env.npm_package_version` for a dynamic release version
1111
// if your build tool supports it.
1212
release: "[email protected]",
13-
integrations: [new Integrations.BrowserTracing()],
13+
integrations: [new BrowserTracing()],
1414

1515
// Set tracesSampleRate to 1.0 to capture 100%
1616
// of transactions for performance monitoring.

src/includes/getting-started-config/javascript.react.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import React from "react";
33
import ReactDOM from "react-dom";
44
import * as Sentry from "@sentry/react";
5-
import { Integrations } from "@sentry/tracing";
5+
import { BrowserTracing } from "@sentry/tracing";
66
import App from "./App";
77

88
Sentry.init({
99
dsn: "___PUBLIC_DSN___",
10-
integrations: [new Integrations.BrowserTracing()],
10+
integrations: [new BrowserTracing()],
1111

1212
// We recommend adjusting this value in production, or using tracesSampler
1313
// for finer control

src/includes/getting-started-config/javascript.vue.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ To initialize Sentry in your Vue application, add this to your `app.js`:
66
import Vue from "vue";
77
import Router from "vue-router";
88
import * as Sentry from "@sentry/vue";
9-
import { Integrations } from "@sentry/tracing";
9+
import { BrowserTracing } from "@sentry/tracing";
1010

1111
Vue.use(Router);
1212

@@ -18,7 +18,7 @@ Sentry.init({
1818
Vue,
1919
dsn: "___PUBLIC_DSN___",
2020
integrations: [
21-
new Integrations.BrowserTracing({
21+
new BrowserTracing({
2222
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
2323
tracingOrigins: ["localhost", "my-site-url.com", /^\//],
2424
}),
@@ -43,7 +43,7 @@ new Vue({
4343
import { createApp } from "vue";
4444
import { createRouter } from "vue-router";
4545
import * as Sentry from "@sentry/vue";
46-
import { Integrations } from "@sentry/tracing";
46+
import { BrowserTracing } from "@sentry/tracing";
4747

4848
const app = createApp({
4949
// ...
@@ -56,7 +56,7 @@ Sentry.init({
5656
app,
5757
dsn: "___PUBLIC_DSN___",
5858
integrations: [
59-
new Integrations.BrowserTracing({
59+
new BrowserTracing({
6060
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
6161
tracingOrigins: ["localhost", "my-site-url.com", /^\//],
6262
}),

src/includes/performance/beforeNavigate-example/javascript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ One common use case is parameterizing transaction names. For both `pageload` and
44
Sentry.init({
55
// ...
66
integrations: [
7-
new Integrations.BrowserTracing({
7+
new BrowserTracing({
88
beforeNavigate: context => {
99
return {
1010
...context,

src/includes/performance/beforeNavigate-example/javascript.nextjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Sentry.init({
33
// ...
44
integrations: [
5-
new Sentry.Integrations.BrowserTracing({
5+
new BrowserTracing({
66
beforeNavigate: context => {
77
return {
88
...context,

src/includes/performance/configure-sample-rate/javascript.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as Sentry from "@sentry/browser";
55

66
// If taking advantage of automatic instrumentation (highly recommended)
7-
import { Integrations as TracingIntegrations } from "@sentry/tracing";
7+
import { BrowserTracing } from "@sentry/tracing";
88
// Or, if only manually tracing
99
// import * as _ from "@sentry/tracing"
1010
// Note: You MUST import the package in some way for tracing to work
@@ -14,7 +14,7 @@ Sentry.init({
1414

1515
// This enables automatic instrumentation (highly recommended), but is not
1616
// necessary for purely manual usage
17-
integrations: [new TracingIntegrations.BrowserTracing()],
17+
integrations: [new BrowserTracing()],
1818

1919
// To set a uniform sample rate
2020
tracesSampleRate: 0.2
@@ -30,7 +30,7 @@ Sentry.init({
3030

3131
// This enables automatic instrumentation (highly recommended), but is not
3232
// necessary for purely manual usage
33-
integrations: [new Sentry.Integrations.BrowserTracing()],
33+
integrations: [new Sentry.BrowserTracing()],
3434

3535
// To set a uniform sample rate
3636
tracesSampleRate: 0.2

src/includes/performance/configure-sample-rate/javascript.react.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as Sentry from "@sentry/react";
33

44
// If taking advantage of automatic instrumentation (highly recommended)
5-
import { Integrations as TracingIntegrations } from "@sentry/tracing";
5+
import { BrowserTracing } from "@sentry/tracing";
66
// Or, if only manually tracing
77
// import * as _ from "@sentry/tracing"
88
// Note: You MUST import the package in some way for tracing to work
@@ -12,12 +12,12 @@ Sentry.init({
1212

1313
// This enables automatic instrumentation (highly recommended), but is not
1414
// necessary for purely manual usage
15-
integrations: [new TracingIntegrations.BrowserTracing()],
15+
integrations: [new BrowserTracing()],
1616

1717
// To set a uniform sample rate
1818
tracesSampleRate: 0.2
1919

2020
// Alternatively, to control sampling dynamically
2121
tracesSampler: samplingContext => { ... }
2222
});
23-
```
23+
```

src/includes/performance/configure-sample-rate/javascript.vue.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Vue from "vue";
33
import * as Sentry from "@sentry/vue";
44

55
// If taking advantage of automatic instrumentation (highly recommended)
6-
import { Integrations } from "@sentry/tracing";
6+
import { BrowserTracing } from "@sentry/tracing";
77
// Or, if only manually tracing
88
// import * as _ from "@sentry/tracing"
99
// Note: You MUST import the package in some way for tracing to work
@@ -15,7 +15,7 @@ Sentry.init({
1515

1616
// This enables automatic instrumentation (highly recommended), but is not
1717
// necessary for purely manual usage
18-
integrations: [new Integrations.BrowserTracing()],
18+
integrations: [new BrowserTracing],
1919

2020
// To set a uniform sample rate
2121
tracesSampleRate: 0.2
@@ -31,7 +31,7 @@ Sentry.init({
3131

3232
// This enables automatic instrumentation (highly recommended), but is not
3333
// necessary for purely manual usage
34-
integrations: [new Sentry.Integrations.BrowserTracing()],
34+
integrations: [new Sentry.BrowserTracing()],
3535

3636
// To set a uniform sample rate
3737
tracesSampleRate: 0.2

src/includes/performance/enable-automatic-instrumentation/javascript.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ After configuration, you will see both `pageload` and `navigation` transactions
66
// If you're using one of our integration packages, like `@sentry/angular`,
77
// substitute its name for `@sentry/browser` here
88
import * as Sentry from "@sentry/browser";
9-
import { Integrations as TracingIntegrations } from "@sentry/tracing"; // Must import second
9+
import { BrowserTracing } from "@sentry/tracing"; // Must import second
1010

1111
Sentry.init({
1212
dsn: "___PUBLIC_DSN___",
1313

1414
integrations: [
15-
new TracingIntegrations.BrowserTracing({
15+
new BrowserTracing({
1616
tracingOrigins: ["localhost", "my-site-url.com", /^\//],
1717
// ... other options
1818
}),
@@ -29,7 +29,7 @@ Sentry.init({
2929
dsn: "___PUBLIC_DSN___",
3030

3131
integrations: [
32-
new Sentry.Integrations.BrowserTracing({
32+
new Sentry.BrowserTracing({
3333
tracingOrigins: ["localhost", "my-site-url.com", /^\//],
3434
// ... other options
3535
}),

src/includes/performance/enable-automatic-instrumentation/javascript.react.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import { Router } from 'react-router-dom';
77
import { createBrowserHistory } from 'history';
88

99
import * as Sentry from "@sentry/react";
10-
import { Integrations as TracingIntegrations } from "@sentry/tracing"; // Must import after @sentry/react
10+
import { BrowserTracing } from "@sentry/tracing"; // Must import after @sentry/react
1111

1212
const history = createBrowserHistory();
1313

1414
Sentry.init({
1515
dsn: "___PUBLIC_DSN___",
1616

1717
integrations: [
18-
new Integrations.BrowserTracing({
18+
new BrowserTracing({
1919
tracingOrigins: ["localhost", "my-site-url.com", /^\//],
2020

2121
// Can also use reactRouterV3Instrumentation or reactRouterV4Instrumentation

src/includes/performance/filter-span-example/javascript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Sentry.init({
33
// ...
44
integrations: [
5-
new Integrations.BrowserTracing({
5+
new BrowserTracing({
66
shouldCreateSpanForRequest: url => {
77
// Do not create spans for outgoing requests to a `/health/` endpoint
88
return !url.match(/\/health\/?$/);

src/includes/performance/filter-span-example/javascript.nextjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Sentry.init({
33
// ...
44
integrations: [
5-
new Sentry.Integrations.BrowserTracing({
5+
new BrowserTracing({
66
shouldCreateSpanForRequest: url => {
77
// Do not create spans for outgoing requests to a `/health/` endpoint
88
return !url.match(/\/health\/?$/);

src/includes/performance/group-transaction-example/javascript.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ For browser JavaScript applications using the `BrowserTracing` integration, the
1515

1616
```javascript
1717
import * as Sentry from "@sentry/browser";
18-
import { Integrations } from "@sentry/tracing";
18+
import { BrowserTracing } from "@sentry/tracing";
1919

2020
Sentry.init({
2121
// ...
2222
integrations: [
23-
new Integrations.BrowserTracing({
23+
new BrowserTracing({
2424
beforeNavigate: context => {
2525
return {
2626
...context,

src/includes/performance/tracingOrigins-example/javascript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For example:
1010
Sentry.init({
1111
// ...
1212
integrations: [
13-
new Integrations.BrowserTracing({
13+
new BrowserTracing({
1414
tracingOrigins: ["api.example.com"],
1515
}),
1616
],

src/includes/performance/tracingOrigins-example/javascript.nextjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For example:
1010
Sentry.init({
1111
// ...
1212
integrations: [
13-
new Sentry.Integrations.BrowserTracing({
13+
new Sentry.BrowserTracing({
1414
tracingOrigins: ["api.example.com"],
1515
}),
1616
],

src/platforms/javascript/common/configuration/integrations/custom.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ redirect_from:
99
Add a custom integration to your JavaScript using the following format:
1010

1111
```javascript
12-
// All integration that come with an SDK can be found on Sentry.Integrations object
13-
// Custom integration must conform Integration interface: https://github.com/getsentry/sentry-javascript/blob/master/packages/types/src/integration.ts
12+
// All integrations that come with an SDK can be found on Sentry.Integrations object
13+
// Custom integration must conform to the Integration interface: https://github.com/getsentry/sentry-javascript/blob/master/packages/types/src/integration.ts
1414

1515
Sentry.init({
1616
// ...

src/platforms/javascript/common/install/cdn.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Sentry.init({
4343
dsn: "___PUBLIC_DSN___",
4444
// this assumes your build process sets "npm_package_version" in the env
4545
release: "my-project-name@" + process.env.npm_package_version,
46-
integrations: [new Sentry.Integrations.BrowserTracing()],
46+
integrations: [new Sentry.BrowserTracing()],
4747

4848
// We recommend adjusting this value in production, or using tracesSampler
4949
// for finer control

src/platforms/javascript/common/performance/instrumentation/automatic-instrumentation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Sentry.init({
3737
dsn: "___PUBLIC_DSN___",
3838

3939
integrations: [
40-
new Sentry.Integrations.BrowserTracing({
40+
new Sentry.BrowserTracing({
4141
// custom options
4242
}),
4343
],

src/platforms/javascript/guides/react/configuration/integrations/react-router.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import { Router } from 'react-router-dom';
2626
import { createBrowserHistory } from 'history';
2727

2828
import * as Sentry from '@sentry/react';
29-
import { Integrations } from '@sentry/tracing';
29+
import { BrowserTracing } from '@sentry/tracing';
3030

3131
const history = createBrowserHistory();
3232

3333
Sentry.init({
3434
integrations: [
35-
new Integrations.BrowserTracing({
35+
new BrowserTracing({
3636
// Can also use reactRouterV3Instrumentation or reactRouterV4Instrumentation
3737
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),
3838
}),
@@ -71,7 +71,7 @@ import { Route, Router, Switch, matchPath } from 'react-router-dom';
7171
import { createBrowserHistory } from 'history';
7272

7373
import * as Sentry from '@sentry/react';
74-
import { Integrations } from '@sentry/tracing';
74+
import { BrowserTracing } from '@sentry/tracing';
7575

7676
const history = createBrowserHistory();
7777

@@ -81,7 +81,7 @@ const routes = [{ path: '/users/:userid' }, { path: '/users' }, { path: '/' }];
8181

8282
Sentry.init({
8383
integrations: [
84-
new Integrations.BrowserTracing({
84+
new BrowserTracing({
8585
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history, routes, matchPath),
8686
}),
8787
],
@@ -114,7 +114,7 @@ import {Route, Router, Switch } from 'react-router-dom';
114114
import { createBrowserHistory } from 'history';
115115

116116
import * as Sentry from '@sentry/react';
117-
import { Integrations } from '@sentry/tracing';
117+
import { BrowserTracing } from '@sentry/tracing';
118118

119119
// Create Custom Sentry Route component
120120
const SentryRoute = Sentry.withSentryRouting(Route);
@@ -123,7 +123,7 @@ const history = createBrowserHistory();
123123

124124
Sentry.init({
125125
integrations: [
126-
new Integrations.BrowserTracing({
126+
new BrowserTracing({
127127
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),
128128
}),
129129
],
@@ -154,7 +154,7 @@ To use the router integration, import and set a custom routing instrumentation a
154154
import * as Router from "react-router";
155155

156156
import * as Sentry from "@sentry/react";
157-
import { Integrations } from "@sentry/tracing";
157+
import { BrowserTracing } from "@sentry/tracing";
158158

159159
// Routes looks like this:
160160
const routes = (
@@ -168,7 +168,7 @@ const routes = (
168168

169169
Sentry.init({
170170
integrations: [
171-
new Integrations.BrowserTracing({
171+
new BrowserTracing({
172172
routingInstrumentation: Sentry.reactRouterV3Instrumentation(
173173
Router.browserHistory,
174174
// Must be Plain Routes.

0 commit comments

Comments
 (0)