What is @sentry/vue?
@sentry/vue is an official Sentry SDK for Vue.js applications. It allows developers to monitor and track errors, performance issues, and other events in their Vue.js applications. The package provides seamless integration with Vue.js, enabling automatic error tracking and performance monitoring.
What are @sentry/vue's main functionalities?
Error Tracking
This feature allows you to initialize Sentry in your Vue.js application to automatically capture and report errors. The `dsn` is your Sentry Data Source Name, which uniquely identifies your project.
import * as Sentry from '@sentry/vue';
import { Integrations } from '@sentry/tracing';
import Vue from 'vue';
Sentry.init({
Vue: Vue,
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
integrations: [new Integrations.BrowserTracing()],
tracesSampleRate: 1.0,
});
Performance Monitoring
This feature allows you to monitor the performance of your Vue.js application. You can track custom transactions and measure the performance of specific parts of your application.
import * as Sentry from '@sentry/vue';
import { Integrations } from '@sentry/tracing';
import Vue from 'vue';
Sentry.init({
Vue: Vue,
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
integrations: [new Integrations.BrowserTracing()],
tracesSampleRate: 1.0,
});
// Example of a custom transaction
const transaction = Sentry.startTransaction({
op: 'test',
name: 'My Custom Transaction',
});
setTimeout(() => {
transaction.finish();
}, 99);
Manual Error Reporting
This feature allows you to manually capture and report exceptions in your Vue.js application. This is useful for capturing errors that are not automatically caught by Sentry.
import * as Sentry from '@sentry/vue';
import Vue from 'vue';
Sentry.init({
Vue: Vue,
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
});
// Manually capture an exception
try {
throw new Error('This is a test error');
} catch (error) {
Sentry.captureException(error);
}
Other packages similar to @sentry/vue
bugsnag-js
Bugsnag provides error monitoring and crash reporting for web and mobile applications. It offers similar functionalities to @sentry/vue, such as automatic error tracking and performance monitoring. Bugsnag also provides detailed error reports and supports various platforms, including Vue.js.
rollbar
Rollbar is an error tracking and monitoring service that supports multiple languages and frameworks, including Vue.js. It offers real-time error reporting, automatic error grouping, and detailed error insights. Rollbar is comparable to @sentry/vue in terms of functionality and ease of integration.
airbrake-js
Airbrake provides error monitoring and performance management for web applications. It supports Vue.js and offers features like real-time error tracking, detailed error reports, and performance monitoring. Airbrake is similar to @sentry/vue in its capabilities and integration process.
Official Sentry SDK for Vue.js
Links
General
This package is a wrapper around @sentry/browser
, with added functionality related to Vue.js. All methods available in
@sentry/browser
can be imported from @sentry/vue
.
To use this SDK, call Sentry.init(options)
as early in your application as possible.
Vue 3
const app = createApp({
});
Sentry.init({
app,
dsn: '__PUBLIC_DSN__',
integrations: [
Sentry.browserTracingIntegration({ router }),
],
});
Vue 2
import Vue from 'vue';
import App from './App';
import router from './router';
import * as Sentry from '@sentry/vue';
Sentry.init({
Vue: Vue,
dsn: '__PUBLIC_DSN__',
integrations: [
Sentry.browserTracingIntegration({ router }),
],
});
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>',
});
9.16.0
Important changes
- feat: Create a Vite plugin that injects sentryConfig into the global config (#16197)
Add a new plugin makeConfigInjectorPlugin
within our existing vite plugin that updates the global vite config with sentry options
- feat(browser): Add option to sample linked traces consistently (#16037)
This PR implements consistent sampling across traces as outlined in (#15754)
- feat(cloudflare): Add support for durable objects (#16180)
This PR introduces a new instrumentDurableObjectWithSentry
method to the SDK, which instruments durable objects. We capture both traces and errors automatically.
- feat(node): Add Prisma integration by default (#16073)
Prisma integration is enabled by default, it should work for both ESM and CJS.
- feat(react-router): Add client-side router instrumentation (#16185)
Adds client-side instrumentation for react router's HydratedRouter
. To enable it, simply replace browserTracingIntegration()
with reactRouterTracingIntegration()
in your client-side init call.
- fix(node): Avoid double-wrapping http module (#16177)
When running your application in ESM mode, there have been scenarios that resulted in the http
/https
emitting duplicate spans for incoming requests. This was apparently caused by us double-wrapping the modules for incoming request isolation.
In order to solve this problem, the modules are no longer monkey patched by us for request isolation. Instead, we register diagnosticschannel hooks to handle request isolation now.
While this is generally not expected to break anything, there is one tiny change that _may affect you if you have been relying on very specific functionality:
The ignoreOutgoingRequests
option of httpIntegration
receives the RequestOptions
as second argument. This type is not changed, however due to how the wrapping now works, we no longer pass through the full RequestOptions, but re-construct this partially based on the generated request. For the vast majority of cases, this should be fine, but for the sake of completeness, these are the only fields that may be available there going forward - other fields that may have existed before may no longer be set:
ignoreOutgoingRequests(url: string, {
method: string;
protocol: string;
host: string;
hostname: string; // same as host
path: string;
headers: OutgoingHttpHeaders;
})
Other changes
- feat(cloudflare): Add logs exports (#16165)
- feat(vercel-edge): Add logs export (#16166)
- feat(cloudflare): Read
SENTRY_RELEASE
from env
(#16201)
- feat(node): Drop
http.server
spans with 404 status by default (#16205)
- fix(browser): Respect manually set sentry tracing headers in XHR requests (#16184)
- fix(core): Respect manually set sentry tracing headers in fetch calls (#16183)
- fix(feedback): Prevent
removeFromDom()
from throwing (#16030)
- fix(node): Use class constructor in docstring for winston transport (#16167)
- fix(node): Fix vercel flushing logic & add test for it (#16208)
- fix(node): Fix 404 route handling in express 5 (#16211)
- fix(logs): Ensure logs can be flushed correctly (#16216)
- ref(core): Switch to standardized log envelope (#16133)