Skip to content

Commit af002e0

Browse files
author
Luca Forstner
committed
Instruct to use the recommended way of using Vue component tracking
1 parent 172c64b commit af002e0

File tree

3 files changed

+101
-114
lines changed

3 files changed

+101
-114
lines changed

docs/platforms/javascript/guides/nuxt/features/component-tracking.mdx

Lines changed: 48 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Learn how to monitor the rendering performance of your application
44
sidebar_order: 10
55
---
66

7-
Sentry's Nuxt SDK has a component-tracking feature that lets you monitor the performance of your Vue components. Enabling this feature provides you with spans in your transactions that represent the component lifecycle events and durations. This allows you to get a drilled-down view into how your components are behaving so you can do things like identify slow initializations or frequent updates, which might be impacting your app's performance.
7+
Sentry's Nuxt SDK offers a feature to monitor the performance of your Vue components: component tracking. Enabling this feature provides you with spans in your transactions that represent the component lifecycle events and durations. This allows you to get a drilled-down view into how your components are behaving so you can do things like identify slow initializations or frequent updates, which might be impacting your app's performance.
88

99
## Usage
1010

@@ -18,87 +18,78 @@ To set up component tracking, you need to first configure performance monitoring
1818

1919
By default, the Nuxt SDK tracks the rendering performance of your app (that is, its root component) on the initial page load. This operation is represented in the page load transaction by the **`ui.vue.render`** span.
2020

21-
### Child Components
21+
### Child Component Tracking
2222

2323
You can also track your app's child components to get more details about the rendering process. This feature will create spans for each tracked component instance. The spans are called **`ui.vue.[hook]`** where `[hook]` is replaced by each tracked lifecycle stage. For example, the span representing the mount stage (the time between `beforeMount` and `mounted`) is called `ui.vue.mount`.
2424

