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 --yesCustomize in the configurator
Packages it adds
| Package | Version | Type |
|---|---|---|
@sentry/vue | ^11.19.0 | runtime |
New files
VITE_SENTRY_DSN=
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
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
.env.example.gitignoreREADME.mdenv.d.tsindex.htmlpackage.jsonsrc/App.vuesrc/assets/main.csssrc/components/CounterCard.vuesrc/main.tssrc/sentry.tstsconfig.app.jsontsconfig.jsontsconfig.node.jsonvite.config.ts