Skip to content

Commit ae2f390

Browse files
authored
ref: Update Vue docs for SDK (#2689)
* ref: Update Vue docs for SDK * ref: Update vue docs * ref: Update bundle * ref: Add router example
1 parent d890846 commit ae2f390

File tree

3 files changed

+104
-116
lines changed

3 files changed

+104
-116
lines changed

src/platforms/javascript/guides/vue/index.mdx

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,99 +7,84 @@ redirect_from:
77
description: "Learn how to use Sentry with your Vue application."
88
---
99

10-
To use Sentry with your Vue application, you will need to use Sentry’s browser JavaScript SDK: `@sentry/browser`.
10+
To use Sentry with your Vue application, you will need to use Sentry’s Vue SDK: `@sentry/vue`.
1111

1212
```bash {tabTitle:npm}
13-
npm install --save @sentry/browser @sentry/integrations
13+
npm install --save @sentry/vue
1414
```
1515

1616
```bash {tabTitle:Yarn}
17-
yarn add @sentry/browser @sentry/integrations
17+
yarn add @sentry/vue
1818
```
1919

20-
On its own, `@sentry/browser` will report any uncaught exceptions triggered by your application.
20+
On its own, `@sentry/vue` will report any uncaught exceptions triggered by your application.
2121

22-
Additionally, the Vue _integration_ will capture the name and props state of the active component where the error was thrown. This is reported via Vue’s `config.errorHandler` hook.
22+
Additionally, the SDK will capture the name and props state of the active component where the error was thrown. This is reported via Vue’s `config.errorHandler` hook.
2323

2424
Then add this to your `app.js`:
2525

2626
```javascript
2727
import Vue from "vue";
28-
import * as Sentry from "@sentry/browser";
29-
import { Vue as VueIntegration } from "@sentry/integrations";
28+
import * as Sentry from '@sentry/vue';
3029

3130
Sentry.init({
32-
dsn: "___PUBLIC_DSN___",
33-
integrations: [new VueIntegration({ Vue, attachProps: true })],
31+
Vue: Vue,
32+
dsn: '__PUBLIC_DSN__',
3433
});
3534
```
3635

37-
Additionally, `Integrations.Vue` accepts a few different configuration options that let you change its behavior:
36+
Additionally the SDK accepts a few different configuration options that let you change its behavior:
3837

3938
- Passing in `Vue` is optional, if you do not pass it `window.Vue` must be present.
4039
- Passing in `attachProps` is optional and is `true` if it is not provided. If you set it to `false`, Sentry will suppress sending all Vue components' props for logging.
4140
- Passing in `logErrors` is optional and is `false` if it is not provided. If you set it to `true`, Sentry will call original Vue's `logError` function as well.
4241

4342
<Alert level="warning" title="Vue Error Handling">
4443

45-
Please note that if you enable this integration, Vue will not call its `logError` internally. This means that errors occurring in the Vue renderer will not show up in the developer console.
44+
Please note that if you enable the SDK, Vue will not call its `logError` internally. This means that errors occurring in the Vue renderer will not show up in the developer console.
4645
If you want to preserve this functionality, make sure to pass the `logErrors: true` option.
4746

4847
</Alert>
4948

50-
In case you are using the CDN version or the Loader, we provide a standalone file for every integration, you can use it
51-
like this:
52-
53-
```html
54-
<!-- Note that we now also provide a es6 build only -->
55-
<!-- <script src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/bundle.es6.min.js" integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'bundle.es6.min.js', 'sha384-base64') }}" crossorigin="anonymous"></script> -->
56-
<script
57-
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/bundle.min.js"
58-
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'bundle.min.js', 'sha384-base64') }}"
59-
crossorigin="anonymous"
60-
></script>
61-
62-
<!-- If you include the integration it will be available under Sentry.Integrations.Vue -->
63-
<script
64-
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/vue.min.js"
65-
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'vue.min.js', 'sha384-base64') }}"
66-
crossorigin="anonymous"
67-
></script>
68-
69-
<script>
70-
Sentry.init({
71-
dsn: "___PUBLIC_DSN___",
72-
integrations: [new Sentry.Integrations.Vue({ Vue, attachProps: true })],
73-
});
74-
</script>
75-
```
49+
In case you are using the CDN version or the Loader, we provide a standalone file for every integration, you can use it
50+
like this:
51+
52+
```html
53+
<script
54+
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/vue.min.js"
55+
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'vue.min.js', 'sha384-base64') }}"
56+
crossorigin="anonymous"
57+
></script>
58+
59+
<script>
60+
Sentry.init({
61+
Vue,
62+
dsn: "___PUBLIC_DSN___",
63+
});
64+
</script>
65+
```
7666

7767
## Monitor Performance
7868

7969
```bash {tabTitle:npm}
80-
npm install --save @sentry/browser @sentry/integrations @sentry/tracing
70+
npm install --save @sentry/vue @sentry/tracing
8171
```
8272

8373
```bash {tabTitle:Yarn}
84-
yarn add @sentry/browser @sentry/integrations @sentry/tracing
74+
yarn add @sentry/vue @sentry/tracing
8575
```
8676

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

8979
```js
80+
import Vue from "vue";
9081
import * as Sentry from "@sentry/browser";
91-
import { Vue as VueIntegration } from "@sentry/integrations";
9282
import { Integrations } from "@sentry/tracing";
93-
import Vue from "vue";
9483

9584
Sentry.init({
9685
// ...
9786
integrations: [
9887
new Integrations.BrowserTracing(),
99-
new VueIntegration({
100-
Vue,
101-
tracing: true,
102-
}),
10388
],
10489

10590
// We recommend adjusting this value in production, or using tracesSampler
@@ -111,9 +96,8 @@ Sentry.init({
11196
If you want to track child components, and see more details about the rendering process, configure the integration to track them all:
11297

11398
```js
114-
new VueIntegration({
99+
Sentry.init({
115100
Vue,
116-
tracing: true,
117101
tracingOptions: {
118102
trackComponents: true,
119103
},

src/platforms/javascript/guides/vue/integrations/components.mdx

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,14 @@ Sentry built the new tracing capabilities into the original Vue error handler in
2121
The most basic configuration for tracing your Vue app, which would track only the top-level component, looks like this:
2222

2323
```js
24+
import Vue from "vue";
2425
import * as Sentry from "@sentry/browser";
25-
import { Vue as VueIntegration } from "@sentry/integrations";
2626
import { Integrations } from "@sentry/tracing";
27-
import Vue from "vue";
2827

2928
Sentry.init({
3029
// ...
3130
integrations: [
3231
new Integrations.BrowserTracing(),
33-
new VueIntegration({
34-
Vue,
35-
tracing: true,
36-
}),
3732
],
3833

3934
// We recommend adjusting this value in production, or using tracesSampler
@@ -45,9 +40,8 @@ Sentry.init({
4540
If you want to track child components, and see more details about the rendering process, configure the integration to track them all:
4641

4742
```js
48-
new VueIntegration({
43+
Sentry.init({
4944
Vue,
50-
tracing: true,
5145
tracingOptions: {
5246
trackComponents: true,
5347
},
@@ -57,9 +51,11 @@ new VueIntegration({
5751
Or, you can choose more granularity:
5852

5953
```js
60-
new VueIntegration({
54+
Sentry.init({
6155
Vue,
62-
tracing: true,
56+
integrations: [
57+
new Integrations.BrowserTracing(),
58+
],
6359
tracingOptions: {
6460
trackComponents: [
6561
"App",
@@ -75,9 +71,11 @@ new VueIntegration({
7571
If you want to know if some components are, for example, removed during the initial page load, add a `destroy` hook to the default:
7672

7773
```js
78-
new VueIntegration({
74+
Sentry.init({
7975
Vue,
80-
tracing: true,
76+
integrations: [
77+
new Integrations.BrowserTracing(),
78+
],
8179
tracingOptions: {
8280
trackComponents: [
8381
"App",
@@ -95,9 +93,11 @@ You can specify how long a top-level activity should wait for the last component
9593
Every new rendering cycle is debouncing the timeout, and it starts counting from the beginning. Once the timeout is reached, tracking is completed, and all the information is sent to Sentry.
9694

9795
```js
98-
new VueIntegration({
96+
Sentry.init({
9997
Vue,
100-
tracing: true,
98+
integrations: [
99+
new Integrations.BrowserTracing(),
100+
],
101101
tracingOptions: {
102102
trackComponents: true,
103103
timeout: 4000,
@@ -108,11 +108,6 @@ new VueIntegration({
108108
**Configuration**
109109

110110
```js
111-
/**
112-
* When set to `true`, enables tracking of components lifecycle performance.
113-
* Default: false
114-
*/
115-
tracing: boolean;
116111
tracingOptions: {
117112
/**
118113
* Decides whether to track components by hooking into its lifecycle methods.
@@ -134,3 +129,57 @@ tracingOptions: {
134129
hooks: string[];
135130
}
136131
```
132+
133+
### Using Vue Router
134+
135+
If you are using Vue Router, you can use our provided integration for better transaction names. Here is a full example how to use it:
136+
137+
```js
138+
import Vue from 'vue'
139+
import App from './App'
140+
import * as Sentry from '@sentry/vue'
141+
import { Integrations } from '@sentry/tracing'
142+
import Router from 'vue-router'
143+
import HelloWorld from '@/components/HelloWorld'
144+
145+
Vue.use(Router)
146+
147+
const Foo = { template: '<div>foo</div>' }
148+
const Bar = { template: '<div>bar</div>' }
149+
150+
const router = new Router({
151+
routes: [
152+
{
153+
path: '/',
154+
name: 'HelloWorld',
155+
component: HelloWorld
156+
},
157+
{ path: '/foo/:id', component: Foo },
158+
{ path: '/bar', component: Bar }
159+
]
160+
})
161+
162+
Vue.config.productionTip = false
163+
164+
Sentry.init({
165+
Vue: Vue,
166+
dsn: '___PUBLIC_DSN___',
167+
tracesSampleRate: 1.0,
168+
integrations: [
169+
new Integrations.BrowserTracing({
170+
routingInstrumentation: Sentry.vueRouterInstrumentation(router)
171+
})
172+
],
173+
tracingOptions: {
174+
trackComponents: true
175+
}
176+
})
177+
178+
/* eslint-disable no-new */
179+
new Vue({
180+
el: '#app',
181+
router,
182+
components: { App },
183+
template: '<App/>'
184+
})
185+
```

src/wizard/javascript/vue.md

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ type: framework
99

1010
To begin collecting error and performance data from your Vue application, you'll need the following packages:
1111

12-
* `@sentry/browser` (Sentry's core browser SDK)
13-
* `@sentry/integrations` (contains Sentry's Vue integration)
12+
* `@sentry/vue` (Sentry's Vue SDK)
1413
* `@sentry/tracing` (instruments performance data)
1514

1615
Below are instructions for using your favorite package manager, or alternatively loaded directly from our CDN.
@@ -21,27 +20,23 @@ Install the dependencies:
2120

2221
```bash
2322
# Using yarn
24-
yarn add @sentry/browser @sentry/integrations @sentry/tracing
23+
yarn add @sentry/vue @sentry/tracing
2524

2625
# Using npm
27-
npm install --save @sentry/browser @sentry/integrations @sentry/tracing
26+
npm install --save @sentry/vue @sentry/tracing
2827
```
2928

3029
Next, initialize Sentry in your app entry point before you initialize your root component.
3130

3231
```javascript
3332
import Vue from "vue";
3433
import * as Sentry from "@sentry/browser";
35-
import { Vue as VueIntegration } from "@sentry/integrations";
3634
import { Integrations } from "@sentry/tracing";
3735

3836
Sentry.init({
37+
Vue,
3938
dsn: "___PUBLIC_DSN___",
4039
integrations: [
41-
new VueIntegration({
42-
Vue,
43-
tracing: true,
44-
}),
4540
new Integrations.BrowserTracing(),
4641
],
4742

@@ -51,49 +46,9 @@ Sentry.init({
5146
});
5247
```
5348

54-
### Using our CDN
55-
56-
Alternatively, you can load these packages directly from our CDN using two script tags:
57-
58-
```html
59-
<script
60-
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/bundle.tracing.min.js"
61-
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'bundle.tracing.min.js', 'sha384-base64') }}"
62-
crossorigin="anonymous"
63-
></script>
64-
<script
65-
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/vue.min.js"
66-
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'vue.min.js', 'sha384-base64') }}"
67-
crossorigin="anonymous"
68-
></script>
69-
```
70-
71-
If you load the Sentry packages this way, they are available under the `Sentry` namespace on the global scope.
72-
73-
Next, initialize Sentry in your `app.js`:
74-
75-
```javascript
76-
Sentry.init({
77-
dsn: "___PUBLIC_DSN___",
78-
integrations: [
79-
new Sentry.Integrations.Vue({
80-
Vue,
81-
tracing: true,
82-
}),
83-
new Sentry.Integrations.BrowserTracing(),
84-
],
85-
86-
// We recommend adjusting this value in production, or using tracesSampler
87-
// for finer control
88-
tracesSampleRate: 1.0,
89-
});
90-
```
91-
92-
After this, Sentry will automatically catch and report any uncaught exceptions, and report on the performance of your application.
93-
9449
### Additional Options
9550

96-
Additionally, `Integrations.Vue` accepts a few different configuration options that let you change its behavior:
51+
Additionally, the SDK accepts a few different configuration options that let you change its behavior:
9752

9853
- Passing in `Vue` is optional, but if you do not pass it `window.Vue` must be present.
9954
- Passing in `attachProps` is optional and is `true` if it is not provided. If you set it to `false`, Sentry will suppress sending all Vue components' props for logging.

0 commit comments

Comments
 (0)