Files
my-notes-viewer/frontend/src/sentry.ts
T
apairon 62f1906276 🔧 fix: update Traefik router rule for MCP/curl access to include host condition
 feat: enable sending default PII in Sentry initialization
2026-02-11 14:25:26 +00:00

54 lines
1.6 KiB
TypeScript

import * as Sentry from "@sentry/svelte"
let initialized = false
export const init = (dsn: string, tracingOrigins: (string | RegExp)[], environment: string, release: string) => {
if (typeof window !== "undefined") {
Sentry.init({
dsn: dsn,
tunnel: "/_s",
tracePropagationTargets: tracingOrigins,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: false,
maskAllInputs: false,
blockAllMedia: false,
networkDetailAllowUrls: [/\/api\//],
mutationLimit: 99999,
mutationBreadcrumbLimit: 2000,
}),
],
environment: environment,
tracesSampleRate: 1.0,
debug: false,
release: release,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
sendDefaultPii: true,
})
console.log("Sentry initialized")
initialized = true
}
}
// export const startSpan = (opt: { name: string; op: string }) => {
// if (typeof window !== "undefined" && initialized) {
// return Sentry.startInactiveSpan(opt)
// }
// }
export const currentTransaction = () => {
const activeSpan = Sentry.getActiveSpan()
if (activeSpan && activeSpan) {
return activeSpan
}
return null
}
export const setUser = (user: Sentry.User) => {
if (typeof window !== "undefined" && initialized) {
user.ip_address = "{{auto}}"
Sentry.setUser(user)
}
}