Files
tibi-docs/frontend/src/sentry.ts
Sebastian Frank 86e0a17265
All checks were successful
deploy to production / deploy (push) Successful in 45s
yarn package upgrades, ssr update
2023-11-15 07:00:12 +00:00

43 lines
1.3 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",
integrations: [
new Sentry.BrowserTracing({
tracingOrigins: tracingOrigins,
traceFetch: false,
traceXHR: false,
}),
new Sentry.Replay({
maskAllText: false,
maskAllInputs: false,
blockAllMedia: false,
networkDetailAllowUrls: [/\/api\//],
}),
],
environment: environment,
tracesSampleRate: 1.0,
debug: false,
release: release,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
})
console.log("Sentry initialized")
initialized = true
}
}
export const currentTransaction = () => Sentry.getCurrentHub().getScope().getTransaction()
export const setUser = (user: Sentry.User) => {
if (typeof window !== "undefined" && initialized) {
user.ip_address = "{{auto}}"
Sentry.setUser(user)
}
}