You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/vue/features/component-tracking.mdx
+52-53Lines changed: 52 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: "Learn how Sentry's Vue SDK allows you to monitor the rendering per
4
4
sidebar_order: 10
5
5
---
6
6
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.
8
8
9
9
## Usage
10
10
@@ -18,87 +18,86 @@ To set up component tracking, you need to configure tracing. For details on how
18
18
19
19
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.
20
20
21
-
### Child Components
21
+
### Child Component Tracking
22
22
23
23
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`.
24
24
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:
26
27
27
-
#### `trackComponents`
28
+
```javascript {5-17}
29
+
import*asSentryfrom"@sentry/vue";
28
30
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
32
31
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
+
}),
42
46
],
43
47
});
44
48
```
45
49
46
-
The default is `false`.
50
+
The default value for `trackComponents` is `false`.
51
+
52
+
#### Track Specific Component Lifecycle Hooks
47
53
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:
49
55
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*asSentryfrom"@sentry/vue";
51
58
52
-
```javascript
53
59
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
+
],
57
68
});
58
69
```
59
70
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']`.
61
72
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']`
63
74
64
75
<Alert>
65
76
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.
67
78
68
79
</Alert>
69
80
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.
71
82
72
-
#### `timeout`
83
+
#### Configure a Timeout for Component Tracking
73
84
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.
75
86
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:
76
87
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*asSentryfrom"@sentry/vue";
88
90
89
-
You can also group the component tracking options by using the optional `tracingOptions` property in `Sentry.init`:
90
-
91
-
```javascript
92
91
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
+
});
100
101
```
101
102
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`.
@@ -93,8 +91,7 @@ The SDK accepts a few Vue-specific `Sentry.init` configuration options:
93
91
94
92
-`attachProps` (defaults to `true`) - Includes all Vue components' props with the events.
95
93
-`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.
0 commit comments