Vue

To use Sentry with your Vue application, you will need to use Sentry’s Vue SDK: @sentry/vue.

Copied
npm install --save  @sentry/vue

On its own, @sentry/vue will report any uncaught exceptions triggered by your application.

Additionally, the SDK will capture the name and props state of the active component where the error was thrown. This is reported via Vue’s config.errorHandler hook.

Then add this to your app.js:

Copied
import Vue from "vue";
import * as Sentry from '@sentry/vue';

Sentry.init({
  Vue: Vue,
  dsn: '__PUBLIC_DSN__',
});

Additionally the SDK accepts a few different configuration options that let you change its behavior:

  • Passing in Vue is optional, if you do not pass it window.Vue must be present.
  • Passing in attachProps is optional and is true if it is not provided. If you set it to false, Sentry will suppress sending all Vue components' props for logging.
  • Passing in logErrors is optional and is false if it is not provided. If you set it to true, Sentry will call original Vue's logError function as well.

In case you are using the CDN version or the Loader, we provide a standalone file for every integration, you can use it like this:

Copied
<script	
  src="https://browser.sentry-cdn.com/6.0.1/vue.min.js"	
  integrity="sha384-ZhUqMWRVNnMf+BalnWBZFnc647u8W2Rx20+rNjm0mJAG5m5F2BFuN1BtyUkkea0y"	
  crossorigin="anonymous"	
></script>	

<script>	
  Sentry.init({	
    Vue,
    dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",	
  });	
</script>	

Monitor Performance

Copied
npm install --save @sentry/vue @sentry/tracing

The most basic configuration for tracing your Vue app, which would track only the top-level component, looks like this:

Copied
import Vue from "vue";
import * as Sentry from "@sentry/vue";
import { Integrations } from "@sentry/tracing";

Sentry.init({
  // ...
  integrations: [
    new Integrations.BrowserTracing(),
  ],

  // We recommend adjusting this value in production, or using tracesSampler
  // for finer control
  tracesSampleRate: 1.0,
});

If you want to track child components, and see more details about the rendering process, configure the integration to track them all:

Copied
Sentry.init({
  Vue,
  tracingOptions: {
    trackComponents: true,
  },
});
You can edit this page on GitHub.