25-
To set it up, add [`trackComponents`](#trackcomponents) in your `Sentry.init` call. You can also optionally add [`hooks`](#hooks), and [`timeout`](#timeout).
25+
To set it up, add the Vue Integration to your `Sentry.init()` call and, set the `tracingOptions.trackComponents` option.
26+
Set the `trackComponent` option to `true` to track all of your child components, or specify a list of individual comopnents you want to track:
2627

27-
#### `trackComponents`
28+
```javascript {5-17}
29+
import * as Sentry from "@sentry/nuxt";
2830

29-
This is the main option that controls which child components should be tracked. Set it to `true` to track all of them or specify a list of individual components you want to track:
30-
31-
```javascript
3231
Sentry.init({
33-
// ...
34-
trackComponents: true,
35-
// OR
36-
trackComponents: [
37-
"App",
38-
"RwvHeader",
39-
"RwvFooter",
40-
"RwvArticleList",
41-
"Pagination",
32+
integrations: [
33+
Sentry.vueIntegration({
34+
tracingOptions: {
35+
trackComponents: true,
36+
// OR
37+
trackComponents: [
38+
"App",
39+
"RwvHeader",
40+
"RwvFooter",
41+
"RwvArticleList",
42+
"Pagination",
43+
],
44+
},
45+
}),
4246
],
4347
});
4448
```
4549

46-
The default is `false`.
50+
The default value for `trackComponents` is `false`.
51+
52+
#### Track Specific Component Lifecycle Hooks
4753

48-
#### `hooks`
54+
You can control which lifecycle hooks should be tracked. This is helpful if, for example, you want to know if some components are removed during the initial page load, in which case you can configure the integration to also track `unmount` hooks:
4955

50-
Control which lifecycle hooks should be tracked. This is helpful if, for example, you want to know if some components are removed during the initial page load, in which case you can add an `unmount` hook to the default:
56+
```javascript {8}
57+
import * as Sentry from "@sentry/nuxt";
5158

52-
```javascript
5359
Sentry.init({
54-
// ...
60+
integrations: [
61+
Sentry.vueIntegration({
62+
tracingOptions: {
5563
trackComponents: true
5664
hooks: ["mount", "update", "unmount"],
65+
},
66+
}),
67+
],
5768
});
5869
```
5970

60-
The following hooks are available to track in Vue 3: `['activate', 'create', 'unmount', 'mount', 'update']`
61-
62-
Note, that when specifying `hooks`, we use the simple verb rather than `before` and `-ed` pairs. For example, `unmount` is correct, while `beforeUnmount` and `unmounted` are incorrect.
71+
The following hooks are available to track: `['activate', 'create', 'unmount', 'mount', 'update']`
6372

64-
<Alert>
65-
66-
If you're using Vue 2, use `destroy` instead of `unmount`. But in Vue 3 `destroy` doesn't work because the names of the lifecycle hooks themselves [changed](https://v3-migration.vuejs.org/breaking-changes/#other-minor-changes).
67-
68-
</Alert>
73+
Note that when specifying `hooks`, we use the simple verb rather than `before` and `-ed` pairs. For example, `unmount` is correct, while `beforeUnmount` and `unmounted` are incorrect.
6974

70-
The default set of hooks is `['activate', 'mount', 'update']`.
75+
#### Configure a Timeout for Component Tracking
7176

72-
#### `timeout`
77+
You can specify how long the root rendering span should wait for the last component to render by configuring the `timeout` option in milliseconds.
78+
Every new rendering cycle debounces the timeout, and it starts counting from the beginning. Once the timeout is reached, tracking is completed, and all the rendering information is sent to Sentry:
7379

74-
You can specify how long the root rendering span should wait until the last component is rendered.
75-
Every new rendering cycle debounces the timeout and it starts counting from the beginning. Once the timeout is reached, tracking is completed and all the rendering information is sent to Sentry:
80+
```javascript {8}
81+
import * as Sentry from "@sentry/nuxt";
7682

77-
```javascript
7883
Sentry.init({
79-
// ...
80-
trackComponents: true,
81-
timeout: 500,
84+
integrations: [
85+
Sentry.vueIntegration({
86+
tracingOptions: {
87+
trackComponents: true,
88+
timeout: 500, // milliseconds
89+
},
90+
}),
91+
],
8292
});
8393
```
8494

85-
The default is `2000`.
86-
87-
#### Alternative Configuration With `tracingOptions`
88-
89-
You can also group the component-tracking options by using the optional `tracingOptions` property in `Sentry.init`:
90-
91-
```javascript
92-
Sentry.init({
93-
// ...
94-
tracingOptions: {
95-
trackComponents: true;
96-
timeout: 500;
97-
hooks: ['mount', 'update'];
98-
}
99-
})
100-
```
101-
102-
Note, that when you use this property there is no change in behaviour, as opposed to when you use the three top-level properties described above.
103-
104-
The default value for `tracingOptions` is `undefined`.
95+
The default timeout is `2000` milliseconds.

docs/platforms/javascript/guides/vue/features/component-tracking.mdx

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Learn how Sentry's Vue SDK allows you to monitor the rendering per
44
sidebar_order: 10
55
---
66

7-
Sentry's Vue SDK offers a feature to monitor the performance of your Vue components: component tracking. Enabling this feature provides you with spans in your transactions that represent the component life cycle events and durations. This allows you to get a drilled-down view into how your components are behaving so you can do things like identify slow initializations or frequent updates, which might have an impact on your app's performance.
7+
Sentry's Vue SDK offers a feature to monitor the performance of your Vue components: component tracking. Enabling this feature provides you with spans in your transactions that represent the component lifecycle events and durations. This allows you to get a drilled-down view into how your components are behaving so you can do things like identify slow initializations or frequent updates, which might have an impact on your app's performance.
88

99
## Usage
1010

@@ -18,87 +18,86 @@ To set up component tracking, you need to configure tracing. For details on how
1818

1919
By default, the Vue SDK tracks the rendering performance of your app (that is, its root component) on the initial page load. This operation is represented in the page load transaction by the **`ui.vue.render`** span.
2020

21-
### Child Components
21+
### Child Component Tracking
2222

2323
You can also track your app's child components to get more details about the rendering process. This feature will create spans for each tracked component instance. The spans are called **`ui.vue.[hook]`** where `[hook]` is replaced by each tracked lifecycle stage. For example, the span representing the mount stage (the time between `beforeMount` and `mounted`) is called `ui.vue.mount`.
2424

25-
To set it up, add, at minimum, [`trackComponents`](#trackcomponents) in your `Sentry.init` call. Optionally, you can also add [`hooks`](#hooks), and [`timeout`](#timeout).
25+
To set it up, add the Vue Integration to your `Sentry.init()` call and, set the `tracingOptions.trackComponents` option.
26+
Set the `trackComponent` option to `true` to track all of your child components, or specify a list of individual comopnents you want to track:
2627

27-
#### `trackComponents`
28+
```javascript {5-17}
29+
import * as Sentry from "@sentry/vue";
2830

29-
This is the main option that controls which child components should be tracked. Set it to `true` to track all of them or specify a list of individual components you want to track:
30-
31-
```javascript
3231
Sentry.init({
33-
// ...
34-
trackComponents: true,
35-
// OR
36-
trackComponents: [
37-
"App",
38-
"RwvHeader",
39-
"RwvFooter",
40-
"RwvArticleList",
41-
"Pagination",
32+
integrations: [
33+
Sentry.vueIntegration({
34+
tracingOptions: {
35+
trackComponents: true,
36+
// OR
37+
trackComponents: [
38+
"App",
39+
"RwvHeader",
40+
"RwvFooter",
41+
"RwvArticleList",
42+
"Pagination",
43+
],
44+
},
45+
}),
4246
],
4347
});
4448
```
4549

46-
The default is `false`.
50+
The default value for `trackComponents` is `false`.
51+
52+
#### Track Specific Component Lifecycle Hooks
4753

48-
#### `hooks`
54+
You can control which lifecycle hooks should be tracked. This is helpful if, for example, you want to know if some components are removed during the initial page load, in which case you can configure the integration to also track `unmount` hooks:
4955

50-
Control which lifecycle hooks should be tracked. This is helpful if, for example, you want to know if some components are removed during the initial page load, in which case you can add a `unmount` hook to the default:
56+
```javascript {8}
57+
import * as Sentry from "@sentry/vue";
5158

52-
```javascript
5359
Sentry.init({
54-
// ...
55-
trackComponents: true
56-
hooks: ["mount", "update", "unmount"],
60+
integrations: [
61+
Sentry.vueIntegration({
62+
tracingOptions: {
63+
trackComponents: true
64+
hooks: ["mount", "update", "unmount"],
65+
},
66+
}),
67+
],
5768
});
5869
```
5970

60-
The following hooks are available to track in Vue 3: `['activate', 'create', 'unmount', 'mount', 'update']`
71+
The default set of tracked hooks is `['activate', 'mount', 'update']`.
6172

62-
Note that when specifying `hooks`, we use the simple verb rather than `before` and `-ed` pairs. For example, `unmount` is correct, while `beforeUnmount` and `unmounted` are incorrect.
73+
The following hooks are available to track in Vue 3: `['activate', 'create', 'unmount', 'mount', 'update']`
6374

6475
<Alert>
6576

66-
In Vue 2, use `destroy` instead of `unmount`. `destroy` does not work in Vue 3, as the names of the lifecycle hooks themselves [changed](https://v3-migration.vuejs.org/breaking-changes/#other-minor-changes) in Vue 3.
77+
In Vue 2, use `destroy` instead of `unmount`. `destroy` does not work in Vue 3, as the names of the lifecycle hooks [changed](https://v3-migration.vuejs.org/breaking-changes/#other-minor-changes) in Vue 3.
6778

6879
</Alert>
6980

70-
The default set of hooks is `['activate', 'mount', 'update']`.
81+
Note that when specifying `hooks`, we use the simple verb rather than `before` and `-ed` pairs. For example, `unmount` is correct, while `beforeUnmount` and `unmounted` are incorrect.
7182

72-
#### `timeout`
83+
#### Configure a Timeout for Component Tracking
7384

74-
You can specify how long the root rendering span should wait for the last component to render.
85+
You can specify how long the root rendering span should wait for the last component to render by configuring the `timeout` option in milliseconds.
7586
Every new rendering cycle debounces the timeout, and it starts counting from the beginning. Once the timeout is reached, tracking is completed, and all the rendering information is sent to Sentry:
7687

77-
```javascript
78-
Sentry.init({
79-
// ...
80-
trackComponents: true,
81-
timeout: 500,
82-
});
83-
```
84-
85-
The default is `2000`.
86-
87-
#### Alternative Configuration With `tracingOptions`
88+
```javascript {8}
89+
import * as Sentry from "@sentry/vue";
8890

89-
You can also group the component tracking options by using the optional `tracingOptions` property in `Sentry.init`:
90-
91-
```javascript
9291
Sentry.init({
93-
// ...
94-
tracingOptions: {
95-
trackComponents: true;
96-
timeout: 500;
97-
hooks: ['mount', 'update'];
98-
}
99-
})
92+
integrations: [
93+
Sentry.vueIntegration({
94+
tracingOptions: {
95+
trackComponents: true,
96+
timeout: 500, // milliseconds
97+
},
98+
}),
99+
],
100+
});
100101
```
101102

102-
Note that when you use this property there is no change in behaviour, as opposed to when you use the three top-level properties described above.
103-
104-
The default value for `tracingOptions` is `undefined`.
103+
The default timeout is `2000` milliseconds.

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ To initialize Sentry in your Vue application, add the following code snippet to
22

33
### Vue 3
44

5-
65
```javascript {filename:main.js} {"onboardingOptions": {"performance": "16, 19-26", "session-replay": "17, 27-31"}}
76
import { createApp } from "vue";
87
import { createRouter } from "vue-router";
@@ -43,7 +42,6 @@ app.mount("#app");
4342

4443
### Vue 2
4544

46-
4745
```javascript {filename:main.js} {"onboardingOptions": {"performance": "15, 18-25", "session-replay": "16, 26-30"}}
4846
import Vue from "vue";
4947
import Router from "vue-router";
@@ -93,8 +91,7 @@ The SDK accepts a few Vue-specific `Sentry.init` configuration options:
9391

9492
- `attachProps` (defaults to `true`) - Includes all Vue components' props with the events.
9593
- `logErrors` (defaults to `true`) - Decides whether SDK should call Vue's original `logError` function as well.
96-
- `trackComponents` (defaults to `false`) - Track your app's components. Learn more about [component tracking](./features/component-tracking) and all its options.
97-
94+
- Check out how to [Track Vue Components](./features/component-tracking) for performance.
9895

9996
### Late-Defined Vue Apps
10097

0 commit comments

Comments
 (0)