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/>',
});
8.37.0
Important Changes
- feat(nuxt): Add
piniaIntegration
(#14138)
The Nuxt SDK now allows you to track Pinia state for captured errors. To enable the Pinia plugin, add the piniaIntegration
to your client config:
// sentry.client.config.ts
import { usePinia } from '#imports';
Sentry.init({
integrations: [
Sentry.piniaIntegration(usePinia(), {
/* optional Pinia plugin options */
}),
],
});
- feat: Deprecate metrics API (#14157)
The Sentry Metrics beta has ended in favour of revisiting metrics in another form at a later date.
This new approach will include different APIs, making the current metrics API unnecessary. This release
deprecates the metrics API with the plan to remove in the next SDK major version. If you currently use the
metrics API in your code, you can safely continue to do so but sent data will no longer be processed by Sentry.
Learn more about the end of the Metrics beta.
Other Changes
- feat(browser): Add
http.response_delivery_type
attribute to resource spans (#14056) - feat(browser): Add
skipBrowserExtensionCheck
escape hatch option (#14147) - feat(deps): Bump @opentelemetry/instrumentation from 0.53.0 to 0.54.0 (#14174)
- feat(deps): Bump @opentelemetry/instrumentation-fastify from 0.40.0 to 0.41.0 (#14175)
- feat(deps): Bump @opentelemetry/instrumentation-graphql from 0.43.0 to 0.44.0 (#14173)
- feat(deps): Bump @opentelemetry/instrumentation-mongodb from 0.47.0 to 0.48.0 (#14171)
- feat(deps): Bump @opentelemetry/propagator-aws-xray from 1.25.1 to 1.26.0 (#14172)
- feat(nuxt): Add
asyncFunctionReExports
to define re-exported server functions (#14104) - feat(nuxt): Add
piniaIntegration
(#14138) - fix(browser): Avoid recording long task spans starting before their parent span (#14183)
- fix(core): Ensure errors thrown in async cron jobs bubble up (#14182)
- fix(core): Silently fail
maybeInstrument
(#14140) - fix(nextjs): Resolve path for dynamic webpack import (#13751)
- fix(node): Make sure
modulesIntegration
does not crash esm apps (#14169)
Work in this release was contributed by @rexxars. Thank you for your contribution!