cd sentry-project
npm install
npm run dev
npm install --save @sentry/vue @sentry/tracing
import { createApp } from "vue";
import App from "./App.vue";
import * as Sentry from "@sentry/vue";
import "./assets/main.css";
const app = createApp(App);
Sentry.init({
app,
dsn: "https://3b1b65fe8df141a68c1541bac7807899@o200463.ingest.sentry.io/4504840498249728",
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});
app.mount("#app");
<script>
...
export default {
...
created() {
...
throw new Error("App created error");
},
};
</script>
import * as Sentry from "@sentry/browser";
try {
aFunctionThatMightFail();
} catch (err) {
Sentry.captureException(err);
}
Sentry.captureMessage("Something went wrong");
Sentry.setUser({
username: "Alan Santos",
email: "alan.fsantos@totvs.com.br",
});
Sentry.init({
app,
dsn: "https://b8f9ef9ed39947268a0c6cba916e2377@o200463.ingest.sentry.io/4504845230735360",
//...
beforeSend(event, hint) {
if (event.exception) {
Sentry.showReportDialog({ eventId: event.event_id });
}
return event;
},
});
...
import { BrowserTracing } from "@sentry/tracing";
Sentry.init({
app,
dsn: "https://b8f9ef9ed39947268a0c6cba916e2377@o200463.ingest.sentry.io/4504845230735360",
integrations: [new BrowserTracing()],
...
});
Sentry.init({
...
ignoreErrors: [
"jigsaw is not defined",
"ComboSearch is not defined",
],
});
Sentry.init({
...
// Called for message and error events
beforeSend(event) {
const error = hint.originalException;
if (
error &&
error.message &&
error.message.match(/database unavailable/i)
) {
event.fingerprint = ["database-unavailable"];
}
return event;
},
});
export default {
...
created() {
Sentry.setContext("Armazenamento", {
localStorage: JSON.stringify(localStorage).length,
sessionStorage: JSON.stringify(sessionStorage).length,
});
}
...
}
export default {
...
created() {
Sentry.configureScope(scope => scope.setTransactionName("Tela Inicial"));
}
...
}
export default {
...
created() {
Sentry.setTag("page_locale", "pt-br");
}
...
}
export default {
...
created() {
Sentry.addBreadcrumb({
category: "ciclo de vida",
message: "componente criado",
level: "info",
});
}
...
}
Sentry.init({
...
// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.1,
// If the entire session is not sampled, use the below sample rate to sample
// sessions when an error occurs.
replaysOnErrorSampleRate: 1.0,
integrations: [
...
new Sentry.Replay({
// Additional SDK configuration goes in here, for example:
maskAllText: true,
blockAllMedia: true,
}),
],
});
export default {
...
methods: {
throwError() {
throw new Error("Coisar o erro");
},
},
...
}
<template>
<div class="wrapper">
<HelloWorld msg="You did it!" />
<button @click="throwError">Coisar o erro</button>
</div>
</template>