Skip to content

Commit fe8cabc

Browse files
authored
Streamline nuxt component tracking (#11993)
1 parent 4b3d240 commit fe8cabc

File tree

2 files changed

+53
-60
lines changed

2 files changed

+53
-60
lines changed

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

Lines changed: 52 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,101 +4,94 @@ 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 have an impact on your app's performance.
88

99
## Usage
1010

1111
<Alert>
1212

13-
To set up component tracking, you need to first configure performance monitoring. For details on how to do this, check out our [Performance documentation](/platforms/javascript/guides/nuxt/performance/).
13+
To set up component tracking, you need to first configure tracing. For details on how to do this, check out our [Tracing documentation](/platforms/javascript/guides/nuxt/performance/).
1414

1515
</Alert>
1616

1717
### Initial Application Load
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 `vueIntegration` to your `Sentry.init()` call and, set the `tracingOptions.trackComponents` option.
26+
Pass `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-
// ...
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']`
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 default set of tracked hooks is `['activate', '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).
73+
The following hooks are available to track: `['activate', 'create', 'unmount', 'mount', 'update']`
6774

68-
</Alert>
75+
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.
6976

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

72-
#### `timeout`
79+
You can specify how long the root rendering span should wait for the last component to render by configuring the `timeout` option in milliseconds.
80+
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:
7381

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:
82+
```javascript {8}
83+
import * as Sentry from "@sentry/nuxt";
7684

77-
```javascript
7885
Sentry.init({
79-
// ...
80-
trackComponents: true,
81-
timeout: 500,
86+
integrations: [
87+
Sentry.vueIntegration({
88+
tracingOptions: {
89+
trackComponents: true,
90+
timeout: 500, // milliseconds
91+
},
92+
}),
93+
],
8294
});
8395
```
8496

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`.
97+
The default timeout is `2000` milliseconds.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ By default, the Vue SDK tracks the rendering performance of your app (that is, i
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

2525
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+
Pass `true` to track all of your child components, or specify a list of individual comopnents you want to track:
2727

2828
```javascript {5-17}
2929
import * as Sentry from "@sentry/vue";

0 commit comments

Comments
 (0)