-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Instruct to use the recommended way of using Vue component tracking #11917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
sidebar_order: 10 | ||
--- | ||
|
||
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. | ||
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. | ||
|
||
## Usage | ||
|
||
|
@@ -18,87 +18,86 @@ To set up component tracking, you need to configure tracing. For details on how | |
|
||
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. | ||
|
||
### Child Components | ||
### Child Component Tracking | ||
|
||
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`. | ||
|
||
To set it up, add, at minimum, [`trackComponents`](#trackcomponents) in your `Sentry.init` call. Optionally, you can also add [`hooks`](#hooks), and [`timeout`](#timeout). | ||
To set it up, add the Vue Integration to your `Sentry.init()` call and, set the `tracingOptions.trackComponents` option. | ||
Set the `trackComponent` option to `true` to track all of your child components, or specify a list of individual comopnents you want to track: | ||
|
||
#### `trackComponents` | ||
```javascript {5-17} | ||
import * as Sentry from "@sentry/vue"; | ||
|
||
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: | ||
|
||
```javascript | ||
Sentry.init({ | ||
// ... | ||
trackComponents: true, | ||
// OR | ||
trackComponents: [ | ||
"App", | ||
"RwvHeader", | ||
"RwvFooter", | ||
"RwvArticleList", | ||
"Pagination", | ||
integrations: [ | ||
Sentry.vueIntegration({ | ||
tracingOptions: { | ||
trackComponents: true, | ||
// OR | ||
trackComponents: [ | ||
"App", | ||
"RwvHeader", | ||
"RwvFooter", | ||
"RwvArticleList", | ||
"Pagination", | ||
], | ||
}, | ||
}), | ||
], | ||
}); | ||
``` | ||
|
||
The default is `false`. | ||
The default value for `trackComponents` is `false`. | ||
|
||
#### Track Specific Component Lifecycle Hooks | ||
|
||
#### `hooks` | ||
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: | ||
|
||
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: | ||
```javascript {8} | ||
import * as Sentry from "@sentry/vue"; | ||
|
||
```javascript | ||
Sentry.init({ | ||
// ... | ||
trackComponents: true | ||
hooks: ["mount", "update", "unmount"], | ||
integrations: [ | ||
Sentry.vueIntegration({ | ||
tracingOptions: { | ||
trackComponents: true | ||
hooks: ["mount", "update", "unmount"], | ||
}, | ||
}), | ||
], | ||
}); | ||
``` | ||
|
||
The following hooks are available to track in Vue 3: `['activate', 'create', 'unmount', 'mount', 'update']` | ||
The default set of tracked hooks is `['activate', 'mount', 'update']`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's another item in the v9 list to remove |
||
|
||
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. | ||
The following hooks are available to track in Vue 3: `['activate', 'create', 'unmount', 'mount', 'update']` | ||
|
||
<Alert> | ||
|
||
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. | ||
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. | ||
|
||
</Alert> | ||
|
||
The default set of hooks is `['activate', 'mount', 'update']`. | ||
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. | ||
|
||
#### `timeout` | ||
#### Configure a Timeout for Component Tracking | ||
|
||
You can specify how long the root rendering span should wait for the last component to render. | ||
You can specify how long the root rendering span should wait for the last component to render by configuring the `timeout` option in milliseconds. | ||
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: | ||
|
||
```javascript | ||
Sentry.init({ | ||
// ... | ||
trackComponents: true, | ||
timeout: 500, | ||
}); | ||
``` | ||
|
||
The default is `2000`. | ||
|
||
#### Alternative Configuration With `tracingOptions` | ||
```javascript {8} | ||
import * as Sentry from "@sentry/vue"; | ||
|
||
You can also group the component tracking options by using the optional `tracingOptions` property in `Sentry.init`: | ||
|
||
```javascript | ||
Sentry.init({ | ||
// ... | ||
tracingOptions: { | ||
trackComponents: true; | ||
timeout: 500; | ||
hooks: ['mount', 'update']; | ||
} | ||
}) | ||
integrations: [ | ||
Sentry.vueIntegration({ | ||
tracingOptions: { | ||
trackComponents: true, | ||
timeout: 500, // milliseconds | ||
}, | ||
}), | ||
], | ||
}); | ||
``` | ||
|
||
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. | ||
|
||
The default value for `tracingOptions` is `undefined`. | ||
The default timeout is `2000` milliseconds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Iet's also add the hooks tracked by default here