@sentry/vue package provides error tracking and performance monitoring for Vue.js applications. It supports both Vue 2.x and Vue 3.x.
Prerequisites
- Node.js 18 or newer
- Vue.js 2.x or 3.x
- A Sentry account and project DSN
Installation
1
Install the Package
Install Current Version: 10.42.0
@sentry/vue using your preferred package manager:2
Initialize Sentry for Vue 3
Initialize Sentry as early as possible in your application:
Pass your Vue app instance to
Sentry.init() to enable automatic component tracking and Vue-specific error handling.3
Initialize Sentry for Vue 2
For Vue 2 applications, pass the Vue constructor instead:
4
Verify Installation
Test that Sentry is working:Check your Sentry dashboard to see the error.
Vue Router Integration
With Vue Router
For automatic page load and navigation tracking:Without Vue Router
If you’re not using Vue Router, omit therouter option:
TanStack Router Integration
If you use TanStack Router for Vue instead of Vue Router:The TanStack Router integration is exported from
@sentry/vue/tanstackrouter.Error Tracking
Automatic Error Capture
The SDK automatically captures:- Errors thrown in component lifecycle hooks
- Errors in event handlers
- Errors in watchers
- Errors in render functions
Manual Error Capture
In Composition API
Setting Context
User Context
Tags and Context
Breadcrumbs
Performance Monitoring
Component Tracking
Sentry automatically tracks Vue component lifecycle performance when you pass theapp instance:
Custom Spans
Pinia Integration
Track Pinia store actions:Session Replay
Capture session replays to see what users experienced:Privacy Controls
Advanced Configuration
TypeScript Support
The SDK includes TypeScript definitions:Custom Error Handler
If you have a custom error handler, make sure Sentry is initialized first:Filtering Components
Control which components are tracked:Troubleshooting
Source Maps
For Vite projects:Errors Not Being Captured
Make sure:Sentry.init()is called before creating the Vue app- You passed the
appinstance (Vue 3) orVueconstructor (Vue 2) - The error is not caught by a
try/catchwithout re-throwing
Performance Not Tracked
Ensure:tracesSampleRateis set to a value greater than 0- The router is passed to
browserTracingIntegration - You’re using a supported router (Vue Router or TanStack Router)
Next Steps
- Configure Vue Router Integration
- Set up Pinia Integration
- Learn about Session Replay
- Explore Performance Monitoring