Skip to content

Commit dab5ebf

Browse files
committed
Update BrowserTracing import for tree shaking
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 77bc884 commit dab5ebf

File tree

22 files changed

+58
-59
lines changed

22 files changed

+58
-59
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: 2 additions & 2 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

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: 2 additions & 2 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

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

Lines changed: 2 additions & 2 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
}),

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/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.

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,27 @@ redirect_from:
88
The Vue Tracing Integration allows you to track rendering performance during an initial application load.
99

1010
Sentry uses mixins functionality to provide access to a Vue component during its life cycle stages.
11-
When Sentry encounters a component named `root`, which is a top-level Vue instance (as in `new Vue({})`), we use our BrowserTracing integration,
12-
and create a new span named `Vue Application Render`. Once the `Vue Application Render` span has been created, it will wait until all of its child components render before marking the span as finished.
11+
When Sentry encounters a component named `root`, which is a top-level Vue instance (as in `new Vue({})`), we use our `BrowserTracing` integration, and create a new span named `Vue Application Render`. Once the `Vue Application Render` span has been created, it will wait until all of its child components render before marking the span as finished.
1312

1413
The described instrumentation functionality will give you very high-level information about the rendering performance of the Vue instance. However, the integration can also provide more fine-grained details about what actually happened during a specific activity.
1514
To do that, you need to specify which components to track and what hooks to listen to (you can find a list of all available hooks [here](https://vuejs.org/v2/api/#Options-Lifecycle-Hooks)). You can also turn on tracking for all the components. However, it may be rather noisy if your app consists of hundreds of components. We encourage being more specific. If you don't provide hooks, Sentry will track a component's `mount` and `update` hooks.
1615

1716
Note that when specifying hooks we use the simple verb rather than `before` and `-ed` pairs. For example, `destroy` is correct. `beforeDestroy` and `destroyed` are incorrect.
1817

19-
To set up the Vue Tracing Integration, you will first need to configure the BrowserTracing integration itself. For details on how to do this, check out our [Performance documentation](/platforms/javascript/guides/vue/performance/).
20-
Once you've configured the BrowserTracing integration, move on to configuring the Vue integration itself.
18+
To set up the Vue Tracing Integration, you will first need to configure the `BrowserTracing` integration itself. For details on how to do this, check out our [Performance documentation](/platforms/javascript/guides/vue/performance/).
19+
Once you've configured the `BrowserTracing` integration, move on to configuring the Vue integration itself.
2120
Sentry built the new tracing capabilities into the original Vue error handler integrations, so there is no need to add any new packages. You only need to provide an appropriate configuration.
2221

2322
The most basic configuration for tracing your Vue app, which would track only the top-level component, looks like this:
2423

2524
```javascript
2625
import Vue from "vue";
2726
import * as Sentry from "@sentry/browser";
28-
import { Integrations } from "@sentry/tracing";
27+
import { BrowserTracing } from "@sentry/tracing";
2928

3029
Sentry.init({
3130
// ...
32-
integrations: [new Integrations.BrowserTracing()],
31+
integrations: [new BrowserTracing()],
3332

3433
// We recommend adjusting this value in production, or using tracesSampler
3534
// for finer control
@@ -51,7 +50,7 @@ Or, you can choose more granularity:
5150
```javascript
5251
Sentry.init({
5352
Vue,
54-
integrations: [new Integrations.BrowserTracing()],
53+
integrations: [new BrowserTracing()],
5554
trackComponents: [
5655
"App",
5756
"RwvHeader",
@@ -67,7 +66,7 @@ If you want to know if some components are, for example, removed during the init
6766
```javascript
6867
Sentry.init({
6968
Vue,
70-
integrations: [new Integrations.BrowserTracing()],
69+
integrations: [new BrowserTracing()],
7170
trackComponents: [
7271
"App",
7372
"RwvHeader",
@@ -85,7 +84,7 @@ Every new rendering cycle is debouncing the timeout, and it starts counting from
8584
```javascript
8685
Sentry.init({
8786
Vue,
88-
integrations: [new Integrations.BrowserTracing()],
87+
integrations: [new BrowserTracing()],
8988
trackComponents: true,
9089
timeout: 4000,
9190
});
@@ -152,7 +151,7 @@ Sentry.init({
152151
dsn: "___PUBLIC_DSN___",
153152
tracesSampleRate: 1.0,
154153
integrations: [
155-
new Integrations.BrowserTracing({
154+
new BrowserTracing({
156155
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
157156
}),
158157
],

src/wizard/javascript/angular.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ You should `init` the Sentry browser SDK as soon as possible during your applica
2323
import { enableProdMode } from "@angular/core";
2424
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
2525
import * as Sentry from "@sentry/angular";
26-
import { Integrations } from "@sentry/tracing";
26+
import { BrowserTracing } from "@sentry/tracing";
2727

2828
import { AppModule } from "./app/app.module";
2929

3030
Sentry.init({
3131
dsn: "___PUBLIC_DSN___",
3232
integrations: [
33-
new Integrations.BrowserTracing({
33+
new BrowserTracing({
3434
tracingOrigins: ["localhost", "https://yourserver.io/api"],
3535
routingInstrumentation: Sentry.routingInstrumentation,
3636
}),

src/wizard/javascript/angularjs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ npm install --save @sentry/browser @sentry/integrations
2222
```javascript
2323
import angular from "angular";
2424
import * as Sentry from "@sentry/browser";
25-
import { Integrations } from "@sentry/tracing";
25+
import { BrowserTracing } from "@sentry/tracing";
2626
import { Angular as AngularIntegration } from "@sentry/integrations";
2727

2828
Sentry.init({
2929
dsn: "___PUBLIC_DSN___",
3030
integrations: [
3131
new AngularIntegration(),
32-
new Integrations.BrowserTracing({
32+
new BrowserTracing({
3333
tracingOrigins: ["localhost", "https://yourserver.io/api"],
3434
}),
3535
],

0 commit comments

Comments
 (0)