Fix/logging warmup background * fix: logging in background functions * fix logging * fix logging * fix logging Approved-by: Linus Flood
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
/* eslint-disable no-console */
|
|
import Sentry from "@sentry/nextjs"
|
|
|
|
export const denyUrls: (string | RegExp)[] = [
|
|
// Ignore preview urls
|
|
/\/.{2}\/preview\//,
|
|
]
|
|
|
|
export const onRequestError = Sentry.captureRequestError
|
|
|
|
export async function configureSentry() {
|
|
const sentryEnvironment = Netlify.env.get("NEXT_PUBLIC_SENTRY_ENVIRONMENT")
|
|
const sampleRate = Number(Netlify.env.get("SENTRY_SERVER_SAMPLERATE") ?? 0.01)
|
|
Sentry.init({
|
|
dsn: "https://fe39c070b4154e2f9cc35f0e5de0aedb@o4508102497206272.ingest.de.sentry.io/4508102500286544",
|
|
environment: sentryEnvironment,
|
|
enabled: sentryEnvironment !== "development",
|
|
tracesSampleRate: sampleRate,
|
|
denyUrls: denyUrls,
|
|
enableLogs: true,
|
|
beforeSendLog(log) {
|
|
switch (log.level) {
|
|
case "info":
|
|
console.log(log.message, log)
|
|
break
|
|
case "warn":
|
|
console.warn(log.message, log)
|
|
break
|
|
case "error":
|
|
console.error(log.message, log)
|
|
break
|
|
}
|
|
|
|
return log
|
|
},
|
|
})
|
|
}
|