pickstack

Vue + Sentry

Error monitoring and tracing with Sentry; off until you set a DSN. This page shows exactly what pickstack adds to a Vue project for Sentry: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.

$ npm create pickstack@latest my-app -- --framework vue --modules sentry --yes
Customize in the configurator

Packages it adds

PackageVersionType
@sentry/vue^11.19.0runtime

New files

.env.example
VITE_SENTRY_DSN=
src/sentry.ts
import * as Sentry from "@sentry/vue";
import type { App } from "vue";

/** `app.use(sentry)`: sends errors and traces once the DSN is set (see .env.example). */
export const sentry = {
  install(app: App) {
    const dsn = import.meta.env.VITE_SENTRY_DSN;
    if (!dsn) return;
    Sentry.init({
      app,
      dsn,
      integrations: [Sentry.browserTracingIntegration()],
      // Traces 10% of page loads; raise it while trying things out.
      tracesSampleRate: 0.1,
    });
  },
};

Changes to existing files

src/main.ts (changed)
 import { createApp } from "vue"; import App from "./App.vue";+import { sentry } from "./sentry"; import "./assets/main.css";  +const app = createApp(App);+ +app.use(sentry);+ +app.mount("#app");−createApp(App).mount("#app");  

Project files

Related templates